OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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> |
(...skipping 15 matching lines...) Expand all Loading... |
26 class Profile; | 26 class Profile; |
27 class SkBitmap; | 27 class SkBitmap; |
28 class TabContents; | 28 class TabContents; |
29 | 29 |
30 // Represents a menu item added by an extension. | 30 // Represents a menu item added by an extension. |
31 class ExtensionMenuItem { | 31 class ExtensionMenuItem { |
32 public: | 32 public: |
33 // A list of ExtensionMenuItem's. | 33 // A list of ExtensionMenuItem's. |
34 typedef std::vector<ExtensionMenuItem*> List; | 34 typedef std::vector<ExtensionMenuItem*> List; |
35 | 35 |
36 // An Id is a pair of |extension id|, |int| where the |int| is unique per | 36 // An Id uniquely identifies a context menu item registered by an extension. |
37 // extension. | 37 struct Id { |
38 typedef std::pair<std::string, int> Id; | 38 Id(); |
| 39 Id(Profile* profile, std::string extension_id, int uid); |
| 40 ~Id(); |
| 41 |
| 42 bool operator==(const Id& other) const; |
| 43 bool operator!=(const Id& other) const; |
| 44 bool operator<(const Id& other) const; |
| 45 |
| 46 Profile* profile; |
| 47 std::string extension_id; |
| 48 int uid; |
| 49 }; |
39 | 50 |
40 // For context menus, these are the contexts where an item can appear. | 51 // For context menus, these are the contexts where an item can appear. |
41 enum Context { | 52 enum Context { |
42 ALL = 1, | 53 ALL = 1, |
43 PAGE = 2, | 54 PAGE = 2, |
44 SELECTION = 4, | 55 SELECTION = 4, |
45 LINK = 8, | 56 LINK = 8, |
46 EDITABLE = 16, | 57 EDITABLE = 16, |
47 IMAGE = 32, | 58 IMAGE = 32, |
48 VIDEO = 64, | 59 VIDEO = 64, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 97 |
87 private: | 98 private: |
88 uint32 value_; // A bitmask of Context values. | 99 uint32 value_; // A bitmask of Context values. |
89 }; | 100 }; |
90 | 101 |
91 ExtensionMenuItem(const Id& id, std::string title, bool checked, Type type, | 102 ExtensionMenuItem(const Id& id, std::string title, bool checked, Type type, |
92 const ContextList& contexts); | 103 const ContextList& contexts); |
93 virtual ~ExtensionMenuItem(); | 104 virtual ~ExtensionMenuItem(); |
94 | 105 |
95 // Simple accessor methods. | 106 // Simple accessor methods. |
96 const std::string& extension_id() const { return id_.first; } | 107 const std::string& extension_id() const { return id_.extension_id; } |
97 const std::string& title() const { return title_; } | 108 const std::string& title() const { return title_; } |
98 const List& children() { return children_; } | 109 const List& children() { return children_; } |
99 const Id& id() const { return id_; } | 110 const Id& id() const { return id_; } |
100 Id* parent_id() const { return parent_id_.get(); } | 111 Id* parent_id() const { return parent_id_.get(); } |
101 int child_count() const { return children_.size(); } | 112 int child_count() const { return children_.size(); } |
102 ContextList contexts() const { return contexts_; } | 113 ContextList contexts() const { return contexts_; } |
103 Type type() const { return type_; } | 114 Type type() const { return type_; } |
104 bool checked() const { return checked_; } | 115 bool checked() const { return checked_; } |
105 const ExtensionExtent& document_url_patterns() const { | 116 const ExtensionExtent& document_url_patterns() const { |
106 return document_url_patterns_; | 117 return document_url_patterns_; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 std::map<ExtensionMenuItem::Id, ExtensionMenuItem*> items_by_id_; | 275 std::map<ExtensionMenuItem::Id, ExtensionMenuItem*> items_by_id_; |
265 | 276 |
266 NotificationRegistrar registrar_; | 277 NotificationRegistrar registrar_; |
267 | 278 |
268 ExtensionIconManager icon_manager_; | 279 ExtensionIconManager icon_manager_; |
269 | 280 |
270 DISALLOW_COPY_AND_ASSIGN(ExtensionMenuManager); | 281 DISALLOW_COPY_AND_ASSIGN(ExtensionMenuManager); |
271 }; | 282 }; |
272 | 283 |
273 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MENU_MANAGER_H_ | 284 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MENU_MANAGER_H_ |
OLD | NEW |