OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_H_ |
6 #define CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_H_ | 6 #define CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 struct WebMediaPlayerAction; | 45 struct WebMediaPlayerAction; |
46 struct WebPluginAction; | 46 struct WebPluginAction; |
47 } | 47 } |
48 | 48 |
49 class RenderViewContextMenu : public ui::SimpleMenuModel::Delegate, | 49 class RenderViewContextMenu : public ui::SimpleMenuModel::Delegate, |
50 public RenderViewContextMenuProxy { | 50 public RenderViewContextMenuProxy { |
51 public: | 51 public: |
| 52 // A delegate interface to communicate with the toolkit used by |
| 53 // the embedder. |
| 54 class ToolkitDelegate { |
| 55 public: |
| 56 virtual ~ToolkitDelegate() {} |
| 57 // Initialize the toolkit's menu. |
| 58 virtual void Init(ui::SimpleMenuModel* menu_model) = 0; |
| 59 |
| 60 virtual void Cancel() = 0; |
| 61 |
| 62 // Updates the actual menu items controlled by the toolkit. |
| 63 virtual void UpdateMenuItem(int command_id, |
| 64 bool enabled, |
| 65 bool hidden, |
| 66 const base::string16& title) = 0; |
| 67 }; |
| 68 |
52 static const size_t kMaxSelectionTextLength; | 69 static const size_t kMaxSelectionTextLength; |
53 | 70 |
54 // Convert a command ID so that it fits within the range for | 71 // Convert a command ID so that it fits within the range for |
55 // content context menu. | 72 // content context menu. |
56 static int ConvertToContentCustomCommandId(int id); | 73 static int ConvertToContentCustomCommandId(int id); |
57 | 74 |
58 // True if the given id is the one generated for content context menu. | 75 // True if the given id is the one generated for content context menu. |
59 static bool IsContentCustomCommandId(int id); | 76 static bool IsContentCustomCommandId(int id); |
60 | 77 |
61 RenderViewContextMenu(content::RenderFrameHost* render_frame_host, | 78 RenderViewContextMenu(content::RenderFrameHost* render_frame_host, |
(...skipping 28 matching lines...) Expand all Loading... |
90 ui::MenuModel* model) OVERRIDE; | 107 ui::MenuModel* model) OVERRIDE; |
91 virtual void UpdateMenuItem(int command_id, | 108 virtual void UpdateMenuItem(int command_id, |
92 bool enabled, | 109 bool enabled, |
93 bool hidden, | 110 bool hidden, |
94 const base::string16& title) OVERRIDE; | 111 const base::string16& title) OVERRIDE; |
95 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE; | 112 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE; |
96 virtual content::WebContents* GetWebContents() const OVERRIDE; | 113 virtual content::WebContents* GetWebContents() const OVERRIDE; |
97 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; | 114 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; |
98 | 115 |
99 protected: | 116 protected: |
| 117 void set_toolkit_delegate(scoped_ptr<ToolkitDelegate> delegate) { |
| 118 toolkit_delegate_ = delegate.Pass(); |
| 119 } |
| 120 |
| 121 ToolkitDelegate* toolkit_delegate() { |
| 122 return toolkit_delegate_.get(); |
| 123 } |
| 124 |
100 void InitMenu(); | 125 void InitMenu(); |
101 Profile* GetProfile(); | 126 Profile* GetProfile(); |
102 | 127 |
103 // Platform specific functions. | 128 // Platform specific functions. |
104 virtual void PlatformInit() = 0; | |
105 virtual void PlatformCancel() = 0; | |
106 virtual bool GetAcceleratorForCommandId( | 129 virtual bool GetAcceleratorForCommandId( |
107 int command_id, | 130 int command_id, |
108 ui::Accelerator* accelerator) = 0; | 131 ui::Accelerator* accelerator) = 0; |
109 virtual void AppendPlatformEditableItems(); | 132 virtual void AppendPlatformEditableItems(); |
110 | 133 |
111 content::ContextMenuParams params_; | 134 content::ContextMenuParams params_; |
112 content::WebContents* source_web_contents_; | 135 content::WebContents* source_web_contents_; |
113 // The RenderFrameHost's IDs. | 136 // The RenderFrameHost's IDs. |
114 int render_process_id_; | 137 int render_process_id_; |
115 int render_frame_id_; | 138 int render_frame_id_; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 233 |
211 // Our observers. | 234 // Our observers. |
212 mutable ObserverList<RenderViewContextMenuObserver> observers_; | 235 mutable ObserverList<RenderViewContextMenuObserver> observers_; |
213 | 236 |
214 // Whether a command has been executed. Used to track whether menu observers | 237 // Whether a command has been executed. Used to track whether menu observers |
215 // should be notified of menu closing without execution. | 238 // should be notified of menu closing without execution. |
216 bool command_executed_; | 239 bool command_executed_; |
217 | 240 |
218 scoped_ptr<ContextMenuContentType> content_type_; | 241 scoped_ptr<ContextMenuContentType> content_type_; |
219 | 242 |
| 243 scoped_ptr<ToolkitDelegate> toolkit_delegate_; |
| 244 |
220 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenu); | 245 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenu); |
221 }; | 246 }; |
222 | 247 |
223 #endif // CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_H_ | 248 #endif // CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_H_ |
OLD | NEW |