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

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 "chrome/common/extensions/extension.h"
10 #include "content/public/browser/notification_observer.h" 11 #include "content/public/browser/notification_observer.h"
11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/ui/browser_commands.h"
13 #include "ui/base/models/simple_menu_model.h" 12 #include "ui/base/models/simple_menu_model.h"
14 13
15 class Browser; 14 class Browser;
16 15
17 namespace extensions {
18 class Extension;
19 }
20
21 // A menu model that builds the contents of the action box menu. This model 16 // 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 17 // should be built on demand since its content reflects the state of the browser
23 // at creation time. 18 // at creation time.
24 class ActionBoxMenuModel : public ui::SimpleMenuModel, 19 class ActionBoxMenuModel : public ui::SimpleMenuModel,
25 public ui::SimpleMenuModel::Delegate, 20 public ui::SimpleMenuModel::Delegate,
26 public content::NotificationObserver { 21 public content::NotificationObserver {
27 public: 22 public:
28 ActionBoxMenuModel(Browser* browser, 23 explicit ActionBoxMenuModel(Browser* browser);
29 ExtensionService* extension_service);
30 virtual ~ActionBoxMenuModel(); 24 virtual ~ActionBoxMenuModel();
31 25
32 // Returns true if item associated with an extension. 26 // Returns true if item associated with an extension.
33 bool IsItemExtension(int index); 27 bool IsItemExtension(int index);
34 28
35 // Returns an extension associated with model item at |index| 29 // Returns an extension associated with model item at |index|
36 // or NULL if it is not an extension item. 30 // or NULL if it is not an extension item.
37 const extensions::Extension* GetExtensionAt(int index); 31 const extensions::Extension* GetExtensionAt(int index);
38 32
39 // Overridden from ui::SimpleMenuModel::Delegate: 33 // Overridden from ui::SimpleMenuModel::Delegate:
40 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; 34 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
41 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; 35 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
42 virtual bool GetAcceleratorForCommandId( 36 virtual bool GetAcceleratorForCommandId(
43 int command_id, 37 int command_id,
44 ui::Accelerator* accelerator) OVERRIDE; 38 ui::Accelerator* accelerator) OVERRIDE;
45 virtual void ExecuteCommand(int command_id) OVERRIDE; 39 virtual void ExecuteCommand(int command_id) OVERRIDE;
46 40
47 private: 41 private:
48 const extensions::ExtensionList& action_box_menu_items() { 42 const extensions::ExtensionList& GetActionBoxMenuItems();
49 return extension_service_->toolbar_model()->action_box_menu_items();
50 }
51 43
52 typedef std::map<int, std::string> IdToEntensionIdMap; 44 typedef std::map<int, std::string> IdToEntensionIdMap;
53 45
54 // Overridden from content::NotificationObserver: 46 // Overridden from content::NotificationObserver:
55 virtual void Observe(int type, 47 virtual void Observe(int type,
56 const content::NotificationSource& source, 48 const content::NotificationSource& source,
57 const content::NotificationDetails& details) OVERRIDE; 49 const content::NotificationDetails& details) OVERRIDE;
58 50
59 Browser* browser_; 51 Browser* browser_;
60 ExtensionService* extension_service_;
61 52
62 IdToEntensionIdMap id_to_extension_id_map_; 53 IdToEntensionIdMap id_to_extension_id_map_;
63 54
64 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenuModel); 55 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenuModel);
65 }; 56 };
66 57
67 #endif // CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_MENU_MODEL_H_ 58 #endif // CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_MENU_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698