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_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 11 #include "chrome/browser/extensions/extension_uninstall_dialog.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 Browser; |
15 class Extension; | |
16 class ExtensionAction; | 15 class ExtensionAction; |
17 class Profile; | 16 class Profile; |
18 | 17 |
| 18 namespace extensions { |
| 19 class Extension; |
| 20 } |
| 21 |
19 // The menu model for the context menu for extension action icons (browser and | 22 // The menu model for the context menu for extension action icons (browser and |
20 // page actions). | 23 // page actions). |
21 class ExtensionContextMenuModel | 24 class ExtensionContextMenuModel |
22 : public base::RefCounted<ExtensionContextMenuModel>, | 25 : public base::RefCounted<ExtensionContextMenuModel>, |
23 public ui::SimpleMenuModel, | 26 public ui::SimpleMenuModel, |
24 public ui::SimpleMenuModel::Delegate, | 27 public ui::SimpleMenuModel::Delegate, |
25 public ExtensionUninstallDialog::Delegate { | 28 public ExtensionUninstallDialog::Delegate { |
26 public: | 29 public: |
27 // Creates a menu model for the given extension action. | 30 // Creates a menu model for the given extension action. |
28 ExtensionContextMenuModel(const Extension* extension, Browser* browser); | 31 ExtensionContextMenuModel(const extensions::Extension* extension, |
| 32 Browser* browser); |
29 | 33 |
30 // SimpleMenuModel::Delegate overrides. | 34 // SimpleMenuModel::Delegate overrides. |
31 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 35 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
32 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 36 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
33 virtual bool GetAcceleratorForCommandId( | 37 virtual bool GetAcceleratorForCommandId( |
34 int command_id, | 38 int command_id, |
35 ui::Accelerator* accelerator) OVERRIDE; | 39 ui::Accelerator* accelerator) OVERRIDE; |
36 virtual void ExecuteCommand(int command_id) OVERRIDE; | 40 virtual void ExecuteCommand(int command_id) OVERRIDE; |
37 | 41 |
38 // ExtensionUninstallDialog::Delegate: | 42 // ExtensionUninstallDialog::Delegate: |
39 virtual void ExtensionUninstallAccepted() OVERRIDE; | 43 virtual void ExtensionUninstallAccepted() OVERRIDE; |
40 virtual void ExtensionUninstallCanceled() OVERRIDE; | 44 virtual void ExtensionUninstallCanceled() OVERRIDE; |
41 | 45 |
42 private: | 46 private: |
43 friend class base::RefCounted<ExtensionContextMenuModel>; | 47 friend class base::RefCounted<ExtensionContextMenuModel>; |
44 virtual ~ExtensionContextMenuModel(); | 48 virtual ~ExtensionContextMenuModel(); |
45 | 49 |
46 void InitCommonCommands(); | 50 void InitCommonCommands(); |
47 | 51 |
48 // Gets the extension we are displaying the menu for. Returns NULL if the | 52 // Gets the extension we are displaying the menu for. Returns NULL if the |
49 // extension has been uninstalled and no longer exists. | 53 // extension has been uninstalled and no longer exists. |
50 const Extension* GetExtension() const; | 54 const extensions::Extension* GetExtension() const; |
51 | 55 |
52 // A copy of the extension's id. | 56 // A copy of the extension's id. |
53 std::string extension_id_; | 57 std::string extension_id_; |
54 | 58 |
55 // The extension action we are displaying the menu for (or NULL). | 59 // The extension action we are displaying the menu for (or NULL). |
56 ExtensionAction* extension_action_; | 60 ExtensionAction* extension_action_; |
57 | 61 |
58 Browser* browser_; | 62 Browser* browser_; |
59 | 63 |
60 Profile* profile_; | 64 Profile* profile_; |
61 | 65 |
62 // Keeps track of the extension uninstall dialog. | 66 // Keeps track of the extension uninstall dialog. |
63 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; | 67 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; |
64 | 68 |
65 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); | 69 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); |
66 }; | 70 }; |
67 | 71 |
68 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ | 72 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ |
OLD | NEW |