Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: chrome/browser/extensions/menu_manager.h

Issue 64953004: Split extensions::MenuManager instance out from ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Explicit nit Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_MENU_MANAGER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/extensions/extension_icon_manager.h" 20 #include "chrome/browser/extensions/extension_icon_manager.h"
21 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
21 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
23 #include "extensions/common/url_pattern_set.h" 24 #include "extensions/common/url_pattern_set.h"
24 25
25 26
26 class Profile; 27 class Profile;
27 class SkBitmap; 28 class SkBitmap;
28 29
29 namespace content { 30 namespace content {
30 class WebContents; 31 class WebContents;
31 struct ContextMenuParams; 32 struct ContextMenuParams;
32 } 33 }
33 34
34 namespace extensions { 35 namespace extensions {
35 class Extension; 36 class Extension;
37 class StateStore;
36 38
37 // Represents a menu item added by an extension. 39 // Represents a menu item added by an extension.
38 class MenuItem { 40 class MenuItem {
39 public: 41 public:
40 // A list of MenuItems. 42 // A list of MenuItems.
41 typedef std::vector<MenuItem*> List; 43 typedef std::vector<MenuItem*> List;
42 44
43 // An Id uniquely identifies a context menu item registered by an extension. 45 // An Id uniquely identifies a context menu item registered by an extension.
44 struct Id { 46 struct Id {
45 Id(); 47 Id();
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 URLPatternSet target_url_patterns_; 238 URLPatternSet target_url_patterns_;
237 239
238 // Any children this item may have. 240 // Any children this item may have.
239 List children_; 241 List children_;
240 242
241 DISALLOW_COPY_AND_ASSIGN(MenuItem); 243 DISALLOW_COPY_AND_ASSIGN(MenuItem);
242 }; 244 };
243 245
244 // This class keeps track of menu items added by extensions. 246 // This class keeps track of menu items added by extensions.
245 class MenuManager : public content::NotificationObserver, 247 class MenuManager : public content::NotificationObserver,
246 public base::SupportsWeakPtr<MenuManager> { 248 public base::SupportsWeakPtr<MenuManager>,
249 public BrowserContextKeyedService {
247 public: 250 public:
248 explicit MenuManager(Profile* profile); 251 MenuManager(Profile* profile, StateStore* store_);
249 virtual ~MenuManager(); 252 virtual ~MenuManager();
250 253
254 // Convenience function to get the MenuManager for a Profile.
255 static MenuManager* Get(Profile* profile);
256
251 // Returns the ids of extensions which have menu items registered. 257 // Returns the ids of extensions which have menu items registered.
252 std::set<std::string> ExtensionIds(); 258 std::set<std::string> ExtensionIds();
253 259
254 // Returns a list of all the *top-level* menu items (added via AddContextItem) 260 // Returns a list of all the *top-level* menu items (added via AddContextItem)
255 // for the given extension id, *not* including child items (added via 261 // for the given extension id, *not* including child items (added via
256 // AddChildItem); although those can be reached via the top-level items' 262 // AddChildItem); although those can be reached via the top-level items'
257 // children. A view can then decide how to display these, including whether to 263 // children. A view can then decide how to display these, including whether to
258 // put them into a submenu if there are more than 1. 264 // put them into a submenu if there are more than 1.
259 const MenuItem::List* MenuItems(const std::string& extension_id); 265 const MenuItem::List* MenuItems(const std::string& extension_id);
260 266
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 // all items the menu manager knows about, including all children of top-level 350 // all items the menu manager knows about, including all children of top-level
345 // items. 351 // items.
346 std::map<MenuItem::Id, MenuItem*> items_by_id_; 352 std::map<MenuItem::Id, MenuItem*> items_by_id_;
347 353
348 content::NotificationRegistrar registrar_; 354 content::NotificationRegistrar registrar_;
349 355
350 ExtensionIconManager icon_manager_; 356 ExtensionIconManager icon_manager_;
351 357
352 Profile* profile_; 358 Profile* profile_;
353 359
360 // Owned by ExtensionSystem.
361 StateStore* store_;
362
354 DISALLOW_COPY_AND_ASSIGN(MenuManager); 363 DISALLOW_COPY_AND_ASSIGN(MenuManager);
355 }; 364 };
356 365
357 } // namespace extensions 366 } // namespace extensions
358 367
359 #endif // CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ 368 #endif // CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/menu_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698