diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 19:22:41 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 19:22:41 +0000 |
commit | b21d691e4e486071ac8601fee7867c29729faca6 (patch) | |
tree | 7829cdf53b53a938bcedc4c0565dea3fbb406684 /app/menus | |
parent | 61c13e8d5361469479e5c0bf61d0c25a5402ef15 (diff) | |
download | chromium_src-b21d691e4e486071ac8601fee7867c29729faca6.zip chromium_src-b21d691e4e486071ac8601fee7867c29729faca6.tar.gz chromium_src-b21d691e4e486071ac8601fee7867c29729faca6.tar.bz2 |
The "Update Chrome" menu item should appear in addition to the About menu.
It should not replace it. This patch modifications to the GTK and Cocoa ports to make the update chrome item appear when an update is available. On win/chromeos, the menu item is always there but disabled, since I'm having some problems figuring out the views custom menu implementation.
BUG=46221
TEST=The upgrade item should now appear under instead of replacing the about command.
Review URL: http://codereview.chromium.org/3143046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/menus')
-rw-r--r-- | app/menus/menu_model.cc | 4 | ||||
-rw-r--r-- | app/menus/menu_model.h | 3 | ||||
-rw-r--r-- | app/menus/simple_menu_model.cc | 16 | ||||
-rw-r--r-- | app/menus/simple_menu_model.h | 4 |
4 files changed, 26 insertions, 1 deletions
diff --git a/app/menus/menu_model.cc b/app/menus/menu_model.cc index 63acbf6..cbce228 100644 --- a/app/menus/menu_model.cc +++ b/app/menus/menu_model.cc @@ -6,6 +6,10 @@ namespace menus { +bool MenuModel::IsVisibleAt(int index) const { + return true; +} + bool MenuModel::GetModelAndIndexForCommandId(int command_id, MenuModel** model, int* index) { int item_count = (*model)->GetItemCount(); diff --git a/app/menus/menu_model.h b/app/menus/menu_model.h index c91efc9..1cb356a 100644 --- a/app/menus/menu_model.h +++ b/app/menus/menu_model.h @@ -94,6 +94,9 @@ class MenuModel { // Returns the enabled state of the item at the specified index. virtual bool IsEnabledAt(int index) const = 0; + // Returns true if the menu item is visible. + virtual bool IsVisibleAt(int index) const; + // Returns the model for the submenu at the specified index. virtual MenuModel* GetSubmenuModelAt(int index) const = 0; diff --git a/app/menus/simple_menu_model.cc b/app/menus/simple_menu_model.cc index 6a40f75..b645b09 100644 --- a/app/menus/simple_menu_model.cc +++ b/app/menus/simple_menu_model.cc @@ -24,6 +24,10 @@ struct SimpleMenuModel::Item { //////////////////////////////////////////////////////////////////////////////// // SimpleMenuModel::Delegate, public: +bool SimpleMenuModel::Delegate::IsCommandIdVisible(int command_id) const { + return true; +} + bool SimpleMenuModel::Delegate::IsLabelForCommandIdDynamic( int command_id) const { return false; @@ -250,6 +254,14 @@ bool SimpleMenuModel::IsEnabledAt(int index) const { return delegate_->IsCommandIdEnabled(command_id); } +bool SimpleMenuModel::IsVisibleAt(int index) const { + int command_id = GetCommandIdAt(index); + if (!delegate_ || command_id == kSeparatorId || + items_.at(FlipIndex(index)).button_model) + return true; + return delegate_->IsCommandIdVisible(command_id); +} + void SimpleMenuModel::HighlightChangedTo(int index) { if (delegate_) delegate_->CommandIdHighlighted(GetCommandIdAt(index)); @@ -264,6 +276,10 @@ MenuModel* SimpleMenuModel::GetSubmenuModelAt(int index) const { return items_.at(FlipIndex(index)).submenu; } +int SimpleMenuModel::FlipIndex(int index) const { + return index; +} + //////////////////////////////////////////////////////////////////////////////// // SimpleMenuModel, Private: diff --git a/app/menus/simple_menu_model.h b/app/menus/simple_menu_model.h index c196225..149791c 100644 --- a/app/menus/simple_menu_model.h +++ b/app/menus/simple_menu_model.h @@ -26,6 +26,7 @@ class SimpleMenuModel : public MenuModel { // Methods for determining the state of specific command ids. virtual bool IsCommandIdChecked(int command_id) const = 0; virtual bool IsCommandIdEnabled(int command_id) const = 0; + virtual bool IsCommandIdVisible(int command_id) const; // Gets the accelerator for the specified command id. Returns true if the // command id has a valid accelerator, false otherwise. @@ -107,6 +108,7 @@ class SimpleMenuModel : public MenuModel { virtual bool GetIconAt(int index, SkBitmap* icon) const; virtual menus::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const; virtual bool IsEnabledAt(int index) const; + virtual bool IsVisibleAt(int index) const; virtual void HighlightChangedTo(int index); virtual void ActivatedAt(int index); virtual MenuModel* GetSubmenuModelAt(int index) const; @@ -117,7 +119,7 @@ class SimpleMenuModel : public MenuModel { // forcing customers to insert things backwards, we return the indices // backwards instead. That's what this method is for. By default, it just // returns what it's passed. - virtual int FlipIndex(int index) const { return index; } + virtual int FlipIndex(int index) const; Delegate* delegate() { return delegate_; } |