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

Side by Side Diff: chrome/browser/wrench_menu_model.h

Issue 3163035: Revert "Clean up the WrenchMenuModel so that it uses SimpleMenu::Delegate." (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/views/toolbar_view.cc ('k') | chrome/browser/wrench_menu_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_WRENCH_MENU_MODEL_H_ 5 #ifndef CHROME_BROWSER_WRENCH_MENU_MODEL_H_
6 #define CHROME_BROWSER_WRENCH_MENU_MODEL_H_ 6 #define CHROME_BROWSER_WRENCH_MENU_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include "app/menus/accelerator.h"
10 #include "app/menus/button_menu_item_model.h" 9 #include "app/menus/button_menu_item_model.h"
11 #include "app/menus/simple_menu_model.h" 10 #include "app/menus/simple_menu_model.h"
12 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
13 #include "chrome/browser/tabs/tab_strip_model.h" 12 #include "chrome/browser/tabs/tab_strip_model.h"
14 #include "chrome/common/notification_observer.h" 13 #include "chrome/common/notification_observer.h"
15 #include "chrome/common/notification_registrar.h" 14 #include "chrome/common/notification_registrar.h"
16 15
17 class Browser; 16 class Browser;
18 17
19 namespace { 18 namespace {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 60
62 private: 61 private:
63 void Build(Browser* browser); 62 void Build(Browser* browser);
64 63
65 scoped_ptr<EncodingMenuModel> encoding_menu_model_; 64 scoped_ptr<EncodingMenuModel> encoding_menu_model_;
66 65
67 DISALLOW_COPY_AND_ASSIGN(ToolsMenuModel); 66 DISALLOW_COPY_AND_ASSIGN(ToolsMenuModel);
68 }; 67 };
69 68
70 // A menu model that builds the contents of the wrench menu. 69 // A menu model that builds the contents of the wrench menu.
71 class WrenchMenuModel : public menus::SimpleMenuModel::Delegate, 70 class WrenchMenuModel : public menus::SimpleMenuModel,
72 public menus::ButtonMenuItemModel::Delegate, 71 public menus::ButtonMenuItemModel::Delegate,
73 public TabStripModelObserver, 72 public TabStripModelObserver,
74 public NotificationObserver { 73 public NotificationObserver {
75 public: 74 public:
76 WrenchMenuModel(menus::AcceleratorProvider* provider, Browser* browser); 75 WrenchMenuModel(menus::SimpleMenuModel::Delegate* delegate,
76 Browser* browser);
77 virtual ~WrenchMenuModel(); 77 virtual ~WrenchMenuModel();
78 78
79 // Overridden for both ButtonMenuItemModel::Delegate and SimpleMenuModel: 79 // Overridden from menus::SimpleMenuModel:
80 virtual bool IsLabelDynamicAt(int index) const;
81 virtual string16 GetLabelAt(int index) const;
82 virtual bool HasIcons() const { return true; }
83 virtual bool GetIconAt(int index, SkBitmap* icon) const;
84
85 // Overridden from menus::ButtonMenuItemModel::Delegate:
80 virtual bool IsLabelForCommandIdDynamic(int command_id) const; 86 virtual bool IsLabelForCommandIdDynamic(int command_id) const;
81 virtual string16 GetLabelForCommandId(int command_id) const; 87 virtual string16 GetLabelForCommandId(int command_id) const;
82 virtual void ExecuteCommand(int command_id); 88 virtual void ExecuteCommand(int command_id);
83 virtual bool IsCommandIdChecked(int command_id) const;
84 virtual bool IsCommandIdEnabled(int command_id) const; 89 virtual bool IsCommandIdEnabled(int command_id) const;
85 virtual bool GetAcceleratorForCommandId(
86 int command_id,
87 menus::Accelerator* accelerator);
88 90
89 // Overridden from TabStripModelObserver: 91 // Overridden from TabStripModelObserver:
90 virtual void TabSelectedAt(TabContents* old_contents, 92 virtual void TabSelectedAt(TabContents* old_contents,
91 TabContents* new_contents, 93 TabContents* new_contents,
92 int index, 94 int index,
93 bool user_gesture); 95 bool user_gesture);
94 virtual void TabReplacedAt(TabContents* old_contents, 96 virtual void TabReplacedAt(TabContents* old_contents,
95 TabContents* new_contents, int index); 97 TabContents* new_contents, int index);
96 virtual void TabStripModelDeleted(); 98 virtual void TabStripModelDeleted();
97 99
98 // Overridden from NotificationObserver: 100 // Overridden from NotificationObserver:
99 virtual void Observe(NotificationType type, 101 virtual void Observe(NotificationType type,
100 const NotificationSource& source, 102 const NotificationSource& source,
101 const NotificationDetails& details); 103 const NotificationDetails& details);
102 104
103 // Getters. 105 // Getters.
104 Browser* browser() const { return browser_; } 106 Browser* browser() const { return browser_; }
105 menus::SimpleMenuModel* menu_model() { return &model_; }
106 107
107 // Calculates |zoom_label_| in response to a zoom change. 108 // Calculates |zoom_label_| in response to a zoom change.
108 void UpdateZoomControls(); 109 void UpdateZoomControls();
109 110
110 private: 111 private:
111 // Testing constructor used for mocking. 112 // Testing constructor used for mocking.
112 friend class ::MockWrenchMenuModel; 113 friend class ::MockWrenchMenuModel;
113 WrenchMenuModel(); 114 WrenchMenuModel() : menus::SimpleMenuModel(NULL) {}
114 115
115 void Build(); 116 void Build();
116 117
117 // Adds custom items to the menu. Deprecated in favor of a cross platform 118 // Adds custom items to the menu. Deprecated in favor of a cross platform
118 // model for button items. 119 // model for button items.
119 void CreateCutCopyPaste(); 120 void CreateCutCopyPaste();
120 void CreateZoomFullscreen(); 121 void CreateZoomFullscreen();
121 122
122 // Gets the current zoom information from the renderer. 123 // Gets the current zoom information from the renderer.
123 double GetZoom(bool* enable_increment, bool* enable_decrement); 124 double GetZoom(bool* enable_increment, bool* enable_decrement);
124 125
125 string16 GetSyncMenuLabel() const; 126 string16 GetSyncMenuLabel() const;
126 string16 GetAboutEntryMenuLabel() const; 127 string16 GetAboutEntryMenuLabel() const;
127 128 bool IsDynamicItem(int index) const;
128 // Our menu, for which we are the delegate.
129 menus::SimpleMenuModel model_;
130 129
131 // Models for the special menu items with buttons. 130 // Models for the special menu items with buttons.
132 scoped_ptr<menus::ButtonMenuItemModel> edit_menu_item_model_; 131 scoped_ptr<menus::ButtonMenuItemModel> edit_menu_item_model_;
133 scoped_ptr<menus::ButtonMenuItemModel> zoom_menu_item_model_; 132 scoped_ptr<menus::ButtonMenuItemModel> zoom_menu_item_model_;
134 133
135 // Label of the zoom label in the zoom menu item. 134 // Label of the zoom label in the zoom menu item.
136 string16 zoom_label_; 135 string16 zoom_label_;
137 136
138 // Tools menu. 137 // Tools menu.
139 scoped_ptr<ToolsMenuModel> tools_menu_model_; 138 scoped_ptr<ToolsMenuModel> tools_menu_model_;
140 139
141 menus::AcceleratorProvider* provider_; 140 menus::SimpleMenuModel::Delegate* delegate_; // weak
142 141
143 Browser* browser_; // weak 142 Browser* browser_; // weak
144 TabStripModel* tabstrip_model_; // weak 143 TabStripModel* tabstrip_model_; // weak
145 144
146 NotificationRegistrar registrar_; 145 NotificationRegistrar registrar_;
147 146
148 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel); 147 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel);
149 }; 148 };
150 149
151 #endif // CHROME_BROWSER_WRENCH_MENU_MODEL_H_ 150 #endif // CHROME_BROWSER_WRENCH_MENU_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/views/toolbar_view.cc ('k') | chrome/browser/wrench_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698