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

Unified Diff: chrome/browser/ui/prefs/prefs_tab_helper.cc

Issue 393133002: Migrate HostZoomMap to live in StoragePartition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to 291677. 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/ui/prefs/prefs_tab_helper.cc
diff --git a/chrome/browser/ui/prefs/prefs_tab_helper.cc b/chrome/browser/ui/prefs/prefs_tab_helper.cc
index d6406993c49e59d1641e6fee96da83fa4387d8b5..6cc78186a767e48a1cdbcfbaf804a09b0e6294a0 100644
--- a/chrome/browser/ui/prefs/prefs_tab_helper.cc
+++ b/chrome/browser/ui/prefs/prefs_tab_helper.cc
@@ -21,7 +21,9 @@
#include "components/pref_registry/pref_registry_syncable.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/web_preferences.h"
#include "grit/locale_settings.h"
@@ -315,13 +317,39 @@ void OverrideFontFamily(WebPreferences* prefs,
PrefsTabHelper::PrefsTabHelper(WebContents* contents)
: web_contents_(contents),
weak_ptr_factory_(this) {
+ // TODO(wjmaclean) Would it be better to plumb a helper function on
+ // RenderProcessHost to simplify this type of call?
+ PrefService* zoom_level_prefs = contents->GetRenderProcessHost()
+ ->GetStoragePartition()
+ ->GetZoomLevelPrefs();
+ if (zoom_level_prefs) {
+ zoom_level_pref_change_registrar_.Init(zoom_level_prefs);
+ base::Closure renderer_callback = base::Bind(
+ &PrefsTabHelper::UpdateRendererPreferences, base::Unretained(this));
+ zoom_level_pref_change_registrar_.Add(prefs::kDefaultZoomLevel,
+ renderer_callback);
+ if (zoom_level_prefs->GetInitializationStatus() ==
+ PrefService::INITIALIZATION_STATUS_WAITING) {
+ // Unlike per-profile prefs, which are guaranteed to have initialized by
+ // the time we get here, zoom-level prefs (per-partition) may not have
+ // completed their initialization. In this case, we need to re-sync the
+ // renderer prefs once their initialization completes so that the default
+ // zoom level information is updated.
+ // TODO(wjmaclean) We need to determine if there are possible lifetime
+ // issues here, namely, can 'this' disappear before the zoom_level_prefs
+ // have finished initializing, causing a stale pointer via the callback?
+ zoom_level_prefs->AddPrefInitObserver(
+ base::Bind(&PrefsTabHelper::UpdateAfterZoomLevelPrefsInitialized,
+ base::Unretained(this)));
+ }
+ }
+
PrefService* prefs = GetProfile()->GetPrefs();
pref_change_registrar_.Init(prefs);
if (prefs) {
base::Closure renderer_callback = base::Bind(
&PrefsTabHelper::UpdateRendererPreferences, base::Unretained(this));
pref_change_registrar_.Add(prefs::kAcceptLanguages, renderer_callback);
- pref_change_registrar_.Add(prefs::kDefaultZoomLevel, renderer_callback);
pref_change_registrar_.Add(prefs::kEnableDoNotTrack, renderer_callback);
pref_change_registrar_.Add(prefs::kEnableReferrers, renderer_callback);
@@ -566,6 +594,11 @@ void PrefsTabHelper::UpdateWebPreferences() {
web_contents_->GetRenderViewHost()->GetWebkitPreferences());
}
+void PrefsTabHelper::UpdateAfterZoomLevelPrefsInitialized(bool success) {
+ if (success)
+ UpdateRendererPreferences();
+}
+
void PrefsTabHelper::UpdateRendererPreferences() {
renderer_preferences_util::UpdateFromSystemSettings(
web_contents_->GetMutableRendererPrefs(), GetProfile());

Powered by Google App Engine
This is Rietveld 408576698