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

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

Issue 23851016: Convert zoom callbacks to use CallbackRegistry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge Created 7 years, 3 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 d62924654ecc55e3689ad1673d7006f1832d77fa..d82ec3d7ec5bc8b42e086ed0ded11f3882b95477 100644
--- a/chrome/browser/ui/views/wrench_menu.cc
+++ b/chrome/browser/ui/views/wrench_menu.cc
@@ -528,15 +528,15 @@ 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_);
+ zoom_subscription_ = HostZoomMap::GetForBrowserContext(
+ menu->browser_->profile())->AddZoomLevelChangedCallback(
+ base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged,
+ base::Unretained(this)));
decrement_button_ = CreateButtonWithAccName(
IDS_ZOOM_MINUS2, MenuButtonBackground::LEFT_BUTTON, decrement_index,
@@ -614,9 +614,7 @@ class WrenchMenu::ZoomView : public WrenchMenuView {
UpdateZoomControls();
}
- virtual ~ZoomView() {
- Shutdown();
- }
+ virtual ~ZoomView() {}
// Overridden from View.
virtual gfx::Size GetPreferredSize() OVERRIDE {
@@ -672,21 +670,10 @@ class WrenchMenu::ZoomView : public WrenchMenuView {
// Overridden from WrenchMenuObserver.
virtual void WrenchMenuDestroyed() OVERRIDE {
- Shutdown();
WrenchMenuView::WrenchMenuDestroyed();
}
private:
- // Invoked from the destructor or when the WrenchMenu is destroyed.
- void Shutdown() {
- if (!menu())
- return;
-
- HostZoomMap::GetForBrowserContext(
- menu()->browser_->profile())->RemoveZoomLevelChangedCallback(
- zoom_callback_);
- }
-
void OnZoomLevelChanged(const HostZoomMap::ZoomLevelChange& change) {
UpdateZoomControls();
}
@@ -738,7 +725,7 @@ class WrenchMenu::ZoomView : public WrenchMenuView {
// Index of the fullscreen menu item in the model.
const int fullscreen_index_;
- content::HostZoomMap::ZoomLevelChangedCallback zoom_callback_;
+ scoped_ptr<content::HostZoomMap::Subscription> zoom_subscription_;
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