| Index: components/renderer_context_menu/render_view_context_menu_base.h
|
| diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.h b/components/renderer_context_menu/render_view_context_menu_base.h
|
| similarity index 52%
|
| copy from chrome/browser/renderer_context_menu/render_view_context_menu.h
|
| copy to components/renderer_context_menu/render_view_context_menu_base.h
|
| index 5b5932eedbe389723dccce7742d091b2821454c6..9d4ac636c0fc38bc8f855d37c2f6ae7ae8604ed3 100644
|
| --- a/chrome/browser/renderer_context_menu/render_view_context_menu.h
|
| +++ b/components/renderer_context_menu/render_view_context_menu_base.h
|
| @@ -2,8 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_H_
|
| -#define CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_H_
|
| +#ifndef COMPONENTS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BASE_H_
|
| +#define COMPONENTS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BASE_H_
|
|
|
| #include <map>
|
| #include <string>
|
| @@ -11,9 +11,6 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/observer_list.h"
|
| #include "base/strings/string16.h"
|
| -#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
|
| -#include "chrome/browser/extensions/context_menu_matcher.h"
|
| -#include "chrome/browser/extensions/menu_manager.h"
|
| #include "components/renderer_context_menu/context_menu_content_type.h"
|
| #include "components/renderer_context_menu/render_view_context_menu_observer.h"
|
| #include "components/renderer_context_menu/render_view_context_menu_proxy.h"
|
| @@ -22,21 +19,11 @@
|
| #include "ui/base/models/simple_menu_model.h"
|
| #include "ui/base/window_open_disposition.h"
|
|
|
| -class PrintPreviewContextMenuObserver;
|
| -class Profile;
|
| -class SpellingMenuObserver;
|
| -class SpellCheckerSubMenuObserver;
|
| -
|
| namespace content {
|
| class RenderFrameHost;
|
| class WebContents;
|
| }
|
|
|
| -namespace extensions {
|
| -class Extension;
|
| -class MenuItem;
|
| -}
|
| -
|
| namespace gfx {
|
| class Point;
|
| }
|
| @@ -46,8 +33,8 @@ struct WebMediaPlayerAction;
|
| struct WebPluginAction;
|
| }
|
|
|
| -class RenderViewContextMenu : public ui::SimpleMenuModel::Delegate,
|
| - public RenderViewContextMenuProxy {
|
| +class RenderViewContextMenuBase : public ui::SimpleMenuModel::Delegate,
|
| + public RenderViewContextMenuProxy {
|
| public:
|
| // A delegate interface to communicate with the toolkit used by
|
| // the embedder.
|
| @@ -68,6 +55,8 @@ class RenderViewContextMenu : public ui::SimpleMenuModel::Delegate,
|
|
|
| static const size_t kMaxSelectionTextLength;
|
|
|
| + static void SetContentCustomCommandIdRange(int first, int last);
|
| +
|
| // Convert a command ID so that it fits within the range for
|
| // content context menu.
|
| static int ConvertToContentCustomCommandId(int id);
|
| @@ -75,10 +64,10 @@ class RenderViewContextMenu : public ui::SimpleMenuModel::Delegate,
|
| // True if the given id is the one generated for content context menu.
|
| static bool IsContentCustomCommandId(int id);
|
|
|
| - RenderViewContextMenu(content::RenderFrameHost* render_frame_host,
|
| - const content::ContextMenuParams& params);
|
| + RenderViewContextMenuBase(content::RenderFrameHost* render_frame_host,
|
| + const content::ContextMenuParams& params);
|
|
|
| - virtual ~RenderViewContextMenu();
|
| + virtual ~RenderViewContextMenuBase();
|
|
|
| // Initializes the context menu.
|
| void Init();
|
| @@ -114,6 +103,13 @@ class RenderViewContextMenu : public ui::SimpleMenuModel::Delegate,
|
| virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
|
|
|
| protected:
|
| + friend class RenderViewContextMenuTest;
|
| + friend class RenderViewContextMenuPrefsTest;
|
| +
|
| + void set_content_type(ContextMenuContentType* content_type) {
|
| + content_type_.reset(content_type);
|
| + }
|
| +
|
| void set_toolkit_delegate(scoped_ptr<ToolkitDelegate> delegate) {
|
| toolkit_delegate_ = delegate.Pass();
|
| }
|
| @@ -122,114 +118,49 @@ class RenderViewContextMenu : public ui::SimpleMenuModel::Delegate,
|
| return toolkit_delegate_.get();
|
| }
|
|
|
| - void InitMenu();
|
| - Profile* GetProfile();
|
| + // TODO(oshima): Make these methods delegate.
|
| +
|
| + // Menu Construction.
|
| + virtual void InitMenu();
|
|
|
| - // Platform specific functions.
|
| + // Increments histogram value for used items specified by |id|.
|
| + virtual void RecordUsedItem(int id) = 0;
|
| +
|
| + // Increments histogram value for visible context menu item specified by |id|.
|
| + virtual void RecordShownItem(int id) = 0;
|
| +
|
| +#if defined(ENABLE_PLUGINS)
|
| + virtual void HandleAuthorizeAllPlugins() = 0;
|
| +#endif
|
| +
|
| + // Returns the accelerator for given |command_id|.
|
| virtual bool GetAcceleratorForCommandId(
|
| int command_id,
|
| ui::Accelerator* accelerator) = 0;
|
| - virtual void AppendPlatformEditableItems();
|
|
|
| - content::ContextMenuParams params_;
|
| - content::WebContents* source_web_contents_;
|
| - // The RenderFrameHost's IDs.
|
| - int render_process_id_;
|
| - int render_frame_id_;
|
| - content::BrowserContext* browser_context_;
|
| + // Subclasses should send notification.
|
| + virtual void NotifyMenuShown() = 0;
|
| + virtual void NotifyURLOpened(const GURL& url,
|
| + content::WebContents* new_contents) = 0;
|
|
|
| - ui::SimpleMenuModel menu_model_;
|
| - extensions::ContextMenuMatcher extension_items_;
|
| + // TODO(oshima): Remove this.
|
| + virtual void AppendPlatformEditableItems() {}
|
|
|
| - private:
|
| - friend class RenderViewContextMenuTest;
|
| - friend class RenderViewContextMenuPrefsTest;
|
| + content::RenderFrameHost* GetRenderFrameHost();
|
|
|
| - static bool IsDevToolsURL(const GURL& url);
|
| - static bool IsInternalResourcesURL(const GURL& url);
|
| - static bool ExtensionContextAndPatternMatch(
|
| - const content::ContextMenuParams& params,
|
| - extensions::MenuItem::ContextList contexts,
|
| - const extensions::URLPatternSet& target_url_patterns);
|
| - static bool MenuItemMatchesParams(const content::ContextMenuParams& params,
|
| - const extensions::MenuItem* item);
|
| -
|
| - // Gets the extension (if any) associated with the WebContents that we're in.
|
| - const extensions::Extension* GetExtension() const;
|
| - bool AppendCustomItems();
|
| -
|
| - void AppendDeveloperItems();
|
| - void AppendDevtoolsForUnpackedExtensions();
|
| - void AppendLinkItems();
|
| - void AppendImageItems();
|
| - void AppendAudioItems();
|
| - void AppendCanvasItems();
|
| - void AppendVideoItems();
|
| - void AppendMediaItems();
|
| - void AppendPluginItems();
|
| - void AppendPageItems();
|
| - void AppendFrameItems();
|
| - void AppendCopyItem();
|
| - void AppendPrintItem();
|
| - void AppendEditableItems();
|
| - void AppendSearchProvider();
|
| - void AppendAllExtensionItems();
|
| - void AppendCurrentExtensionItems();
|
| - void AppendPrintPreviewItems();
|
| - void AppendSearchWebForImageItems();
|
| - void AppendSpellingSuggestionsSubMenu();
|
| - void AppendSpellcheckOptionsSubMenu();
|
| - void AppendProtocolHandlerSubMenu();
|
| + bool IsCustomItemChecked(int id) const;
|
| + bool IsCustomItemEnabled(int id) const;
|
|
|
| // Opens the specified URL string in a new tab.
|
| void OpenURL(const GURL& url, const GURL& referrer,
|
| WindowOpenDisposition disposition,
|
| content::PageTransition transition);
|
|
|
| - // Copy to the clipboard an image located at a point in the RenderView
|
| - void CopyImageAt(int x, int y);
|
| -
|
| - // Get an image located at a point in the RenderView for search.
|
| - void GetImageThumbnailForSearch();
|
| -
|
| - // Launch the inspector targeting a point in the RenderView
|
| - void Inspect(int x, int y);
|
| -
|
| - // Writes the specified text/url to the system clipboard
|
| - void WriteURLToClipboard(const GURL& url);
|
| -
|
| - void MediaPlayerActionAt(const gfx::Point& location,
|
| - const blink::WebMediaPlayerAction& action);
|
| - void PluginActionAt(const gfx::Point& location,
|
| - const blink::WebPluginAction& action);
|
| -
|
| - bool IsDevCommandEnabled(int id) const;
|
| -
|
| - // Returns a list of registered ProtocolHandlers that can handle the clicked
|
| - // on URL.
|
| - ProtocolHandlerRegistry::ProtocolHandlerList GetHandlersForLinkUrl();
|
| -
|
| - // Returns a (possibly truncated) version of the current selection text
|
| - // suitable or putting in the title of a menu item.
|
| - base::string16 PrintableSelectionText();
|
| -
|
| - // The destination URL to use if the user tries to search for or navigate to
|
| - // a text selection.
|
| - GURL selection_navigation_url_;
|
| -
|
| - ui::SimpleMenuModel protocol_handler_submenu_model_;
|
| - ProtocolHandlerRegistry* protocol_handler_registry_;
|
| -
|
| - // An observer that handles spelling-menu items.
|
| - scoped_ptr<SpellingMenuObserver> spelling_menu_observer_;
|
| -
|
| - // An observer that handles a 'spell-checker options' submenu.
|
| - scoped_ptr<SpellCheckerSubMenuObserver> spellchecker_submenu_observer_;
|
| + content::ContextMenuParams params_;
|
| + content::WebContents* source_web_contents_;
|
| + content::BrowserContext* browser_context_;
|
|
|
| -#if defined(ENABLE_FULL_PRINTING)
|
| - // An observer that disables menu items when print preview is active.
|
| - scoped_ptr<PrintPreviewContextMenuObserver> print_preview_menu_observer_;
|
| -#endif
|
| + ui::SimpleMenuModel menu_model_;
|
|
|
| // Our observers.
|
| mutable ObserverList<RenderViewContextMenuObserver> observers_;
|
| @@ -240,9 +171,16 @@ class RenderViewContextMenu : public ui::SimpleMenuModel::Delegate,
|
|
|
| scoped_ptr<ContextMenuContentType> content_type_;
|
|
|
| + private:
|
| + bool AppendCustomItems();
|
| +
|
| + // The RenderFrameHost's IDs.
|
| + int render_process_id_;
|
| + int render_frame_id_;
|
| +
|
| scoped_ptr<ToolkitDelegate> toolkit_delegate_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenu);
|
| + DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuBase);
|
| };
|
|
|
| -#endif // CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_H_
|
| +#endif // COMPONENTS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BASE_H_
|
|
|