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

Unified Diff: chrome/browser/ui/zoom/chrome_zoom_level_otr_delegate.cc

Issue 2630583002: Add setting to isolate zoom changes by default. (Closed)
Patch Set: ... and tell closure_compiler. Created 3 years, 10 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/zoom/chrome_zoom_level_otr_delegate.cc
diff --git a/chrome/browser/ui/zoom/chrome_zoom_level_otr_delegate.cc b/chrome/browser/ui/zoom/chrome_zoom_level_otr_delegate.cc
index 5092f549385ea777a8539c81655e69ca9ad97bf5..65accc23abfd23f34831b25459f18c0bb08c8cf8 100644
--- a/chrome/browser/ui/zoom/chrome_zoom_level_otr_delegate.cc
+++ b/chrome/browser/ui/zoom/chrome_zoom_level_otr_delegate.cc
@@ -5,15 +5,57 @@
#include "chrome/browser/ui/zoom/chrome_zoom_level_otr_delegate.h"
#include "base/bind.h"
+#include "chrome/common/pref_names.h"
#include "components/zoom/zoom_event_manager.h"
ChromeZoomLevelOTRDelegate::ChromeZoomLevelOTRDelegate(
+ PrefService* pref_service,
+ const base::FilePath& profile_path,
+ const base::FilePath& partition_path,
base::WeakPtr<zoom::ZoomEventManager> zoom_event_manager)
- : zoom_event_manager_(zoom_event_manager), host_zoom_map_(nullptr) {}
+ : partitioned_prefs_(pref_service, profile_path, partition_path),
+ zoom_event_manager_(zoom_event_manager),
+ host_zoom_map_(nullptr) {
+ // Observe changes to the zoom scope preference in case it is changed in the
+ // parent profile.
+ last_scope_was_per_origin_ = GetZoomScopeIsPerOriginPref();
+ pref_registrar_.Init(pref_service);
+ pref_registrar_.Add(
+ prefs::kPartitionZoomScopeIsPerOrigin,
+ base::Bind(&ChromeZoomLevelOTRDelegate::OnParentScopeChanged,
+ base::Unretained(this)));
+}
ChromeZoomLevelOTRDelegate::~ChromeZoomLevelOTRDelegate() {
}
+bool ChromeZoomLevelOTRDelegate::GetZoomScopeIsPerOriginPref() const {
+ bool is_per_origin = kZoomScopeSettingDefault;
+
+ // If no value has been previously set, |is_per_origin| will be untouched
+ // from the default value we've set above.
+ partitioned_prefs_.GetBoolean(prefs::kPartitionZoomScopeIsPerOrigin,
+ &is_per_origin);
+ return is_per_origin;
+}
+
+std::unique_ptr<ChromeZoomLevelOTRDelegate::DefaultZoomScopeSubscription>
+ChromeZoomLevelOTRDelegate::RegisterDefaultZoomScopeCallback(
+ const base::Closure& callback) {
+ return default_scope_changed_callbacks_.Add(callback);
+}
+
+void ChromeZoomLevelOTRDelegate::OnParentScopeChanged() {
+ bool new_scope_is_per_origin = GetZoomScopeIsPerOriginPref();
+ // Make sure that we're not being notified for a scope change in another
+ // partition.
+ if (new_scope_is_per_origin == last_scope_was_per_origin_)
+ return;
+
+ last_scope_was_per_origin_ = new_scope_is_per_origin;
+ default_scope_changed_callbacks_.Notify();
+}
+
void ChromeZoomLevelOTRDelegate::InitHostZoomMap(
content::HostZoomMap* host_zoom_map) {
// This init function must be called only once.
« no previous file with comments | « chrome/browser/ui/zoom/chrome_zoom_level_otr_delegate.h ('k') | chrome/browser/ui/zoom/chrome_zoom_level_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698