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

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

Issue 482993003: Move logic to clear ExtensionAction values to ExtensionActionAPI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest master for CQ Created 6 years, 4 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 | 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 #include "chrome/browser/extensions/extension_action_manager.h" 5 #include "chrome/browser/extensions/extension_action_manager.h"
6 6
7 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage r_factory.h" 7 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage r_factory.h"
8 #include "chrome/browser/extensions/extension_action.h" 8 #include "chrome/browser/extensions/extension_action.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "components/keyed_service/content/browser_context_dependency_manager.h" 10 #include "components/keyed_service/content/browser_context_dependency_manager.h"
11 #include "extensions/browser/extension_registry.h" 11 #include "extensions/browser/extension_registry.h"
12 #include "extensions/browser/extension_system.h" 12 #include "extensions/browser/extension_system.h"
13 #include "extensions/browser/extensions_browser_client.h" 13 #include "extensions/browser/extensions_browser_client.h"
14 #include "extensions/common/constants.h" 14 #include "extensions/common/constants.h"
15 #include "extensions/common/manifest_handlers/icons_handler.h" 15 #include "extensions/common/manifest_handlers/icons_handler.h"
16 16
17 namespace extensions { 17 namespace extensions {
18 18
19 namespace { 19 namespace {
20 20
21 // BrowserContextKeyedServiceFactory for ExtensionActionManager. 21 // BrowserContextKeyedServiceFactory for ExtensionActionManager.
22 class ExtensionActionManagerFactory : public BrowserContextKeyedServiceFactory { 22 class ExtensionActionManagerFactory : public BrowserContextKeyedServiceFactory {
23 public: 23 public:
24 // BrowserContextKeyedServiceFactory implementation: 24 // BrowserContextKeyedServiceFactory implementation:
25 static ExtensionActionManager* GetForProfile(Profile* profile) { 25 static ExtensionActionManager* GetForBrowserContext(
26 content::BrowserContext* context) {
26 return static_cast<ExtensionActionManager*>( 27 return static_cast<ExtensionActionManager*>(
27 GetInstance()->GetServiceForBrowserContext(profile, true)); 28 GetInstance()->GetServiceForBrowserContext(context, true));
28 } 29 }
29 30
30 static ExtensionActionManagerFactory* GetInstance(); 31 static ExtensionActionManagerFactory* GetInstance();
31 32
32 private: 33 private:
33 friend struct DefaultSingletonTraits<ExtensionActionManagerFactory>; 34 friend struct DefaultSingletonTraits<ExtensionActionManagerFactory>;
34 35
35 ExtensionActionManagerFactory() 36 ExtensionActionManagerFactory()
36 : BrowserContextKeyedServiceFactory( 37 : BrowserContextKeyedServiceFactory(
37 "ExtensionActionManager", 38 "ExtensionActionManager",
(...skipping 23 matching lines...) Expand all
61 CHECK_EQ(profile, profile->GetOriginalProfile()) 62 CHECK_EQ(profile, profile->GetOriginalProfile())
62 << "Don't instantiate this with an incognito profile."; 63 << "Don't instantiate this with an incognito profile.";
63 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); 64 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
64 } 65 }
65 66
66 ExtensionActionManager::~ExtensionActionManager() { 67 ExtensionActionManager::~ExtensionActionManager() {
67 // Don't assert that the ExtensionAction maps are empty because Extensions are 68 // Don't assert that the ExtensionAction maps are empty because Extensions are
68 // sometimes (only in tests?) not unloaded before the Profile is destroyed. 69 // sometimes (only in tests?) not unloaded before the Profile is destroyed.
69 } 70 }
70 71
71 ExtensionActionManager* ExtensionActionManager::Get(Profile* profile) { 72 ExtensionActionManager* ExtensionActionManager::Get(
72 return ExtensionActionManagerFactory::GetForProfile(profile); 73 content::BrowserContext* context) {
74 return ExtensionActionManagerFactory::GetForBrowserContext(context);
73 } 75 }
74 76
75 void ExtensionActionManager::OnExtensionUnloaded( 77 void ExtensionActionManager::OnExtensionUnloaded(
76 content::BrowserContext* browser_context, 78 content::BrowserContext* browser_context,
77 const Extension* extension, 79 const Extension* extension,
78 UnloadedExtensionInfo::Reason reason) { 80 UnloadedExtensionInfo::Reason reason) {
79 page_actions_.erase(extension->id()); 81 page_actions_.erase(extension->id());
80 browser_actions_.erase(extension->id()); 82 browser_actions_.erase(extension->id());
81 system_indicators_.erase(extension->id()); 83 system_indicators_.erase(extension->id());
82 } 84 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (!extensions::SystemIndicatorManagerFactory::GetForProfile(profile_)) 198 if (!extensions::SystemIndicatorManagerFactory::GetForProfile(profile_))
197 return NULL; 199 return NULL;
198 200
199 return GetOrCreateOrNull(&system_indicators_, extension, 201 return GetOrCreateOrNull(&system_indicators_, extension,
200 ActionInfo::TYPE_SYSTEM_INDICATOR, 202 ActionInfo::TYPE_SYSTEM_INDICATOR,
201 ActionInfo::GetSystemIndicatorInfo(&extension), 203 ActionInfo::GetSystemIndicatorInfo(&extension),
202 profile_); 204 profile_);
203 } 205 }
204 206
205 } // namespace extensions 207 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_action_manager.h ('k') | chrome/browser/extensions/installed_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698