Chromium Code Reviews| Index: chrome/browser/profiles/profile.cc |
| diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc |
| index 5b6162d7d6d394a9b3a309424c1ae62048cda5d9..27ac91df6f36db7d3c9a0d5ceaad33ba4437d7c6 100644 |
| --- a/chrome/browser/profiles/profile.cc |
| +++ b/chrome/browser/profiles/profile.cc |
| @@ -19,6 +19,7 @@ |
| #include "components/sync_driver/sync_prefs.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/notification_source.h" |
| +#include "content/public/browser/storage_partition.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_ui.h" |
| @@ -36,6 +37,8 @@ |
| #include "extensions/browser/pref_names.h" |
| #endif |
| +using content::HostZoomMap; |
| + |
| Profile::Profile() |
| : restored_last_session_(false), |
| sent_destroyed_notification_(false), |
| @@ -144,10 +147,6 @@ void Profile::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
| prefs::kSelectFileLastDirectory, |
| std::string(), |
| user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| - registry->RegisterDoublePref( |
| - prefs::kDefaultZoomLevel, |
| - 0.0, |
| - user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| registry->RegisterDictionaryPref( |
| prefs::kPerHostZoomLevels, |
| user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| @@ -258,3 +257,50 @@ bool ProfileCompare::operator()(Profile* a, Profile* b) const { |
| return false; |
| return a->GetOriginalProfile() < b->GetOriginalProfile(); |
| } |
| + |
| +double Profile::GetDefaultZoomLevel() { |
| + return GetDefaultStoragePartition(this) |
| + ->GetHostZoomMap() |
| + ->GetDefaultZoomLevel(); |
| +} |
| + |
| +PrefService* Profile::GetZoomLevelPrefs() { |
| + return GetDefaultStoragePartition(this)->GetZoomLevelPrefs(); |
| +} |
| + |
| +void Profile::TrackZoomLevelsFromParent(Profile* parent) { |
| + // This function only makes sense in a derived class that implements |
| + // HostZoomMaps. |
| + DCHECK(GetProfileType() == INCOGNITO_PROFILE && |
| + parent->GetProfileType() == REGULAR_PROFILE); |
| + |
| + // Here we only want to use zoom levels stored in the main-context's default |
| + // storage partition. We're not interested in zoom levels in special |
| + // partitions, e.g. those used by WebViewGuests. |
| + HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); |
| + HostZoomMap* parent_host_zoom_map = |
| + HostZoomMap::GetDefaultForBrowserContext(parent); |
| + host_zoom_map->CopyFrom(parent_host_zoom_map); |
| + // Observe parenti profile's HostZoomMap changes so they can also be applied |
|
awong
2014/08/20 19:56:58
parenti -> parent
wjmaclean
2014/08/20 20:15:45
Done.
|
| + // to this profile's HostZoomMap. |
| + track_zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( |
| + base::Bind(&Profile::TrackZoomLevelChanged, base::Unretained(this))); |
|
awong
2014/08/20 19:56:58
Should add a note in TrackZoomLevelChanged() that
wjmaclean
2014/08/20 20:15:45
I will add this in the next CL.
|
| +} |
| + |
| +void Profile::TrackZoomLevelChanged( |
| + const HostZoomMap::ZoomLevelChange& change) { |
| + HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); |
| + switch (change.mode) { |
| + case HostZoomMap::ZOOM_CHANGED_DEFAULT_ZOOM_LEVEL: |
| + case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: |
| + return; |
| + case HostZoomMap::ZOOM_CHANGED_FOR_HOST: |
| + host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); |
| + return; |
| + case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: |
| + host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, |
| + change.host, |
| + change.zoom_level); |
| + return; |
| + } |
| +} |