summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-27 19:46:04 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-27 19:46:04 +0000
commit108011938035924b2ff64fd76abb9bd967f67c0f (patch)
tree2927816fbecdacd971ea18ce28c83c0132730271
parent60742f122a4dabbcd946dfd7c1dc214366075df7 (diff)
downloadchromium_src-108011938035924b2ff64fd76abb9bd967f67c0f.zip
chromium_src-108011938035924b2ff64fd76abb9bd967f67c0f.tar.gz
chromium_src-108011938035924b2ff64fd76abb9bd967f67c0f.tar.bz2
Exposed an IsEnabledAt for ButtonMenuItemModel (this is not used yet, will be used in a subsequent checkin). The Mac wrench menu zoom controls honor the global enabled state of the zoom commands.
BUG=None. TEST=Open a PDF using the internal PDF viewer on the Mac. The Zoom controls on the Wrench menu should be disabled. Review URL: http://codereview.chromium.org/3026025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53824 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/menus/button_menu_item_model.cc6
-rw-r--r--app/menus/button_menu_item_model.h4
-rw-r--r--chrome/browser/cocoa/wrench_menu_controller.mm6
-rw-r--r--chrome/browser/wrench_menu_model.cc6
-rw-r--r--chrome/browser/wrench_menu_model.h1
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,