summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-28 23:39:26 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-28 23:39:26 +0000
commit74d2579aac81dfb31d625fef689d3be22c229a75 (patch)
treef609a1cf0a9bc9f3527ac3d1b6789b0c19750464 /ui
parentef16c174a500a841cf6a120dc4ef9fca89fac9f9 (diff)
downloadchromium_src-74d2579aac81dfb31d625fef689d3be22c229a75.zip
chromium_src-74d2579aac81dfb31d625fef689d3be22c229a75.tar.gz
chromium_src-74d2579aac81dfb31d625fef689d3be22c229a75.tar.bz2
Fix crash in RenderViewContextMenuViews::RunMenuAt. As part of fixing
this I'm centralizing how we notify the view of menu showing/hiding. BUG=80099 80879 TEST=none R=estade@chromium.org,ben@chromium.org Review URL: http://codereview.chromium.org/6901075 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83444 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/models/simple_menu_model.cc8
-rw-r--r--ui/base/models/simple_menu_model.h42
2 files changed, 32 insertions, 18 deletions
diff --git a/ui/base/models/simple_menu_model.cc b/ui/base/models/simple_menu_model.cc
index 28c1b01..57f6ec3e 100644
--- a/ui/base/models/simple_menu_model.cc
+++ b/ui/base/models/simple_menu_model.cc
@@ -46,6 +46,9 @@ bool SimpleMenuModel::Delegate::GetIconForCommandId(
void SimpleMenuModel::Delegate::CommandIdHighlighted(int command_id) {
}
+void SimpleMenuModel::Delegate::MenuWillShow() {
+}
+
void SimpleMenuModel::Delegate::MenuClosed() {
}
@@ -291,6 +294,11 @@ MenuModel* SimpleMenuModel::GetSubmenuModelAt(int index) const {
return items_.at(FlipIndex(index)).submenu;
}
+void SimpleMenuModel::MenuWillShow() {
+ if (delegate_)
+ delegate_->MenuWillShow();
+}
+
void SimpleMenuModel::MenuClosed() {
// Due to how menus work on the different platforms, ActivatedAt will be
// called after this. It's more convenient for the delegate to be called
diff --git a/ui/base/models/simple_menu_model.h b/ui/base/models/simple_menu_model.h
index 59b752f..e8ccb40 100644
--- a/ui/base/models/simple_menu_model.h
+++ b/ui/base/models/simple_menu_model.h
@@ -49,6 +49,9 @@ class SimpleMenuModel : public MenuModel {
// Performs the action associated with the specified command id.
virtual void ExecuteCommand(int command_id) = 0;
+ // Notifies the delegate that the menu is about to show.
+ virtual void MenuWillShow();
+
// Notifies the delegate that the menu has closed.
virtual void MenuClosed();
@@ -102,25 +105,28 @@ class SimpleMenuModel : public MenuModel {
int GetIndexOfCommandId(int command_id);
// Overridden from MenuModel:
- virtual bool HasIcons() const;
- virtual int GetItemCount() const;
- virtual ItemType GetTypeAt(int index) const;
- virtual int GetCommandIdAt(int index) const;
- virtual string16 GetLabelAt(int index) const;
- virtual bool IsItemDynamicAt(int index) const;
+ virtual bool HasIcons() const OVERRIDE;
+ virtual int GetItemCount() const OVERRIDE;
+ virtual ItemType GetTypeAt(int index) const OVERRIDE;
+ virtual int GetCommandIdAt(int index) const OVERRIDE;
+ virtual string16 GetLabelAt(int index) const OVERRIDE;
+ virtual bool IsItemDynamicAt(int index) const OVERRIDE;
virtual bool GetAcceleratorAt(int index,
- ui::Accelerator* accelerator) const;
- virtual bool IsItemCheckedAt(int index) const;
- virtual int GetGroupIdAt(int index) const;
- virtual bool GetIconAt(int index, SkBitmap* icon);
- virtual ui::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;
- virtual void MenuClosed();
- virtual void SetMenuModelDelegate(ui::MenuModelDelegate* menu_model_delegate);
+ ui::Accelerator* accelerator) const OVERRIDE;
+ virtual bool IsItemCheckedAt(int index) const OVERRIDE;
+ virtual int GetGroupIdAt(int index) const OVERRIDE;
+ virtual bool GetIconAt(int index, SkBitmap* icon) OVERRIDE;
+ virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt(
+ int index) const OVERRIDE;
+ virtual bool IsEnabledAt(int index) const OVERRIDE;
+ virtual bool IsVisibleAt(int index) const OVERRIDE;
+ virtual void HighlightChangedTo(int index) OVERRIDE;
+ virtual void ActivatedAt(int index) OVERRIDE;
+ virtual MenuModel* GetSubmenuModelAt(int index) const OVERRIDE;
+ virtual void MenuWillShow() OVERRIDE;
+ virtual void MenuClosed() OVERRIDE;
+ virtual void SetMenuModelDelegate(
+ ui::MenuModelDelegate* menu_model_delegate) OVERRIDE;
protected:
// Some variants of this model (SystemMenuModel) relies on items to be