| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_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/page_transition_types.h" | 20 #include "content/public/common/page_transition_types.h" |
| 21 #include "ui/base/models/simple_menu_model.h" | 21 #include "ui/base/models/simple_menu_model.h" |
| 22 #include "webkit/glue/context_menu.h" | 22 #include "webkit/glue/context_menu.h" |
| 23 #include "webkit/glue/window_open_disposition.h" | 23 #include "webkit/glue/window_open_disposition.h" |
| 24 | 24 |
| 25 class ExtensionMenuItem; | 25 class ExtensionMenuItem; |
| 26 class Profile; | 26 class Profile; |
| 27 class RenderViewHost; | 27 class RenderViewHost; |
| 28 class TabContents; | 28 class TabContents; |
| 29 class SpellingMenuObserver; | 29 class SpellingMenuObserver; |
| 30 class SpellCheckerSubMenuObserver; |
| 30 | 31 |
| 31 namespace gfx { | 32 namespace gfx { |
| 32 class Point; | 33 class Point; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace WebKit { | 36 namespace WebKit { |
| 36 struct WebMediaPlayerAction; | 37 struct WebMediaPlayerAction; |
| 37 } | 38 } |
| 38 | 39 |
| 39 // An interface that controls a RenderViewContextMenu instance from observers. | 40 // An interface that controls a RenderViewContextMenu instance from observers. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // // Start a task that creates the final text. | 85 // // Start a task that creates the final text. |
| 85 // my_task_ = new MyTask(this, IDC_MY_ITEM); | 86 // my_task_ = new MyTask(this, IDC_MY_ITEM); |
| 86 // my_task_->Start(...); | 87 // my_task_->Start(...); |
| 87 // } | 88 // } |
| 88 // | 89 // |
| 89 class RenderViewContextMenuProxy { | 90 class RenderViewContextMenuProxy { |
| 90 public: | 91 public: |
| 91 // Add a menu item to a context menu. | 92 // Add a menu item to a context menu. |
| 92 virtual void AddMenuItem(int command_id, const string16& title) = 0; | 93 virtual void AddMenuItem(int command_id, const string16& title) = 0; |
| 93 | 94 |
| 95 // Add a submenu item to a context menu. |
| 96 virtual void AddSubMenu(int command_id, |
| 97 const string16& label, |
| 98 ui::MenuModel* model) = 0; |
| 99 |
| 94 // Update the status and text of the specified context-menu item. | 100 // Update the status and text of the specified context-menu item. |
| 95 virtual void UpdateMenuItem(int command_id, | 101 virtual void UpdateMenuItem(int command_id, |
| 96 bool enabled, | 102 bool enabled, |
| 97 bool hidden, | 103 bool hidden, |
| 98 const string16& title) = 0; | 104 const string16& title) = 0; |
| 99 | 105 |
| 100 // Retrieve the RenderViewHost (or Profile) instance associated with a context | 106 // Retrieve the RenderViewHost (or Profile) instance associated with a context |
| 101 // menu, respectively. | 107 // menu, respectively. |
| 102 virtual RenderViewHost* GetRenderViewHost() const = 0; | 108 virtual RenderViewHost* GetRenderViewHost() const = 0; |
| 103 virtual Profile* GetProfile() const = 0; | 109 virtual Profile* GetProfile() const = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 123 // SimpleMenuModel::Delegate implementation. | 129 // SimpleMenuModel::Delegate implementation. |
| 124 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 130 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 125 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 131 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 126 virtual void ExecuteCommand(int command_id) OVERRIDE; | 132 virtual void ExecuteCommand(int command_id) OVERRIDE; |
| 127 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 133 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| 128 virtual void MenuWillShow(ui::SimpleMenuModel* source) OVERRIDE; | 134 virtual void MenuWillShow(ui::SimpleMenuModel* source) OVERRIDE; |
| 129 virtual void MenuClosed(ui::SimpleMenuModel* source) OVERRIDE; | 135 virtual void MenuClosed(ui::SimpleMenuModel* source) OVERRIDE; |
| 130 | 136 |
| 131 // RenderViewContextMenuDelegate implementation. | 137 // RenderViewContextMenuDelegate implementation. |
| 132 virtual void AddMenuItem(int command_id, const string16& title) OVERRIDE; | 138 virtual void AddMenuItem(int command_id, const string16& title) OVERRIDE; |
| 139 virtual void AddSubMenu(int command_id, |
| 140 const string16& label, |
| 141 ui::MenuModel* model) OVERRIDE; |
| 133 virtual void UpdateMenuItem(int command_id, | 142 virtual void UpdateMenuItem(int command_id, |
| 134 bool enabled, | 143 bool enabled, |
| 135 bool hidden, | 144 bool hidden, |
| 136 const string16& title) OVERRIDE; | 145 const string16& title) OVERRIDE; |
| 137 virtual RenderViewHost* GetRenderViewHost() const; | 146 virtual RenderViewHost* GetRenderViewHost() const OVERRIDE; |
| 138 virtual Profile* GetProfile() const; | 147 virtual Profile* GetProfile() const OVERRIDE; |
| 139 | 148 |
| 140 protected: | 149 protected: |
| 141 void InitMenu(); | 150 void InitMenu(); |
| 142 | 151 |
| 143 // Platform specific functions. | 152 // Platform specific functions. |
| 144 virtual void PlatformInit() = 0; | 153 virtual void PlatformInit() = 0; |
| 145 virtual bool GetAcceleratorForCommandId( | 154 virtual bool GetAcceleratorForCommandId( |
| 146 int command_id, | 155 int command_id, |
| 147 ui::Accelerator* accelerator) = 0; | 156 ui::Accelerator* accelerator) = 0; |
| 148 virtual void LookUpInDictionary(); | 157 virtual void LookUpInDictionary(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 ProtocolHandlerRegistry::ProtocolHandlerList GetHandlersForLinkUrl(); | 247 ProtocolHandlerRegistry::ProtocolHandlerList GetHandlersForLinkUrl(); |
| 239 | 248 |
| 240 // Returns a (possibly truncated) version of the current selection text | 249 // Returns a (possibly truncated) version of the current selection text |
| 241 // suitable or putting in the title of a menu item. | 250 // suitable or putting in the title of a menu item. |
| 242 string16 PrintableSelectionText(); | 251 string16 PrintableSelectionText(); |
| 243 | 252 |
| 244 // The destination URL to use if the user tries to search for or navigate to | 253 // The destination URL to use if the user tries to search for or navigate to |
| 245 // a text selection. | 254 // a text selection. |
| 246 GURL selection_navigation_url_; | 255 GURL selection_navigation_url_; |
| 247 | 256 |
| 248 ui::SimpleMenuModel spellcheck_submenu_model_; | |
| 249 ui::SimpleMenuModel speech_input_submenu_model_; | 257 ui::SimpleMenuModel speech_input_submenu_model_; |
| 250 ui::SimpleMenuModel bidi_submenu_model_; | 258 ui::SimpleMenuModel bidi_submenu_model_; |
| 251 ui::SimpleMenuModel protocol_handler_submenu_model_; | 259 ui::SimpleMenuModel protocol_handler_submenu_model_; |
| 252 ScopedVector<ui::SimpleMenuModel> extension_menu_models_; | 260 ScopedVector<ui::SimpleMenuModel> extension_menu_models_; |
| 253 scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_; | 261 scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_; |
| 254 | 262 |
| 255 // An observer that handles a spelling-menu items. | 263 // An observer that handles spelling-menu items. |
| 256 scoped_ptr<SpellingMenuObserver> spelling_menu_observer_; | 264 scoped_ptr<SpellingMenuObserver> spelling_menu_observer_; |
| 257 | 265 |
| 266 // An observer that handles a 'spell-checker options' submenu. |
| 267 scoped_ptr<SpellCheckerSubMenuObserver> spellchecker_submenu_observer_; |
| 268 |
| 258 // Our observers. | 269 // Our observers. |
| 259 mutable ObserverList<RenderViewContextMenuObserver> observers_; | 270 mutable ObserverList<RenderViewContextMenuObserver> observers_; |
| 260 | 271 |
| 261 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenu); | 272 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenu); |
| 262 }; | 273 }; |
| 263 | 274 |
| 264 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_ | 275 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_ |
| OLD | NEW |