| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/extensions/extension_toolbar_model_factory.h" |
| 6 |
| 7 #include "chrome/browser/extensions/extension_prefs.h" |
| 8 #include "chrome/browser/extensions/extension_prefs_factory.h" |
| 9 #include "chrome/browser/extensions/extension_toolbar_model.h" |
| 10 #include "chrome/browser/profiles/incognito_helpers.h" |
| 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 13 |
| 14 // static |
| 15 ExtensionToolbarModel* ExtensionToolbarModelFactory::GetForProfile( |
| 16 Profile* profile) { |
| 17 return static_cast<ExtensionToolbarModel*>( |
| 18 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 19 } |
| 20 |
| 21 // static |
| 22 ExtensionToolbarModelFactory* ExtensionToolbarModelFactory::GetInstance() { |
| 23 return Singleton<ExtensionToolbarModelFactory>::get(); |
| 24 } |
| 25 |
| 26 ExtensionToolbarModelFactory::ExtensionToolbarModelFactory() |
| 27 : BrowserContextKeyedServiceFactory( |
| 28 "ExtensionToolbarModel", |
| 29 BrowserContextDependencyManager::GetInstance()) { |
| 30 DependsOn(extensions::ExtensionPrefsFactory::GetInstance()); |
| 31 } |
| 32 |
| 33 ExtensionToolbarModelFactory::~ExtensionToolbarModelFactory() {} |
| 34 |
| 35 BrowserContextKeyedService* |
| 36 ExtensionToolbarModelFactory::BuildServiceInstanceFor( |
| 37 content::BrowserContext* context) const { |
| 38 Profile* profile = Profile::FromBrowserContext(context); |
| 39 return new ExtensionToolbarModel( |
| 40 profile, |
| 41 extensions::ExtensionPrefsFactory::GetForProfile(profile)); |
| 42 } |
| 43 |
| 44 content::BrowserContext* ExtensionToolbarModelFactory::GetBrowserContextToUse( |
| 45 content::BrowserContext* context) const { |
| 46 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 47 } |
| 48 |
| 49 bool ExtensionToolbarModelFactory::ServiceIsCreatedWithBrowserContext() const { |
| 50 return true; |
| 51 } |
| 52 |
| 53 bool ExtensionToolbarModelFactory::ServiceIsNULLWhileTesting() const { |
| 54 return true; |
| 55 } |
| OLD | NEW |