| OLD | NEW |
| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // BrowserContextKeyedServiceFactory implementation: | 23 // BrowserContextKeyedServiceFactory implementation: |
| 24 static ExtensionActionManager* GetForBrowserContext( | 24 static ExtensionActionManager* GetForBrowserContext( |
| 25 content::BrowserContext* context) { | 25 content::BrowserContext* context) { |
| 26 return static_cast<ExtensionActionManager*>( | 26 return static_cast<ExtensionActionManager*>( |
| 27 GetInstance()->GetServiceForBrowserContext(context, true)); | 27 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 28 } | 28 } |
| 29 | 29 |
| 30 static ExtensionActionManagerFactory* GetInstance(); | 30 static ExtensionActionManagerFactory* GetInstance(); |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 friend struct DefaultSingletonTraits<ExtensionActionManagerFactory>; | 33 friend struct base::DefaultSingletonTraits<ExtensionActionManagerFactory>; |
| 34 | 34 |
| 35 ExtensionActionManagerFactory() | 35 ExtensionActionManagerFactory() |
| 36 : BrowserContextKeyedServiceFactory( | 36 : BrowserContextKeyedServiceFactory( |
| 37 "ExtensionActionManager", | 37 "ExtensionActionManager", |
| 38 BrowserContextDependencyManager::GetInstance()) { | 38 BrowserContextDependencyManager::GetInstance()) { |
| 39 } | 39 } |
| 40 | 40 |
| 41 KeyedService* BuildServiceInstanceFor( | 41 KeyedService* BuildServiceInstanceFor( |
| 42 content::BrowserContext* profile) const override { | 42 content::BrowserContext* profile) const override { |
| 43 return new ExtensionActionManager(static_cast<Profile*>(profile)); | 43 return new ExtensionActionManager(static_cast<Profile*>(profile)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 content::BrowserContext* GetBrowserContextToUse( | 46 content::BrowserContext* GetBrowserContextToUse( |
| 47 content::BrowserContext* context) const override { | 47 content::BrowserContext* context) const override { |
| 48 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); | 48 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); |
| 49 } | 49 } |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 ExtensionActionManagerFactory* | 52 ExtensionActionManagerFactory* |
| 53 ExtensionActionManagerFactory::GetInstance() { | 53 ExtensionActionManagerFactory::GetInstance() { |
| 54 return Singleton<ExtensionActionManagerFactory>::get(); | 54 return base::Singleton<ExtensionActionManagerFactory>::get(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 ExtensionActionManager::ExtensionActionManager(Profile* profile) | 59 ExtensionActionManager::ExtensionActionManager(Profile* profile) |
| 60 : profile_(profile), extension_registry_observer_(this) { | 60 : profile_(profile), extension_registry_observer_(this) { |
| 61 CHECK_EQ(profile, profile->GetOriginalProfile()) | 61 CHECK_EQ(profile, profile->GetOriginalProfile()) |
| 62 << "Don't instantiate this with an incognito profile."; | 62 << "Don't instantiate this with an incognito profile."; |
| 63 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 63 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); |
| 64 } | 64 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 profile_); | 163 profile_); |
| 164 } | 164 } |
| 165 | 165 |
| 166 ExtensionAction* ExtensionActionManager::GetExtensionAction( | 166 ExtensionAction* ExtensionActionManager::GetExtensionAction( |
| 167 const Extension& extension) const { | 167 const Extension& extension) const { |
| 168 ExtensionAction* action = GetBrowserAction(extension); | 168 ExtensionAction* action = GetBrowserAction(extension); |
| 169 return action ? action : GetPageAction(extension); | 169 return action ? action : GetPageAction(extension); |
| 170 } | 170 } |
| 171 | 171 |
| 172 } // namespace extensions | 172 } // namespace extensions |
| OLD | NEW |