diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-22 22:36:20 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-22 22:36:20 +0000 |
commit | 7e9f4a8e17e918412cfba8337e55873abed112cb (patch) | |
tree | 49363f7f49844e68f858677aa5bef4e081b2e0df /chrome/browser/extensions/extension_context_menu_model.h | |
parent | 8c157cf900b7ae30185b4905ac51c39dfc2c90ad (diff) | |
download | chromium_src-7e9f4a8e17e918412cfba8337e55873abed112cb.zip chromium_src-7e9f4a8e17e918412cfba8337e55873abed112cb.tar.gz chromium_src-7e9f4a8e17e918412cfba8337e55873abed112cb.tar.bz2 |
Refactor ExtensionActionContextMenuModel.
- Simplify constructor
- Rename to ExtensionContextMenuModel.*
- Remove views/extension_action_context_menu.*
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/1107007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42271 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_context_menu_model.h')
-rw-r--r-- | chrome/browser/extensions/extension_context_menu_model.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_context_menu_model.h b/chrome/browser/extensions/extension_context_menu_model.h new file mode 100644 index 0000000..21667ef --- /dev/null +++ b/chrome/browser/extensions/extension_context_menu_model.h @@ -0,0 +1,70 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ + +#include "app/menus/simple_menu_model.h" +#include "chrome/browser/extensions/extension_install_ui.h" + +class Browser; +class Extension; +class ExtensionAction; +class Profile; + +// The menu model for the context menu for extension action icons (browser and +// page actions). +class ExtensionContextMenuModel + : public menus::SimpleMenuModel, + public menus::SimpleMenuModel::Delegate, + public ExtensionInstallUI::Delegate { + public: + // Delegate to handle showing an ExtensionAction popup. + class PopupDelegate { + public: + // Called when the user selects the menu item which requests that the + // popup be shown and inspected. + virtual void InspectPopup(ExtensionAction* action) = 0; + }; + + // Creates a menu model for the given extension action. If + // prefs::kExtensionsUIDeveloperMode is enabled then a menu item + // will be shown for "Inspect Popup" which, when selected, will cause + // ShowPopupForDevToolsWindow() to be called on |delegate|. + ExtensionContextMenuModel(Extension* extension, + Browser* browser, + PopupDelegate* delegate); + virtual ~ExtensionContextMenuModel(); + + // SimpleMenuModel::Delegate overrides. + virtual bool IsCommandIdChecked(int command_id) const; + virtual bool IsCommandIdEnabled(int command_id) const; + virtual bool GetAcceleratorForCommandId(int command_id, + menus::Accelerator* accelerator); + virtual void ExecuteCommand(int command_id); + + // ExtensionInstallUI::Delegate overrides. + virtual void InstallUIProceed(bool create_app); + virtual void InstallUIAbort() {} + + private: + void InitCommonCommands(); + + // The extension we are displaying the menu for. + Extension* extension_; + + // The extension action we are displaying the menu for (or NULL). + ExtensionAction* extension_action_; + + Browser* browser_; + + Profile* profile_; + + // The delegate which handles the 'inspect popup' menu command (or NULL). + PopupDelegate* delegate_; + + DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); +}; + +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ |