Chromium Code Reviews| Index: chrome/browser/profiles/profile.cc |
| diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc |
| index fc5cde6eaf12f7ec39f3c81ad335d405066236d4..6dbadb76dad46b2274114bba0b77a6ddabe82183 100644 |
| --- a/chrome/browser/profiles/profile.cc |
| +++ b/chrome/browser/profiles/profile.cc |
| @@ -33,6 +33,8 @@ |
| #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| #endif |
| +using content::HostZoomMap; |
| + |
| Profile::Profile() |
| : restored_last_session_(false), |
| sent_destroyed_notification_(false), |
| @@ -257,3 +259,37 @@ bool ProfileCompare::operator()(Profile* a, Profile* b) const { |
| return false; |
| return a->GetOriginalProfile() < b->GetOriginalProfile(); |
| } |
| + |
| +void Profile::TrackZoomLevelsFromParent(Profile* parent) { |
| + if (GetProfileType() != INCOGNITO_PROFILE || |
| + parent->GetProfileType() != REGULAR_PROFILE) |
| + return; |
| + |
| + // 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. |
|
awong
2014/08/11 22:36:33
Can we explain why? This is confusing to me...
wjmaclean
2014/08/12 16:57:44
The incognito profile, when created, basically tra
|
| + HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); |
| + HostZoomMap* parent_host_zoom_map = HostZoomMap::GetForBrowserContext(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::GetForBrowserContext(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; |
| + } |
| +} |