OLD | NEW |
---|---|
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/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
msw
2012/08/30 00:41:43
Remove these two extension includes with the out-o
Cait (Slow)
2012/08/30 01:33:29
Done.
| |
12 #include "chrome/browser/extensions/extension_system.h" | |
13 #include "chrome/browser/ui/browser.h" | |
msw
2012/08/30 00:41:43
The Browser forward decl will suffice with the out
Cait (Slow)
2012/08/30 01:33:29
Done.
| |
14 #include "chrome/browser/ui/browser_command_controller.h" | |
msw
2012/08/30 00:41:43
browser_command_controller.h and browser_commands.
Cait (Slow)
2012/08/30 01:33:29
browser_commands.h is needed, browser_command_cont
| |
12 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
13 #include "ui/base/models/simple_menu_model.h" | 16 #include "ui/base/models/simple_menu_model.h" |
14 | 17 |
15 class Browser; | 18 class Browser; |
19 class Profile; | |
msw
2012/08/30 00:41:43
Remove this forward decl with the out-of-line defi
Cait (Slow)
2012/08/30 01:33:29
Done.
| |
16 | 20 |
17 namespace extensions { | 21 namespace extensions { |
18 class Extension; | 22 class Extension; |
19 } | 23 } |
20 | 24 |
21 // A menu model that builds the contents of the action box menu. This model | 25 // 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 | 26 // should be built on demand since its content reflects the state of the browser |
23 // at creation time. | 27 // at creation time. |
24 class ActionBoxMenuModel : public ui::SimpleMenuModel, | 28 class ActionBoxMenuModel : public ui::SimpleMenuModel, |
25 public ui::SimpleMenuModel::Delegate, | 29 public ui::SimpleMenuModel::Delegate, |
26 public content::NotificationObserver { | 30 public content::NotificationObserver { |
27 public: | 31 public: |
28 ActionBoxMenuModel(Browser* browser, | 32 explicit ActionBoxMenuModel(Browser* browser); |
29 ExtensionService* extension_service); | |
30 virtual ~ActionBoxMenuModel(); | 33 virtual ~ActionBoxMenuModel(); |
31 | 34 |
32 // Returns true if item associated with an extension. | 35 // Returns true if item associated with an extension. |
33 bool IsItemExtension(int index); | 36 bool IsItemExtension(int index); |
34 | 37 |
35 // Returns an extension associated with model item at |index| | 38 // Returns an extension associated with model item at |index| |
36 // or NULL if it is not an extension item. | 39 // or NULL if it is not an extension item. |
37 const extensions::Extension* GetExtensionAt(int index); | 40 const extensions::Extension* GetExtensionAt(int index); |
38 | 41 |
39 // Overridden from ui::SimpleMenuModel::Delegate: | 42 // Overridden from ui::SimpleMenuModel::Delegate: |
40 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 43 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
41 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 44 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
42 virtual bool GetAcceleratorForCommandId( | 45 virtual bool GetAcceleratorForCommandId( |
43 int command_id, | 46 int command_id, |
44 ui::Accelerator* accelerator) OVERRIDE; | 47 ui::Accelerator* accelerator) OVERRIDE; |
45 virtual void ExecuteCommand(int command_id) OVERRIDE; | 48 virtual void ExecuteCommand(int command_id) OVERRIDE; |
46 | 49 |
47 private: | 50 private: |
48 const extensions::ExtensionList& action_box_menu_items() { | 51 const extensions::ExtensionList& action_box_menu_items() { |
msw
2012/08/30 00:41:43
This shouldn't be defined inline anymore (also nee
Cait (Slow)
2012/08/30 01:33:29
Done.
| |
49 return extension_service_->toolbar_model()->action_box_menu_items(); | 52 ExtensionService* extension_service = |
53 extensions::ExtensionSystem::Get(browser_->profile())-> | |
54 extension_service(); | |
55 return extension_service->toolbar_model()->action_box_menu_items(); | |
50 } | 56 } |
51 | 57 |
52 typedef std::map<int, std::string> IdToEntensionIdMap; | 58 typedef std::map<int, std::string> IdToEntensionIdMap; |
53 | 59 |
54 // Overridden from content::NotificationObserver: | 60 // Overridden from content::NotificationObserver: |
55 virtual void Observe(int type, | 61 virtual void Observe(int type, |
56 const content::NotificationSource& source, | 62 const content::NotificationSource& source, |
57 const content::NotificationDetails& details) OVERRIDE; | 63 const content::NotificationDetails& details) OVERRIDE; |
58 | 64 |
59 Browser* browser_; | 65 Browser* browser_; |
60 ExtensionService* extension_service_; | |
61 | 66 |
62 IdToEntensionIdMap id_to_extension_id_map_; | 67 IdToEntensionIdMap id_to_extension_id_map_; |
63 | 68 |
64 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenuModel); | 69 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenuModel); |
65 }; | 70 }; |
66 | 71 |
67 #endif // CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_MENU_MODEL_H_ | 72 #endif // CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_MENU_MODEL_H_ |
OLD | NEW |