Index: chrome/browser/profiles/profile.cc |
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc |
index 06b7d1730e30132d746b7fa17bd0663a557a8385..b2f74ac1ab4495f160c8e37d6e881a0422ee8d88 100644 |
--- a/chrome/browser/profiles/profile.cc |
+++ b/chrome/browser/profiles/profile.cc |
@@ -36,6 +36,8 @@ |
#include "extensions/browser/pref_names.h" |
#endif |
+using content::HostZoomMap; |
+ |
Profile::Profile() |
: restored_last_session_(false), |
sent_destroyed_notification_(false), |
@@ -262,3 +264,39 @@ bool ProfileCompare::operator()(Profile* a, Profile* b) const { |
return false; |
return a->GetOriginalProfile() < b->GetOriginalProfile(); |
} |
+ |
+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 |
+ // to this profile's HostZoomMap. |
+ 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; |
+ } |
+} |