| Index: chrome/browser/profiles/profile.cc
|
| diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc
|
| index 5b6162d7d6d394a9b3a309424c1ae62048cda5d9..3400921b3dabeed3520caca9952cd788b99b278d 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(parent->GetProfileType() != INCOGNITO_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 parent profile's HostZoomMap changes so they can also be applied
|
| + // to this profile's HostZoomMap.
|
| + // Important: this function should never be made virtual without moving the
|
| + // subscription down to the leaf nodes(s).
|
| + track_zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback(
|
| + base::Bind(&Profile::TrackZoomLevelChanged, base::Unretained(this)));
|
| +}
|
| +
|
| +void Profile::TrackZoomLevelChanged(
|
| + const HostZoomMap::ZoomLevelChange& change) {
|
| + HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this);
|
| + switch (change.mode) {
|
| + 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;
|
| + }
|
| +}
|
|
|