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

Unified Diff: chrome/browser/ui/views/wrench_menu.cc

Issue 12039058: content: convert zoom notifications to observer usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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
« no previous file with comments | « chrome/browser/ui/toolbar/wrench_menu_model.cc ('k') | chrome/browser/ui/zoom/zoom_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/wrench_menu.cc
diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc
index c7b65dfcdcdc1eacbb9143c2bea04dd72f52bfed..2b2ad2a61f5f39e45f9fadd0e390f682c0320066 100644
--- a/chrome/browser/ui/views/wrench_menu.cc
+++ b/chrome/browser/ui/views/wrench_menu.cc
@@ -480,8 +480,7 @@ static const int kTouchZoomPadding = 14;
// ZoomView contains the various zoom controls: two buttons to increase/decrease
// the zoom, a label showing the current zoom percent, and a button to go
// full-screen.
-class WrenchMenu::ZoomView : public WrenchMenuView,
- public content::NotificationObserver {
+class WrenchMenu::ZoomView : public WrenchMenuView {
public:
ZoomView(WrenchMenu* menu,
MenuModel* menu_model,
@@ -490,11 +489,17 @@ class WrenchMenu::ZoomView : public WrenchMenuView,
int fullscreen_index)
: WrenchMenuView(menu, menu_model),
fullscreen_index_(fullscreen_index),
+ zoom_callback_(base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged,
+ base::Unretained(this))),
increment_button_(NULL),
zoom_label_(NULL),
decrement_button_(NULL),
fullscreen_button_(NULL),
zoom_label_width_(0) {
+ HostZoomMap::GetForBrowserContext(
+ menu_->browser_->profile())->AddZoomLevelChangedCallback(
+ zoom_callback_);
+
decrement_button_ = CreateButtonWithAccName(
IDS_ZOOM_MINUS2, MenuButtonBackground::LEFT_BUTTON, decrement_index,
NULL, IDS_ACCNAME_ZOOM_MINUS2);
@@ -555,11 +560,12 @@ class WrenchMenu::ZoomView : public WrenchMenuView,
AddChildView(fullscreen_button_);
UpdateZoomControls();
+ }
- registrar_.Add(
- this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
- content::Source<HostZoomMap>(
- HostZoomMap::GetForBrowserContext(menu->browser_->profile())));
+ ~ZoomView() {
+ HostZoomMap::GetForBrowserContext(
+ menu_->browser_->profile())->RemoveZoomLevelChangedCallback(
+ zoom_callback_);
}
// Overridden from View.
@@ -613,15 +619,11 @@ class WrenchMenu::ZoomView : public WrenchMenuView,
}
}
- // Overridden from content::NotificationObserver.
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE {
- DCHECK_EQ(content::NOTIFICATION_ZOOM_LEVEL_CHANGED, type);
+ private:
+ void OnZoomLevelChanged(const std::string& host) {
UpdateZoomControls();
}
- private:
void UpdateZoomControls() {
bool enable_increment = false;
bool enable_decrement = false;
@@ -669,6 +671,7 @@ class WrenchMenu::ZoomView : public WrenchMenuView,
// Index of the fullscreen menu item in the model.
const int fullscreen_index_;
+ content::HostZoomMap::ZoomLevelChangedCallback zoom_callback_;
content::NotificationRegistrar registrar_;
// Button for incrementing the zoom.
« no previous file with comments | « chrome/browser/ui/toolbar/wrench_menu_model.cc ('k') | chrome/browser/ui/zoom/zoom_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698