| 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_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/string16.h" | 16 #include "base/string16.h" |
| 17 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 17 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 18 #include "chrome/browser/extensions/extension_menu_manager.h" | 18 #include "chrome/browser/extensions/menu_manager.h" |
| 19 #include "chrome/browser/tab_contents/render_view_context_menu_observer.h" | 19 #include "chrome/browser/tab_contents/render_view_context_menu_observer.h" |
| 20 #include "content/public/common/context_menu_params.h" | 20 #include "content/public/common/context_menu_params.h" |
| 21 #include "content/public/common/page_transition_types.h" | 21 #include "content/public/common/page_transition_types.h" |
| 22 #include "ui/base/models/simple_menu_model.h" | 22 #include "ui/base/models/simple_menu_model.h" |
| 23 #include "webkit/glue/window_open_disposition.h" | 23 #include "webkit/glue/window_open_disposition.h" |
| 24 | 24 |
| 25 class ExtensionMenuItem; | |
| 26 class PrintPreviewContextMenuObserver; | 25 class PrintPreviewContextMenuObserver; |
| 27 class Profile; | 26 class Profile; |
| 28 class SpellingMenuObserver; | 27 class SpellingMenuObserver; |
| 29 class SpellCheckerSubMenuObserver; | 28 class SpellCheckerSubMenuObserver; |
| 30 | 29 |
| 31 namespace content { | 30 namespace content { |
| 32 class RenderViewHost; | 31 class RenderViewHost; |
| 33 class WebContents; | 32 class WebContents; |
| 34 } | 33 } |
| 35 | 34 |
| 36 namespace extensions { | 35 namespace extensions { |
| 37 class Extension; | 36 class Extension; |
| 37 class MenuItem; |
| 38 } | 38 } |
| 39 | 39 |
| 40 namespace gfx { | 40 namespace gfx { |
| 41 class Point; | 41 class Point; |
| 42 } | 42 } |
| 43 | 43 |
| 44 namespace WebKit { | 44 namespace WebKit { |
| 45 struct WebMediaPlayerAction; | 45 struct WebMediaPlayerAction; |
| 46 struct WebPluginAction; | 46 struct WebPluginAction; |
| 47 } | 47 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 protected: | 171 protected: |
| 172 void InitMenu(); | 172 void InitMenu(); |
| 173 | 173 |
| 174 // Platform specific functions. | 174 // Platform specific functions. |
| 175 virtual void PlatformInit() = 0; | 175 virtual void PlatformInit() = 0; |
| 176 virtual void PlatformCancel() = 0; | 176 virtual void PlatformCancel() = 0; |
| 177 virtual bool GetAcceleratorForCommandId( | 177 virtual bool GetAcceleratorForCommandId( |
| 178 int command_id, | 178 int command_id, |
| 179 ui::Accelerator* accelerator) = 0; | 179 ui::Accelerator* accelerator) = 0; |
| 180 | 180 |
| 181 // Attempts to get an ExtensionMenuItem given the id of a context menu item. | 181 // Attempts to get an MenuItem given the id of a context menu item. |
| 182 ExtensionMenuItem* GetExtensionMenuItem(int id) const; | 182 extensions::MenuItem* GetExtensionMenuItem(int id) const; |
| 183 | 183 |
| 184 content::ContextMenuParams params_; | 184 content::ContextMenuParams params_; |
| 185 content::WebContents* source_web_contents_; | 185 content::WebContents* source_web_contents_; |
| 186 Profile* profile_; | 186 Profile* profile_; |
| 187 | 187 |
| 188 ui::SimpleMenuModel menu_model_; | 188 ui::SimpleMenuModel menu_model_; |
| 189 | 189 |
| 190 // True if we are showing for an external tab contents. The default is false. | 190 // True if we are showing for an external tab contents. The default is false. |
| 191 bool external_; | 191 bool external_; |
| 192 | 192 |
| 193 // Maps the id from a context menu item to the ExtensionMenuItem's internal | 193 // Maps the id from a context menu item to the MenuItem's internal id. |
| 194 // id. | 194 std::map<int, extensions::MenuItem::Id> extension_item_map_; |
| 195 std::map<int, ExtensionMenuItem::Id> extension_item_map_; | |
| 196 | 195 |
| 197 private: | 196 private: |
| 198 friend class RenderViewContextMenuTest; | 197 friend class RenderViewContextMenuTest; |
| 199 | 198 |
| 200 static bool IsDevToolsURL(const GURL& url); | 199 static bool IsDevToolsURL(const GURL& url); |
| 201 static bool IsInternalResourcesURL(const GURL& url); | 200 static bool IsInternalResourcesURL(const GURL& url); |
| 202 static bool ExtensionContextAndPatternMatch( | 201 static bool ExtensionContextAndPatternMatch( |
| 203 const content::ContextMenuParams& params, | 202 const content::ContextMenuParams& params, |
| 204 ExtensionMenuItem::ContextList contexts, | 203 extensions::MenuItem::ContextList contexts, |
| 205 const URLPatternSet& target_url_patterns); | 204 const URLPatternSet& target_url_patterns); |
| 206 static ExtensionMenuItem::List GetRelevantExtensionItems( | 205 static extensions::MenuItem::List GetRelevantExtensionItems( |
| 207 const ExtensionMenuItem::List& items, | 206 const extensions::MenuItem::List& items, |
| 208 const content::ContextMenuParams& params, | 207 const content::ContextMenuParams& params, |
| 209 Profile* profile, | 208 Profile* profile, |
| 210 bool can_cross_incognito); | 209 bool can_cross_incognito); |
| 211 | 210 |
| 212 // Gets the extension (if any) associated with the WebContents that we're in. | 211 // Gets the extension (if any) associated with the WebContents that we're in. |
| 213 const extensions::Extension* GetExtension() const; | 212 const extensions::Extension* GetExtension() const; |
| 214 void AppendPlatformAppItems(); | 213 void AppendPlatformAppItems(); |
| 215 void AppendPopupExtensionItems(); | 214 void AppendPopupExtensionItems(); |
| 216 bool AppendCustomItems(); | 215 bool AppendCustomItems(); |
| 217 void AppendDeveloperItems(); | 216 void AppendDeveloperItems(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 234 void AppendBidiSubMenu(); | 233 void AppendBidiSubMenu(); |
| 235 void AppendProtocolHandlerSubMenu(); | 234 void AppendProtocolHandlerSubMenu(); |
| 236 | 235 |
| 237 // This is a helper function to append items for one particular extension. | 236 // This is a helper function to append items for one particular extension. |
| 238 // The |index| parameter is used for assigning id's, and is incremented for | 237 // The |index| parameter is used for assigning id's, and is incremented for |
| 239 // each item actually added. | 238 // each item actually added. |
| 240 void AppendExtensionItems(const std::string& extension_id, int* index); | 239 void AppendExtensionItems(const std::string& extension_id, int* index); |
| 241 | 240 |
| 242 // Used for recursively adding submenus of extension items. | 241 // Used for recursively adding submenus of extension items. |
| 243 void RecursivelyAppendExtensionItems( | 242 void RecursivelyAppendExtensionItems( |
| 244 const std::vector<ExtensionMenuItem*>& items, | 243 const std::vector<extensions::MenuItem*>& items, |
| 245 bool can_cross_incognito, | 244 bool can_cross_incognito, |
| 246 ui::SimpleMenuModel* menu_model, | 245 ui::SimpleMenuModel* menu_model, |
| 247 int* index); | 246 int* index); |
| 248 // This will set the icon on the most recently-added item in the menu_model_. | 247 // This will set the icon on the most recently-added item in the menu_model_. |
| 249 void SetExtensionIcon(const std::string& extension_id); | 248 void SetExtensionIcon(const std::string& extension_id); |
| 250 | 249 |
| 251 // Opens the specified URL string in a new tab. The |frame_id| specifies the | 250 // Opens the specified URL string in a new tab. The |frame_id| specifies the |
| 252 // frame in which the context menu was displayed, or 0 if the menu action is | 251 // frame in which the context menu was displayed, or 0 if the menu action is |
| 253 // independent of that frame (e.g. protocol handler settings). | 252 // independent of that frame (e.g. protocol handler settings). |
| 254 void OpenURL(const GURL& url, const GURL& referrer, int64 frame_id, | 253 void OpenURL(const GURL& url, const GURL& referrer, int64 frame_id, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 // An observer that disables menu items when print preview is active. | 297 // An observer that disables menu items when print preview is active. |
| 299 scoped_ptr<PrintPreviewContextMenuObserver> print_preview_menu_observer_; | 298 scoped_ptr<PrintPreviewContextMenuObserver> print_preview_menu_observer_; |
| 300 | 299 |
| 301 // Our observers. | 300 // Our observers. |
| 302 mutable ObserverList<RenderViewContextMenuObserver> observers_; | 301 mutable ObserverList<RenderViewContextMenuObserver> observers_; |
| 303 | 302 |
| 304 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenu); | 303 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenu); |
| 305 }; | 304 }; |
| 306 | 305 |
| 307 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_ | 306 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_ |
| OLD | NEW |