| 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 COMPONENTS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BASE_H_ | 5 #ifndef COMPONENTS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BASE_H_ |
| 6 #define COMPONENTS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BASE_H_ | 6 #define COMPONENTS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BASE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // Convert a command ID so that it fits within the range for | 60 // Convert a command ID so that it fits within the range for |
| 61 // content context menu. | 61 // content context menu. |
| 62 static int ConvertToContentCustomCommandId(int id); | 62 static int ConvertToContentCustomCommandId(int id); |
| 63 | 63 |
| 64 // True if the given id is the one generated for content context menu. | 64 // True if the given id is the one generated for content context menu. |
| 65 static bool IsContentCustomCommandId(int id); | 65 static bool IsContentCustomCommandId(int id); |
| 66 | 66 |
| 67 RenderViewContextMenuBase(content::RenderFrameHost* render_frame_host, | 67 RenderViewContextMenuBase(content::RenderFrameHost* render_frame_host, |
| 68 const content::ContextMenuParams& params); | 68 const content::ContextMenuParams& params); |
| 69 | 69 |
| 70 virtual ~RenderViewContextMenuBase(); | 70 ~RenderViewContextMenuBase() override; |
| 71 | 71 |
| 72 // Initializes the context menu. | 72 // Initializes the context menu. |
| 73 void Init(); | 73 void Init(); |
| 74 | 74 |
| 75 // Programmatically closes the context menu. | 75 // Programmatically closes the context menu. |
| 76 void Cancel(); | 76 void Cancel(); |
| 77 | 77 |
| 78 const ui::SimpleMenuModel& menu_model() const { return menu_model_; } | 78 const ui::SimpleMenuModel& menu_model() const { return menu_model_; } |
| 79 const content::ContextMenuParams& params() const { return params_; } | 79 const content::ContextMenuParams& params() const { return params_; } |
| 80 | 80 |
| 81 // Returns true if the specified command id is known and valid for | 81 // Returns true if the specified command id is known and valid for |
| 82 // this menu. If the command is known |enabled| is set to indicate | 82 // this menu. If the command is known |enabled| is set to indicate |
| 83 // if the command is enabled. | 83 // if the command is enabled. |
| 84 bool IsCommandIdKnown(int command_id, bool* enabled) const; | 84 bool IsCommandIdKnown(int command_id, bool* enabled) const; |
| 85 | 85 |
| 86 // SimpleMenuModel::Delegate implementation. | 86 // SimpleMenuModel::Delegate implementation. |
| 87 virtual bool IsCommandIdChecked(int command_id) const override; | 87 bool IsCommandIdChecked(int command_id) const override; |
| 88 virtual void ExecuteCommand(int command_id, int event_flags) override; | 88 void ExecuteCommand(int command_id, int event_flags) override; |
| 89 virtual void MenuWillShow(ui::SimpleMenuModel* source) override; | 89 void MenuWillShow(ui::SimpleMenuModel* source) override; |
| 90 virtual void MenuClosed(ui::SimpleMenuModel* source) override; | 90 void MenuClosed(ui::SimpleMenuModel* source) override; |
| 91 | 91 |
| 92 // RenderViewContextMenuProxy implementation. | 92 // RenderViewContextMenuProxy implementation. |
| 93 virtual void AddMenuItem(int command_id, | 93 void AddMenuItem(int command_id, const base::string16& title) override; |
| 94 const base::string16& title) override; | 94 void AddCheckItem(int command_id, const base::string16& title) override; |
| 95 virtual void AddCheckItem(int command_id, | 95 void AddSeparator() override; |
| 96 const base::string16& title) override; | 96 void AddSubMenu(int command_id, |
| 97 virtual void AddSeparator() override; | 97 const base::string16& label, |
| 98 virtual void AddSubMenu(int command_id, | 98 ui::MenuModel* model) override; |
| 99 const base::string16& label, | 99 void UpdateMenuItem(int command_id, |
| 100 ui::MenuModel* model) override; | 100 bool enabled, |
| 101 virtual void UpdateMenuItem(int command_id, | 101 bool hidden, |
| 102 bool enabled, | 102 const base::string16& title) override; |
| 103 bool hidden, | 103 content::RenderViewHost* GetRenderViewHost() const override; |
| 104 const base::string16& title) override; | 104 content::WebContents* GetWebContents() const override; |
| 105 virtual content::RenderViewHost* GetRenderViewHost() const override; | 105 content::BrowserContext* GetBrowserContext() const override; |
| 106 virtual content::WebContents* GetWebContents() const override; | |
| 107 virtual content::BrowserContext* GetBrowserContext() const override; | |
| 108 | 106 |
| 109 protected: | 107 protected: |
| 110 friend class RenderViewContextMenuTest; | 108 friend class RenderViewContextMenuTest; |
| 111 friend class RenderViewContextMenuPrefsTest; | 109 friend class RenderViewContextMenuPrefsTest; |
| 112 | 110 |
| 113 void set_content_type(ContextMenuContentType* content_type) { | 111 void set_content_type(ContextMenuContentType* content_type) { |
| 114 content_type_.reset(content_type); | 112 content_type_.reset(content_type); |
| 115 } | 113 } |
| 116 | 114 |
| 117 void set_toolkit_delegate(scoped_ptr<ToolkitDelegate> delegate) { | 115 void set_toolkit_delegate(scoped_ptr<ToolkitDelegate> delegate) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 181 |
| 184 // The RenderFrameHost's IDs. | 182 // The RenderFrameHost's IDs. |
| 185 int render_process_id_; | 183 int render_process_id_; |
| 186 | 184 |
| 187 scoped_ptr<ToolkitDelegate> toolkit_delegate_; | 185 scoped_ptr<ToolkitDelegate> toolkit_delegate_; |
| 188 | 186 |
| 189 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuBase); | 187 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuBase); |
| 190 }; | 188 }; |
| 191 | 189 |
| 192 #endif // COMPONENTS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BASE_H_ | 190 #endif // COMPONENTS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BASE_H_ |
| OLD | NEW |