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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 // Initialize the toolkit's menu. | 44 // Initialize the toolkit's menu. |
45 virtual void Init(ui::SimpleMenuModel* menu_model) = 0; | 45 virtual void Init(ui::SimpleMenuModel* menu_model) = 0; |
46 | 46 |
47 virtual void Cancel() = 0; | 47 virtual void Cancel() = 0; |
48 | 48 |
49 // Updates the actual menu items controlled by the toolkit. | 49 // Updates the actual menu items controlled by the toolkit. |
50 virtual void UpdateMenuItem(int command_id, | 50 virtual void UpdateMenuItem(int command_id, |
51 bool enabled, | 51 bool enabled, |
52 bool hidden, | 52 bool hidden, |
53 const base::string16& title) = 0; | 53 const base::string16& title) = 0; |
54 // Set icon to the actual menu items controlled by the toolkit. | |
lazyboy
2015/02/13 08:10:39
Sets icon to ...
pals
2015/02/13 09:30:40
Done.
| |
55 virtual void SetIcon(int command_id, const gfx::Image& icon) = 0; | |
54 }; | 56 }; |
55 | 57 |
56 static const size_t kMaxSelectionTextLength; | 58 static const size_t kMaxSelectionTextLength; |
57 | 59 |
58 static void SetContentCustomCommandIdRange(int first, int last); | 60 static void SetContentCustomCommandIdRange(int first, int last); |
59 | 61 |
60 // Convert a command ID so that it fits within the range for | 62 // Convert a command ID so that it fits within the range for |
61 // content context menu. | 63 // content context menu. |
62 static int ConvertToContentCustomCommandId(int id); | 64 static int ConvertToContentCustomCommandId(int id); |
63 | 65 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 void AddMenuItem(int command_id, const base::string16& title) override; | 99 void AddMenuItem(int command_id, const base::string16& title) override; |
98 void AddCheckItem(int command_id, const base::string16& title) override; | 100 void AddCheckItem(int command_id, const base::string16& title) override; |
99 void AddSeparator() override; | 101 void AddSeparator() override; |
100 void AddSubMenu(int command_id, | 102 void AddSubMenu(int command_id, |
101 const base::string16& label, | 103 const base::string16& label, |
102 ui::MenuModel* model) override; | 104 ui::MenuModel* model) override; |
103 void UpdateMenuItem(int command_id, | 105 void UpdateMenuItem(int command_id, |
104 bool enabled, | 106 bool enabled, |
105 bool hidden, | 107 bool hidden, |
106 const base::string16& title) override; | 108 const base::string16& title) override; |
109 void SetIcon(int command_id, const gfx::Image& icon) override; | |
107 content::RenderViewHost* GetRenderViewHost() const override; | 110 content::RenderViewHost* GetRenderViewHost() const override; |
108 content::WebContents* GetWebContents() const override; | 111 content::WebContents* GetWebContents() const override; |
109 content::BrowserContext* GetBrowserContext() const override; | 112 content::BrowserContext* GetBrowserContext() const override; |
110 | 113 |
111 protected: | 114 protected: |
112 friend class RenderViewContextMenuTest; | 115 friend class RenderViewContextMenuTest; |
113 friend class RenderViewContextMenuPrefsTest; | 116 friend class RenderViewContextMenuPrefsTest; |
114 | 117 |
115 void set_content_type(ContextMenuContentType* content_type) { | 118 void set_content_type(ContextMenuContentType* content_type) { |
116 content_type_.reset(content_type); | 119 content_type_.reset(content_type); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 mutable ObserverList<RenderViewContextMenuObserver> observers_; | 177 mutable ObserverList<RenderViewContextMenuObserver> observers_; |
175 | 178 |
176 // Whether a command has been executed. Used to track whether menu observers | 179 // Whether a command has been executed. Used to track whether menu observers |
177 // should be notified of menu closing without execution. | 180 // should be notified of menu closing without execution. |
178 bool command_executed_; | 181 bool command_executed_; |
179 | 182 |
180 scoped_ptr<ContextMenuContentType> content_type_; | 183 scoped_ptr<ContextMenuContentType> content_type_; |
181 | 184 |
182 private: | 185 private: |
183 bool AppendCustomItems(); | 186 bool AppendCustomItems(); |
187 void AddCustomItemsToMenu(const std::vector<content::MenuItem>& items, | |
188 size_t depth, | |
189 size_t* total_items, | |
190 ui::SimpleMenuModel::Delegate* delegate, | |
191 ui::SimpleMenuModel* menu_model); | |
192 void OnIconDownloaded(int command_id, | |
193 int id, | |
194 int http_status_code, | |
195 const GURL& image_url, | |
196 const std::vector<SkBitmap>& bitmaps, | |
197 const std::vector<gfx::Size>& original_bitmap_sizes); | |
184 | 198 |
185 // The RenderFrameHost's IDs. | 199 // The RenderFrameHost's IDs. |
186 int render_process_id_; | 200 int render_process_id_; |
187 | 201 |
188 scoped_ptr<ToolkitDelegate> toolkit_delegate_; | 202 scoped_ptr<ToolkitDelegate> toolkit_delegate_; |
203 base::WeakPtrFactory<RenderViewContextMenuBase> weak_ptr_factory_; | |
189 | 204 |
190 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuBase); | 205 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuBase); |
191 }; | 206 }; |
192 | 207 |
193 #endif // COMPONENTS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BASE_H_ | 208 #endif // COMPONENTS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BASE_H_ |
OLD | NEW |