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

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

Issue 250443002: Remove NOTIFICATION_EXTENSION_LOADED_DEPRECATED from MenuManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months 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
« no previous file with comments | « no previous file | chrome/browser/extensions/menu_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/scoped_observer.h"
18 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
19 #include "base/values.h" 20 #include "base/values.h"
20 #include "chrome/browser/extensions/extension_icon_manager.h" 21 #include "chrome/browser/extensions/extension_icon_manager.h"
21 #include "components/keyed_service/core/keyed_service.h" 22 #include "components/keyed_service/core/keyed_service.h"
22 #include "content/public/browser/notification_observer.h" 23 #include "content/public/browser/notification_observer.h"
23 #include "content/public/browser/notification_registrar.h" 24 #include "content/public/browser/notification_registrar.h"
25 #include "extensions/browser/extension_registry_observer.h"
24 #include "extensions/common/url_pattern_set.h" 26 #include "extensions/common/url_pattern_set.h"
25 27
26
27 class Profile; 28 class Profile;
28 class SkBitmap; 29 class SkBitmap;
29 30
30 namespace content { 31 namespace content {
31 class WebContents; 32 class WebContents;
32 struct ContextMenuParams; 33 struct ContextMenuParams;
33 } 34 }
34 35
35 namespace extensions { 36 namespace extensions {
36 class Extension; 37 class Extension;
38 class ExtensionRegistry;
37 class StateStore; 39 class StateStore;
38 40
39 // Represents a menu item added by an extension. 41 // Represents a menu item added by an extension.
40 class MenuItem { 42 class MenuItem {
41 public: 43 public:
42 // A list of MenuItems. 44 // A list of MenuItems.
43 typedef std::vector<MenuItem*> List; 45 typedef std::vector<MenuItem*> List;
44 46
45 // Key used to identify which extension a menu item belongs to. 47 // Key used to identify which extension a menu item belongs to.
46 // A menu item can also belong to a <webview> inside an extension, 48 // A menu item can also belong to a <webview> inside an extension,
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 262
261 // Any children this item may have. 263 // Any children this item may have.
262 List children_; 264 List children_;
263 265
264 DISALLOW_COPY_AND_ASSIGN(MenuItem); 266 DISALLOW_COPY_AND_ASSIGN(MenuItem);
265 }; 267 };
266 268
267 // This class keeps track of menu items added by extensions. 269 // This class keeps track of menu items added by extensions.
268 class MenuManager : public content::NotificationObserver, 270 class MenuManager : public content::NotificationObserver,
269 public base::SupportsWeakPtr<MenuManager>, 271 public base::SupportsWeakPtr<MenuManager>,
270 public KeyedService { 272 public KeyedService,
273 public ExtensionRegistryObserver {
271 public: 274 public:
272 static const char kOnContextMenus[]; 275 static const char kOnContextMenus[];
273 static const char kOnWebviewContextMenus[]; 276 static const char kOnWebviewContextMenus[];
274 277
275 MenuManager(Profile* profile, StateStore* store_); 278 MenuManager(Profile* profile, StateStore* store_);
276 virtual ~MenuManager(); 279 virtual ~MenuManager();
277 280
278 // Convenience function to get the MenuManager for a Profile. 281 // Convenience function to get the MenuManager for a Profile.
279 static MenuManager* Get(Profile* profile); 282 static MenuManager* Get(Profile* profile);
280 283
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 void ExecuteCommand(Profile* profile, 330 void ExecuteCommand(Profile* profile,
328 content::WebContents* web_contents, 331 content::WebContents* web_contents,
329 const content::ContextMenuParams& params, 332 const content::ContextMenuParams& params,
330 const MenuItem::Id& menu_item_id); 333 const MenuItem::Id& menu_item_id);
331 334
332 // This returns a bitmap of width/height kFaviconSize, loaded either from an 335 // This returns a bitmap of width/height kFaviconSize, loaded either from an
333 // entry specified in the extension's 'icon' section of the manifest, or a 336 // entry specified in the extension's 'icon' section of the manifest, or a
334 // default extension icon. 337 // default extension icon.
335 const SkBitmap& GetIconForExtension(const std::string& extension_id); 338 const SkBitmap& GetIconForExtension(const std::string& extension_id);
336 339
337 // Implements the content::NotificationObserver interface. 340 // content::NotificationObserver implementation.
338 virtual void Observe(int type, const content::NotificationSource& source, 341 virtual void Observe(int type, const content::NotificationSource& source,
339 const content::NotificationDetails& details) OVERRIDE; 342 const content::NotificationDetails& details) OVERRIDE;
340 343
344 // ExtensionRegistryObserver implementation.
345 virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
346 const Extension* extension) OVERRIDE;
347 virtual void OnExtensionUnloaded(
348 content::BrowserContext* browser_context,
349 const Extension* extension,
350 UnloadedExtensionInfo::Reason reason) OVERRIDE;
351
341 // Stores the menu items for the extension in the state storage. 352 // Stores the menu items for the extension in the state storage.
342 void WriteToStorage(const Extension* extension, 353 void WriteToStorage(const Extension* extension,
343 const MenuItem::ExtensionKey& extension_key); 354 const MenuItem::ExtensionKey& extension_key);
344 355
345 // Reads menu items for the extension from the state storage. Any invalid 356 // Reads menu items for the extension from the state storage. Any invalid
346 // items are ignored. 357 // items are ignored.
347 void ReadFromStorage(const std::string& extension_id, 358 void ReadFromStorage(const std::string& extension_id,
348 scoped_ptr<base::Value> value); 359 scoped_ptr<base::Value> value);
349 360
350 // Removes all "incognito" "split" mode context items. 361 // Removes all "incognito" "split" mode context items.
(...skipping 20 matching lines...) Expand all
371 typedef std::map<MenuItem::ExtensionKey, MenuItem::List> MenuItemMap; 382 typedef std::map<MenuItem::ExtensionKey, MenuItem::List> MenuItemMap;
372 MenuItemMap context_items_; 383 MenuItemMap context_items_;
373 384
374 // This lets us make lookup by id fast. It maps id to MenuItem* for 385 // This lets us make lookup by id fast. It maps id to MenuItem* for
375 // all items the menu manager knows about, including all children of top-level 386 // all items the menu manager knows about, including all children of top-level
376 // items. 387 // items.
377 std::map<MenuItem::Id, MenuItem*> items_by_id_; 388 std::map<MenuItem::Id, MenuItem*> items_by_id_;
378 389
379 content::NotificationRegistrar registrar_; 390 content::NotificationRegistrar registrar_;
380 391
392 // Listen to extension load, unloaded notifications.
393 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
394 extension_registry_observer_;
395
381 ExtensionIconManager icon_manager_; 396 ExtensionIconManager icon_manager_;
382 397
383 Profile* profile_; 398 Profile* profile_;
384 399
385 // Owned by ExtensionSystem. 400 // Owned by ExtensionSystem.
386 StateStore* store_; 401 StateStore* store_;
387 402
388 DISALLOW_COPY_AND_ASSIGN(MenuManager); 403 DISALLOW_COPY_AND_ASSIGN(MenuManager);
389 }; 404 };
390 405
391 } // namespace extensions 406 } // namespace extensions
392 407
393 #endif // CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ 408 #endif // CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/menu_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698