| 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 "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| 11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 12 #include "ui/base/models/simple_menu_model.h" | 12 #include "ui/base/models/simple_menu_model.h" |
| 13 | 13 |
| 14 class Browser; | 14 class Profile; |
| 15 | 15 |
| 16 // A menu model that builds the contents of the action box menu. Effectively, | 16 // A menu model that builds the contents of the action box menu. Effectively, |
| 17 // a ui::SimpleMenuModel with methods specifically for dealing with extension | 17 // a ui::SimpleMenuModel with methods specifically for dealing with extension |
| 18 // content. | 18 // content. |
| 19 // | 19 // |
| 20 // This model should be built on demand since its content reflects the state of | 20 // This model should be built on demand since its content reflects the state of |
| 21 // the browser at creation time. | 21 // the browser at creation time. |
| 22 class ActionBoxMenuModel : public ui::SimpleMenuModel { | 22 class ActionBoxMenuModel : public ui::SimpleMenuModel { |
| 23 public: | 23 public: |
| 24 ActionBoxMenuModel(Browser* browser, ui::SimpleMenuModel::Delegate* delegate); | 24 ActionBoxMenuModel(Profile* profile, ui::SimpleMenuModel::Delegate* delegate); |
| 25 virtual ~ActionBoxMenuModel(); | 25 virtual ~ActionBoxMenuModel(); |
| 26 | 26 |
| 27 // Adds an extension to the model with a given command ID. | 27 // Adds an extension to the model with a given command ID. |
| 28 void AddExtension(const extensions::Extension& extension, int command_id); | 28 void AddExtension(const extensions::Extension& extension, int command_id); |
| 29 | 29 |
| 30 // Returns true if item associated with an extension. | 30 // Returns true if item associated with an extension. |
| 31 bool IsItemExtension(int index); | 31 bool IsItemExtension(int index); |
| 32 | 32 |
| 33 // Returns an extension associated with model item at |index| | 33 // Returns an extension associated with model item at |index| |
| 34 // or NULL if it is not an extension item. | 34 // or NULL if it is not an extension item. |
| 35 const extensions::Extension* GetExtensionAt(int index); | 35 const extensions::Extension* GetExtensionAt(int index); |
| 36 | 36 |
| 37 // Calls ExecuteCommand on the delegate. | 37 // Calls ExecuteCommand on the delegate. |
| 38 void ExecuteCommand(int command_id); | 38 void ExecuteCommand(int command_id); |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 friend class ActionBoxMenuModelTest; | 41 friend class ActionBoxMenuModelTest; |
| 42 // Gets the index of the first extension. This may be equal to the number of | 42 // Gets the index of the first extension. This may be equal to the number of |
| 43 // total items in the model if there are no extensions installed. | 43 // total items in the model if there are no extensions installed. |
| 44 int GetFirstExtensionIndex(); | 44 int GetFirstExtensionIndex(); |
| 45 | 45 |
| 46 Browser* browser_; | 46 Profile* profile_; |
| 47 | 47 |
| 48 // The list of extensions added to the menu, in order, if any. | 48 // The list of extensions added to the menu, in order, if any. |
| 49 extensions::ExtensionIdList extension_ids_; | 49 extensions::ExtensionIdList extension_ids_; |
| 50 | 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenuModel); | 51 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenuModel); |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 #endif // CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_MENU_MODEL_H_ | 54 #endif // CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_MENU_MODEL_H_ |
| OLD | NEW |