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

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

Issue 12039058: content: convert zoom notifications to observer usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/ui/zoom/zoom_controller.cc
diff --git a/chrome/browser/ui/zoom/zoom_controller.cc b/chrome/browser/ui/zoom/zoom_controller.cc
index 24b33baad649d27d4287532503a79d6d1ad08c83..5b5430637731c8c43043acf6fe2432cee7031d10 100644
--- a/chrome/browser/ui/zoom/zoom_controller.cc
+++ b/chrome/browser/ui/zoom/zoom_controller.cc
@@ -22,7 +22,9 @@
DEFINE_WEB_CONTENTS_USER_DATA_KEY(ZoomController);
ZoomController::ZoomController(content::WebContents* web_contents)
- : content::WebContentsObserver(web_contents),
+ : content::HostZoomMap::Observer(content::HostZoomMap::GetForBrowserContext(
+ web_contents->GetBrowserContext())),
+ content::WebContentsObserver(web_contents),
zoom_percent_(100),
observer_(NULL) {
Profile* profile =
@@ -32,11 +34,6 @@ ZoomController::ZoomController(content::WebContents* web_contents)
base::Unretained(this),
std::string()));
- content::HostZoomMap* zoom_map =
- content::HostZoomMap::GetForBrowserContext(profile);
- registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
- content::Source<content::HostZoomMap>(zoom_map));
-
UpdateState(std::string());
}
@@ -59,6 +56,10 @@ int ZoomController::GetResourceForZoomLevel() const {
return zoom > default_zoom_level_.GetValue() ? IDR_ZOOM_PLUS : IDR_ZOOM_MINUS;
}
+void ZoomController::OnZoomLevelChanged(const std::string& host) {
+ UpdateState(host);
+}
+
void ZoomController::DidNavigateMainFrame(
const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) {
@@ -67,13 +68,6 @@ void ZoomController::DidNavigateMainFrame(
UpdateState(std::string());
}
-void ZoomController::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(content::NOTIFICATION_ZOOM_LEVEL_CHANGED, type);
- UpdateState(*content::Details<std::string>(details).ptr());
-}
-
void ZoomController::UpdateState(const std::string& host) {
// TODO(dbeam): I'm not totally sure why this is happening, and there's been a
// bit of effort to understand with no tangible results yet. It's possible

Powered by Google App Engine
This is Rietveld 408576698