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

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

Issue 12039058: content: convert zoom notifications to observer usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: callbacks Created 7 years, 11 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/off_the_record_profile_impl.cc
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc
index 489c2aec63836e5c08735aabc07ae084d1f52ff8..7b7aa37bc302b28968c94c5f7319710f21e9e76e 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -45,8 +45,6 @@
#include "chrome/common/render_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/host_zoom_map.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
@@ -129,6 +127,10 @@ void OffTheRecordProfileImpl::Init() {
OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
MaybeSendDestroyedNotification();
+ HostZoomMap::GetForBrowserContext(profile_)->RemoveZoomLevelChangedCallback(
+ base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged,
+ base::Unretained(this)));
+
#if defined(ENABLE_PLUGINS)
ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext(
io_data_.GetResourceContextNoInit());
@@ -165,8 +167,9 @@ void OffTheRecordProfileImpl::InitHostZoomMap() {
host_zoom_map->CopyFrom(parent_host_zoom_map);
// Observe parent's HZM change for propagating change of parent's
// change to this HZM.
- registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
- content::Source<HostZoomMap>(parent_host_zoom_map));
+ parent_host_zoom_map->AddZoomLevelChangedCallback(
+ base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged,
+ base::Unretained(this)));
}
#if defined(OS_ANDROID)
@@ -428,21 +431,15 @@ GURL OffTheRecordProfileImpl::GetHomePage() {
return profile_->GetHomePage();
}
-void OffTheRecordProfileImpl::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- if (type == content::NOTIFICATION_ZOOM_LEVEL_CHANGED) {
- const std::string& host =
- *(content::Details<const std::string>(details).ptr());
- if (!host.empty()) {
- HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
- HostZoomMap* parent_host_zoom_map =
- HostZoomMap::GetForBrowserContext(profile_);
- double level = parent_host_zoom_map->GetZoomLevel(host);
- host_zoom_map->SetZoomLevel(host, level);
- }
- }
+void OffTheRecordProfileImpl::OnZoomLevelChanged(const std::string& host) {
+ if (host.empty())
+ return;
+
+ HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
+ HostZoomMap* parent_host_zoom_map =
+ HostZoomMap::GetForBrowserContext(profile_);
+ double level = parent_host_zoom_map->GetZoomLevel(host);
+ host_zoom_map->SetZoomLevel(host, level);
}
#if defined(OS_CHROMEOS)

Powered by Google App Engine
This is Rietveld 408576698