Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(735)

Unified Diff: chrome/browser/profiles/profile.cc

Issue 393133002: Migrate HostZoomMap to live in StoragePartition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove ref counts, improve comments. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile.cc
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc
index 06b7d1730e30132d746b7fa17bd0663a557a8385..e960809c3036524e25dd429d5d841a59999dc5b7 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,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 ||
Fady Samuel 2014/08/13 19:45:42 This seems like an assumption that may be violated
wjmaclean 2014/08/14 18:18:21 Done.
+ 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.
+ 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)));
Fady Samuel 2014/08/13 19:45:42 I worry about the lifetime implications here. What
wjmaclean 2014/08/14 18:18:21 The HostZoomMap lives in a StoragePartitionImpl in
Fady Samuel 2014/08/14 18:56:26 That doesn't seem to be the case looking at this c
wjmaclean 2014/08/14 19:12:20 My mistake, but we're still OK. Wrt to parent's Ho
+}
+
+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;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698