OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 18 matching lines...) Expand all Loading... |
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 uniquely identifies a context menu item registered by an extension. | 36 // An Id uniquely identifies a context menu item registered by an extension. |
37 struct Id { | 37 struct Id { |
38 Id(); | 38 Id(); |
39 Id(Profile* profile, std::string extension_id, int uid); | 39 Id(Profile* profile, const std::string& extension_id, int uid); |
40 ~Id(); | 40 ~Id(); |
41 | 41 |
42 bool operator==(const Id& other) const; | 42 bool operator==(const Id& other) const; |
43 bool operator!=(const Id& other) const; | 43 bool operator!=(const Id& other) const; |
44 bool operator<(const Id& other) const; | 44 bool operator<(const Id& other) const; |
45 | 45 |
46 Profile* profile; | 46 Profile* profile; |
47 std::string extension_id; | 47 std::string extension_id; |
48 int uid; | 48 int uid; |
49 }; | 49 }; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
93 | 93 |
94 void Add(Context context) { | 94 void Add(Context context) { |
95 value_ |= context; | 95 value_ |= context; |
96 } | 96 } |
97 | 97 |
98 private: | 98 private: |
99 uint32 value_; // A bitmask of Context values. | 99 uint32 value_; // A bitmask of Context values. |
100 }; | 100 }; |
101 | 101 |
102 ExtensionMenuItem(const Id& id, std::string title, bool checked, Type type, | 102 ExtensionMenuItem(const Id& id, |
| 103 const std::string& title, |
| 104 bool checked, |
| 105 Type type, |
103 const ContextList& contexts); | 106 const ContextList& contexts); |
104 virtual ~ExtensionMenuItem(); | 107 virtual ~ExtensionMenuItem(); |
105 | 108 |
106 // Simple accessor methods. | 109 // Simple accessor methods. |
107 const std::string& extension_id() const { return id_.extension_id; } | 110 const std::string& extension_id() const { return id_.extension_id; } |
108 const std::string& title() const { return title_; } | 111 const std::string& title() const { return title_; } |
109 const List& children() { return children_; } | 112 const List& children() { return children_; } |
110 const Id& id() const { return id_; } | 113 const Id& id() const { return id_; } |
111 Id* parent_id() const { return parent_id_.get(); } | 114 Id* parent_id() const { return parent_id_.get(); } |
112 int child_count() const { return children_.size(); } | 115 int child_count() const { return children_.size(); } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 std::map<ExtensionMenuItem::Id, ExtensionMenuItem*> items_by_id_; | 278 std::map<ExtensionMenuItem::Id, ExtensionMenuItem*> items_by_id_; |
276 | 279 |
277 NotificationRegistrar registrar_; | 280 NotificationRegistrar registrar_; |
278 | 281 |
279 ExtensionIconManager icon_manager_; | 282 ExtensionIconManager icon_manager_; |
280 | 283 |
281 DISALLOW_COPY_AND_ASSIGN(ExtensionMenuManager); | 284 DISALLOW_COPY_AND_ASSIGN(ExtensionMenuManager); |
282 }; | 285 }; |
283 | 286 |
284 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MENU_MANAGER_H_ | 287 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MENU_MANAGER_H_ |
OLD | NEW |