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

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

Powered by Google App Engine
This is Rietveld 408576698