| 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.
|
|
|