diff options
-rw-r--r-- | app/menus/button_menu_item_model.cc | 6 | ||||
-rw-r--r-- | app/menus/button_menu_item_model.h | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/wrench_menu_controller.mm | 6 | ||||
-rw-r--r-- | chrome/browser/wrench_menu_model.cc | 6 | ||||
-rw-r--r-- | chrome/browser/wrench_menu_model.h | 1 |
5 files changed, 23 insertions, 0 deletions
diff --git a/app/menus/button_menu_item_model.cc b/app/menus/button_menu_item_model.cc index c1c7f7a..94949e4 100644 --- a/app/menus/button_menu_item_model.cc +++ b/app/menus/button_menu_item_model.cc @@ -102,4 +102,10 @@ void ButtonMenuItemModel::ActivatedCommand(int command_id) { delegate_->ExecuteCommand(command_id); } +bool ButtonMenuItemModel::IsEnabledAt(int index) const { + if (delegate_) + return delegate_->IsCommandIdEnabled(items_[index].command_id); + return true; +} + } // namespace menus diff --git a/app/menus/button_menu_item_model.h b/app/menus/button_menu_item_model.h index 29a8b7c..8e3300e 100644 --- a/app/menus/button_menu_item_model.h +++ b/app/menus/button_menu_item_model.h @@ -31,6 +31,7 @@ class ButtonMenuItemModel { // Performs the action associated with the specified command id. virtual void ExecuteCommand(int command_id) = 0; + virtual bool IsCommandIdEnabled(int command_id) const { return true; } }; ButtonMenuItemModel(int string_id, ButtonMenuItemModel::Delegate* delegate); @@ -77,6 +78,9 @@ class ButtonMenuItemModel { // Called from implementations. void ActivatedCommand(int command_id); + // Returns the enabled state of the button at |index|. + bool IsEnabledAt(int index) const; + const string16& label() const { return item_label_; } private: diff --git a/chrome/browser/cocoa/wrench_menu_controller.mm b/chrome/browser/cocoa/wrench_menu_controller.mm index ce17447..4f4c894 100644 --- a/chrome/browser/cocoa/wrench_menu_controller.mm +++ b/chrome/browser/cocoa/wrench_menu_controller.mm @@ -74,6 +74,12 @@ NSString* title = base::SysUTF16ToNSString( [self wrenchMenuModel]->GetLabelForCommandId(IDC_ZOOM_PERCENT_DISPLAY)); [[zoomItem_ viewWithTag:IDC_ZOOM_PERCENT_DISPLAY] setTitle:title]; + bool plusEnabled = [self wrenchMenuModel]->IsCommandIdEnabled(IDC_ZOOM_PLUS); + bool minusEnabled = [self wrenchMenuModel]->IsCommandIdEnabled( + IDC_ZOOM_MINUS); + + [zoomPlus_ setEnabled:plusEnabled]; + [zoomMinus_ setEnabled:minusEnabled]; NSImage* icon = [self wrenchMenuModel]->browser()->window()->IsFullscreen() ? [NSImage imageNamed:NSImageNameExitFullScreenTemplate] : diff --git a/chrome/browser/wrench_menu_model.cc b/chrome/browser/wrench_menu_model.cc index c48b973..27d8e09 100644 --- a/chrome/browser/wrench_menu_model.cc +++ b/chrome/browser/wrench_menu_model.cc @@ -396,3 +396,9 @@ bool WrenchMenuModel::IsDynamicItem(int index) const { return command_id == IDC_SYNC_BOOKMARKS || command_id == IDC_ABOUT; } + +bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { + if (delegate_) + return delegate_->IsCommandIdEnabled(command_id); + return true; +} diff --git a/chrome/browser/wrench_menu_model.h b/chrome/browser/wrench_menu_model.h index 7507507..f8eece1 100644 --- a/chrome/browser/wrench_menu_model.h +++ b/chrome/browser/wrench_menu_model.h @@ -94,6 +94,7 @@ class WrenchMenuModel : public menus::SimpleMenuModel, virtual bool IsLabelForCommandIdDynamic(int command_id) const; virtual string16 GetLabelForCommandId(int command_id) const; virtual void ExecuteCommand(int command_id); + virtual bool IsCommandIdEnabled(int command_id) const; // Overridden from TabStripModelObserver: virtual void TabSelectedAt(TabContents* old_contents, |