Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1093)

Unified Diff: chrome/browser/wrench_menu_model.h

Issue 3163023: Clean up the WrenchMenuModel so that it uses SimpleMenu::Delegate. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Fix stray rb Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/wrench_menu_model.h
diff --git a/chrome/browser/wrench_menu_model.h b/chrome/browser/wrench_menu_model.h
index 3bf6c248f526d29531c8b30cb2f2e47542f0368e..ba45a03041bba95fed76bd95bd5fe96d87dc54bd 100644
--- a/chrome/browser/wrench_menu_model.h
+++ b/chrome/browser/wrench_menu_model.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_WRENCH_MENU_MODEL_H_
#pragma once
+#include "app/menus/accelerator.h"
#include "app/menus/button_menu_item_model.h"
#include "app/menus/simple_menu_model.h"
#include "base/scoped_ptr.h"
@@ -67,26 +68,23 @@ class ToolsMenuModel : public menus::SimpleMenuModel {
};
// A menu model that builds the contents of the wrench menu.
-class WrenchMenuModel : public menus::SimpleMenuModel,
+class WrenchMenuModel : public menus::SimpleMenuModel::Delegate,
public menus::ButtonMenuItemModel::Delegate,
public TabStripModelObserver,
public NotificationObserver {
public:
- WrenchMenuModel(menus::SimpleMenuModel::Delegate* delegate,
- Browser* browser);
+ WrenchMenuModel(menus::AcceleratorProvider* provider, Browser* browser);
virtual ~WrenchMenuModel();
- // Overridden from menus::SimpleMenuModel:
- virtual bool IsLabelDynamicAt(int index) const;
- virtual string16 GetLabelAt(int index) const;
- virtual bool HasIcons() const { return true; }
- virtual bool GetIconAt(int index, SkBitmap* icon) const;
-
- // Overridden from menus::ButtonMenuItemModel::Delegate:
+ // Overridden for both ButtonMenuItemModel::Delegate and SimpleMenuModel:
virtual bool IsLabelForCommandIdDynamic(int command_id) const;
virtual string16 GetLabelForCommandId(int command_id) const;
virtual void ExecuteCommand(int command_id);
+ virtual bool IsCommandIdChecked(int command_id) const;
virtual bool IsCommandIdEnabled(int command_id) const;
+ virtual bool GetAcceleratorForCommandId(
+ int command_id,
+ menus::Accelerator* accelerator);
// Overridden from TabStripModelObserver:
virtual void TabSelectedAt(TabContents* old_contents,
@@ -104,6 +102,7 @@ class WrenchMenuModel : public menus::SimpleMenuModel,
// Getters.
Browser* browser() const { return browser_; }
+ menus::SimpleMenuModel* menu_model() { return &model_; }
// Calculates |zoom_label_| in response to a zoom change.
void UpdateZoomControls();
@@ -111,7 +110,7 @@ class WrenchMenuModel : public menus::SimpleMenuModel,
private:
// Testing constructor used for mocking.
friend class ::MockWrenchMenuModel;
- WrenchMenuModel() : menus::SimpleMenuModel(NULL) {}
+ WrenchMenuModel();
void Build();
@@ -125,7 +124,9 @@ class WrenchMenuModel : public menus::SimpleMenuModel,
string16 GetSyncMenuLabel() const;
string16 GetAboutEntryMenuLabel() const;
- bool IsDynamicItem(int index) const;
+
+ // Our menu, for which we are the delegate.
+ menus::SimpleMenuModel model_;
// Models for the special menu items with buttons.
scoped_ptr<menus::ButtonMenuItemModel> edit_menu_item_model_;
@@ -137,7 +138,7 @@ class WrenchMenuModel : public menus::SimpleMenuModel,
// Tools menu.
scoped_ptr<ToolsMenuModel> tools_menu_model_;
- menus::SimpleMenuModel::Delegate* delegate_; // weak
+ menus::AcceleratorProvider* provider_;
Browser* browser_; // weak
TabStripModel* tabstrip_model_; // weak

Powered by Google App Engine
This is Rietveld 408576698