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

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

Issue 666153002: Standardize usage of virtual/override/final in chrome/browser/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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_EXTENSION_ACTION_MANAGER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/scoped_observer.h" 11 #include "base/scoped_observer.h"
12 #include "chrome/common/extensions/api/extension_action/action_info.h" 12 #include "chrome/common/extensions/api/extension_action/action_info.h"
13 #include "components/keyed_service/core/keyed_service.h" 13 #include "components/keyed_service/core/keyed_service.h"
14 #include "extensions/browser/extension_registry_observer.h" 14 #include "extensions/browser/extension_registry_observer.h"
15 15
16 class ExtensionAction; 16 class ExtensionAction;
17 class Profile; 17 class Profile;
18 18
19 namespace extensions { 19 namespace extensions {
20 20
21 class Extension; 21 class Extension;
22 class ExtensionRegistry; 22 class ExtensionRegistry;
23 23
24 // Owns the ExtensionActions associated with each extension. These actions live 24 // Owns the ExtensionActions associated with each extension. These actions live
25 // while an extension is loaded and are destroyed on unload. 25 // while an extension is loaded and are destroyed on unload.
26 class ExtensionActionManager : public KeyedService, 26 class ExtensionActionManager : public KeyedService,
27 public ExtensionRegistryObserver { 27 public ExtensionRegistryObserver {
28 public: 28 public:
29 explicit ExtensionActionManager(Profile* profile); 29 explicit ExtensionActionManager(Profile* profile);
30 virtual ~ExtensionActionManager(); 30 ~ExtensionActionManager() override;
31 31
32 // Returns this profile's ExtensionActionManager. One instance is 32 // Returns this profile's ExtensionActionManager. One instance is
33 // shared between a profile and its incognito version. 33 // shared between a profile and its incognito version.
34 static ExtensionActionManager* Get(content::BrowserContext* browser_context); 34 static ExtensionActionManager* Get(content::BrowserContext* browser_context);
35 35
36 // Retrieves the page action, browser action, or system indicator for 36 // Retrieves the page action, browser action, or system indicator for
37 // |extension|. 37 // |extension|.
38 // If the result is not NULL, it remains valid until the extension is 38 // If the result is not NULL, it remains valid until the extension is
39 // unloaded. 39 // unloaded.
40 ExtensionAction* GetPageAction(const Extension& extension) const; 40 ExtensionAction* GetPageAction(const Extension& extension) const;
41 ExtensionAction* GetBrowserAction(const Extension& extension) const; 41 ExtensionAction* GetBrowserAction(const Extension& extension) const;
42 ExtensionAction* GetSystemIndicator(const Extension& extension) const; 42 ExtensionAction* GetSystemIndicator(const Extension& extension) const;
43 43
44 // Returns either the PageAction or BrowserAction for |extension|, or NULL if 44 // Returns either the PageAction or BrowserAction for |extension|, or NULL if
45 // none exists. Since an extension can only declare one of Browser|PageAction, 45 // none exists. Since an extension can only declare one of Browser|PageAction,
46 // this is okay to use anywhere you need a generic "ExtensionAction". 46 // this is okay to use anywhere you need a generic "ExtensionAction".
47 // Since SystemIndicators are used differently and don't follow this 47 // Since SystemIndicators are used differently and don't follow this
48 // rule of mutual exclusion, they are not checked or returned. 48 // rule of mutual exclusion, they are not checked or returned.
49 ExtensionAction* GetExtensionAction(const Extension& extension) const; 49 ExtensionAction* GetExtensionAction(const Extension& extension) const;
50 50
51 // Gets the best fit ExtensionAction for the given |extension|. This takes 51 // Gets the best fit ExtensionAction for the given |extension|. This takes
52 // into account |extension|'s browser or page actions, if any, along with its 52 // into account |extension|'s browser or page actions, if any, along with its
53 // name and any declared icons. 53 // name and any declared icons.
54 scoped_ptr<ExtensionAction> GetBestFitAction( 54 scoped_ptr<ExtensionAction> GetBestFitAction(
55 const Extension& extension, ActionInfo::Type type) const; 55 const Extension& extension, ActionInfo::Type type) const;
56 56
57 private: 57 private:
58 // Implement ExtensionRegistryObserver. 58 // Implement ExtensionRegistryObserver.
59 virtual void OnExtensionUnloaded(content::BrowserContext* browser_context, 59 void OnExtensionUnloaded(content::BrowserContext* browser_context,
60 const Extension* extension, 60 const Extension* extension,
61 UnloadedExtensionInfo::Reason reason) 61 UnloadedExtensionInfo::Reason reason) override;
62 override;
63 62
64 Profile* profile_; 63 Profile* profile_;
65 64
66 // Listen to extension unloaded notifications. 65 // Listen to extension unloaded notifications.
67 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 66 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
68 extension_registry_observer_; 67 extension_registry_observer_;
69 68
70 // Keyed by Extension ID. These maps are populated lazily when their 69 // Keyed by Extension ID. These maps are populated lazily when their
71 // ExtensionAction is first requested, and the entries are removed when the 70 // ExtensionAction is first requested, and the entries are removed when the
72 // extension is unloaded. Not every extension has a page action or browser 71 // extension is unloaded. Not every extension has a page action or browser
73 // action. 72 // action.
74 typedef std::map<std::string, linked_ptr<ExtensionAction> > ExtIdToActionMap; 73 typedef std::map<std::string, linked_ptr<ExtensionAction> > ExtIdToActionMap;
75 mutable ExtIdToActionMap page_actions_; 74 mutable ExtIdToActionMap page_actions_;
76 mutable ExtIdToActionMap browser_actions_; 75 mutable ExtIdToActionMap browser_actions_;
77 mutable ExtIdToActionMap system_indicators_; 76 mutable ExtIdToActionMap system_indicators_;
78 }; 77 };
79 78
80 } // namespace extensions 79 } // namespace extensions
81 80
82 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_ 81 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698