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_EXTENSIONS_EXTENSION_MENU_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MENU_MANAGER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MENU_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MENU_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/string16.h" | 18 #include "base/string16.h" |
19 #include "chrome/browser/extensions/extension_icon_manager.h" | 19 #include "chrome/browser/extensions/extension_icon_manager.h" |
20 #include "chrome/common/extensions/url_pattern_set.h" | 20 #include "chrome/common/extensions/url_pattern_set.h" |
21 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
23 | 23 |
24 | 24 |
25 class Extension; | |
26 class Profile; | 25 class Profile; |
27 class SkBitmap; | 26 class SkBitmap; |
28 | 27 |
29 namespace content { | 28 namespace content { |
30 class WebContents; | 29 class WebContents; |
31 struct ContextMenuParams; | 30 struct ContextMenuParams; |
32 } | 31 } |
33 | 32 |
| 33 namespace extensions { |
| 34 class Extension; |
| 35 } |
| 36 |
34 // Represents a menu item added by an extension. | 37 // Represents a menu item added by an extension. |
35 class ExtensionMenuItem { | 38 class ExtensionMenuItem { |
36 public: | 39 public: |
37 // A list of ExtensionMenuItem's. | 40 // A list of ExtensionMenuItem's. |
38 typedef std::vector<ExtensionMenuItem*> List; | 41 typedef std::vector<ExtensionMenuItem*> List; |
39 | 42 |
40 // An Id uniquely identifies a context menu item registered by an extension. | 43 // An Id uniquely identifies a context menu item registered by an extension. |
41 struct Id { | 44 struct Id { |
42 Id(); | 45 Id(); |
43 // Since the unique ID (uid or string_uid) is parsed from API arguments, | 46 // Since the unique ID (uid or string_uid) is parsed from API arguments, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // Returns a list of all the *top-level* menu items (added via AddContextItem) | 220 // Returns a list of all the *top-level* menu items (added via AddContextItem) |
218 // for the given extension id, *not* including child items (added via | 221 // for the given extension id, *not* including child items (added via |
219 // AddChildItem); although those can be reached via the top-level items' | 222 // AddChildItem); although those can be reached via the top-level items' |
220 // children. A view can then decide how to display these, including whether to | 223 // children. A view can then decide how to display these, including whether to |
221 // put them into a submenu if there are more than 1. | 224 // put them into a submenu if there are more than 1. |
222 const ExtensionMenuItem::List* MenuItems(const std::string& extension_id); | 225 const ExtensionMenuItem::List* MenuItems(const std::string& extension_id); |
223 | 226 |
224 // Adds a top-level menu item for an extension, requiring the |extension| | 227 // Adds a top-level menu item for an extension, requiring the |extension| |
225 // pointer so it can load the icon for the extension. Takes ownership of | 228 // pointer so it can load the icon for the extension. Takes ownership of |
226 // |item|. Returns a boolean indicating success or failure. | 229 // |item|. Returns a boolean indicating success or failure. |
227 bool AddContextItem(const Extension* extension, ExtensionMenuItem* item); | 230 bool AddContextItem(const extensions::Extension* extension, |
| 231 ExtensionMenuItem* item); |
228 | 232 |
229 // Add an item as a child of another item which has been previously added, and | 233 // Add an item as a child of another item which has been previously added, and |
230 // takes ownership of |item|. Returns a boolean indicating success or failure. | 234 // takes ownership of |item|. Returns a boolean indicating success or failure. |
231 bool AddChildItem(const ExtensionMenuItem::Id& parent_id, | 235 bool AddChildItem(const ExtensionMenuItem::Id& parent_id, |
232 ExtensionMenuItem* child); | 236 ExtensionMenuItem* child); |
233 | 237 |
234 // Makes existing item with |child_id| a child of the item with |parent_id|. | 238 // Makes existing item with |child_id| a child of the item with |parent_id|. |
235 // If the child item was already a child of another parent, this will remove | 239 // If the child item was already a child of another parent, this will remove |
236 // it from that parent first. It is an error to try and move an item to be a | 240 // it from that parent first. It is an error to try and move an item to be a |
237 // child of one of its own descendants. It is legal to pass NULL for | 241 // child of one of its own descendants. It is legal to pass NULL for |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 std::map<ExtensionMenuItem::Id, ExtensionMenuItem*> items_by_id_; | 302 std::map<ExtensionMenuItem::Id, ExtensionMenuItem*> items_by_id_; |
299 | 303 |
300 content::NotificationRegistrar registrar_; | 304 content::NotificationRegistrar registrar_; |
301 | 305 |
302 ExtensionIconManager icon_manager_; | 306 ExtensionIconManager icon_manager_; |
303 | 307 |
304 DISALLOW_COPY_AND_ASSIGN(ExtensionMenuManager); | 308 DISALLOW_COPY_AND_ASSIGN(ExtensionMenuManager); |
305 }; | 309 }; |
306 | 310 |
307 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MENU_MANAGER_H_ | 311 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MENU_MANAGER_H_ |
OLD | NEW |