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

Side by Side Diff: chrome/browser/ui/toolbar/action_box_menu_model.h

Issue 10887029: Only show chrome2mobile in action box if it is enabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_UI_TOOLBAR_ACTION_BOX_MENU_MODEL_H_ 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_MENU_MODEL_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_MENU_MODEL_H_ 6 #define CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_MENU_MODEL_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "content/public/browser/notification_observer.h" 10 #include "content/public/browser/notification_observer.h"
11 #include "chrome/browser/command_observer.h"
11 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/ui/browser_commands.h" 13 #include "chrome/browser/ui/browser_commands.h"
13 #include "ui/base/models/simple_menu_model.h" 14 #include "ui/base/models/simple_menu_model.h"
14 15
15 class Browser; 16 class Browser;
17 class CommandUpdater;
18 class Profile;
16 19
17 namespace extensions { 20 namespace extensions {
18 class Extension; 21 class Extension;
19 } 22 }
20 23
21 // A menu model that builds the contents of the action box menu. This model 24 // A menu model that builds the contents of the action box menu. This model
22 // should be built on demand since its content reflects the state of the browser 25 // should be built on demand since its content reflects the state of the browser
23 // at creation time. 26 // at creation time.
24 class ActionBoxMenuModel : public ui::SimpleMenuModel, 27 class ActionBoxMenuModel : public ui::SimpleMenuModel,
25 public ui::SimpleMenuModel::Delegate, 28 public ui::SimpleMenuModel::Delegate,
26 public content::NotificationObserver { 29 public content::NotificationObserver,
30 public CommandObserver {
27 public: 31 public:
28 ActionBoxMenuModel(Browser* browser, 32 ActionBoxMenuModel(Browser* browser,
29 ExtensionService* extension_service); 33 ExtensionService* extension_service,
34 CommandUpdater* command_updater);
30 virtual ~ActionBoxMenuModel(); 35 virtual ~ActionBoxMenuModel();
31 36
32 // Returns true if item associated with an extension. 37 // Returns true if item associated with an extension.
33 bool IsItemExtension(int index); 38 bool IsItemExtension(int index);
34 39
35 // Returns an extension associated with model item at |index| 40 // Returns an extension associated with model item at |index|
36 // or NULL if it is not an extension item. 41 // or NULL if it is not an extension item.
37 const extensions::Extension* GetExtensionAt(int index); 42 const extensions::Extension* GetExtensionAt(int index);
38 43
39 // Overridden from ui::SimpleMenuModel::Delegate: 44 // Overridden from ui::SimpleMenuModel::Delegate:
40 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; 45 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
41 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; 46 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
42 virtual bool GetAcceleratorForCommandId( 47 virtual bool GetAcceleratorForCommandId(
43 int command_id, 48 int command_id,
44 ui::Accelerator* accelerator) OVERRIDE; 49 ui::Accelerator* accelerator) OVERRIDE;
45 virtual void ExecuteCommand(int command_id) OVERRIDE; 50 virtual void ExecuteCommand(int command_id) OVERRIDE;
46 51
47 private: 52 private:
48 const extensions::ExtensionList& action_box_menu_items() { 53 const extensions::ExtensionList& action_box_menu_items() {
49 return extension_service_->toolbar_model()->action_box_menu_items(); 54 return extension_service_->toolbar_model()->action_box_menu_items();
50 } 55 }
51 56
52 typedef std::map<int, std::string> IdToEntensionIdMap; 57 typedef std::map<int, std::string> IdToEntensionIdMap;
53 58
54 // Overridden from content::NotificationObserver: 59 // Overridden from content::NotificationObserver:
55 virtual void Observe(int type, 60 virtual void Observe(int type,
56 const content::NotificationSource& source, 61 const content::NotificationSource& source,
57 const content::NotificationDetails& details) OVERRIDE; 62 const content::NotificationDetails& details) OVERRIDE;
58 63
64 // CommandObserver:
65 virtual void EnabledStateChangedForCommand(int id, bool enabled) OVERRIDE;
66
67 void UpdateMenu();
msw 2012/08/29 22:05:42 nit: Add a comment.
Cait (Slow) 2012/08/29 23:03:47 Done.
68
59 Browser* browser_; 69 Browser* browser_;
60 ExtensionService* extension_service_; 70 ExtensionService* extension_service_;
71 CommandUpdater* command_updater_;
61 72
62 IdToEntensionIdMap id_to_extension_id_map_; 73 IdToEntensionIdMap id_to_extension_id_map_;
63 74
64 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenuModel); 75 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenuModel);
65 }; 76 };
66 77
67 #endif // CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_MENU_MODEL_H_ 78 #endif // CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_MENU_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698