Chromium Code Reviews| Index: chrome/browser/ui/views/toolbar/wrench_menu.cc |
| diff --git a/chrome/browser/ui/views/toolbar/wrench_menu.cc b/chrome/browser/ui/views/toolbar/wrench_menu.cc |
| index b38dd1012736f58747466f026f1ada45cbdbe62e..a41fe1467dd775eef71c7276eb6025dfe4ac3abf 100644 |
| --- a/chrome/browser/ui/views/toolbar/wrench_menu.cc |
| +++ b/chrome/browser/ui/views/toolbar/wrench_menu.cc |
| @@ -22,6 +22,8 @@ |
| #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h" |
| #include "chrome/browser/ui/views/toolbar/wrench_menu_observer.h" |
| +#include "chrome/browser/ui/zoom/zoom_controller.h" |
| +#include "chrome/browser/ui/zoom/zoom_event_manager.h" |
| #include "components/bookmarks/browser/bookmark_model.h" |
| #include "content/public/browser/host_zoom_map.h" |
| #include "content/public/browser/notification_observer.h" |
| @@ -632,7 +634,12 @@ class WrenchMenu::ZoomView : public WrenchMenuView { |
| decrement_button_(NULL), |
| fullscreen_button_(NULL), |
| zoom_label_width_(0) { |
| - zoom_subscription_ = HostZoomMap::GetForBrowserContext( |
| + content_zoom_subscription_ = HostZoomMap::GetForBrowserContext( |
| + menu->browser_->profile())->AddZoomLevelChangedCallback( |
| + base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged, |
| + base::Unretained(this))); |
| + |
| + browser_zoom_subscription_ = ZoomEventManager::GetForBrowserContext( |
| menu->browser_->profile())->AddZoomLevelChangedCallback( |
| base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged, |
| base::Unretained(this))); |
| @@ -785,15 +792,14 @@ class WrenchMenu::ZoomView : public WrenchMenuView { |
| } |
| void UpdateZoomControls() { |
| - bool enable_increment = false; |
| - bool enable_decrement = false; |
| WebContents* selected_tab = |
| menu()->browser_->tab_strip_model()->GetActiveWebContents(); |
| int zoom = 100; |
| - if (selected_tab) |
| - zoom = selected_tab->GetZoomPercent(&enable_increment, &enable_decrement); |
| - increment_button_->SetEnabled(enable_increment); |
| - decrement_button_->SetEnabled(enable_decrement); |
| + if (selected_tab) { |
|
Devlin
2014/06/19 21:15:29
nit: no brackets around 1-line if statements
wjmaclean
2014/06/20 22:01:33
Done.
|
| + zoom = ZoomController::FromWebContents(selected_tab)->GetZoomPercent(); |
| + } |
| + increment_button_->SetEnabled(zoom < selected_tab->GetMaximumZoomPercent()); |
| + decrement_button_->SetEnabled(zoom > selected_tab->GetMinimumZoomPercent()); |
| zoom_label_->SetText( |
| l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom)); |
| @@ -831,7 +837,8 @@ class WrenchMenu::ZoomView : public WrenchMenuView { |
| // Index of the fullscreen menu item in the model. |
| const int fullscreen_index_; |
| - scoped_ptr<content::HostZoomMap::Subscription> zoom_subscription_; |
| + scoped_ptr<content::HostZoomMap::Subscription> content_zoom_subscription_; |
| + scoped_ptr<content::HostZoomMap::Subscription> browser_zoom_subscription_; |
| content::NotificationRegistrar registrar_; |
| // Button for incrementing the zoom. |