Commit 10801193 authored by sanjeevr@chromium.org's avatar sanjeevr@chromium.org

Exposed an IsEnabledAt for ButtonMenuItemModel (this is not used yet, will be...

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
parent 60742f12
......@@ -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
......@@ -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:
......
......@@ -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] :
......
......@@ -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;
}
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment