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.
5 #include "chrome/browser/extensions/extension_toolbar_model_factory.h"
7 #include "chrome/browser/extensions/extension_toolbar_model.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "components/keyed_service/content/browser_context_dependency_manager.h"
10 #include "extensions/browser/extension_prefs.h"
11 #include "extensions/browser/extension_prefs_factory.h"
12 #include "extensions/browser/extensions_browser_client.h"
14 namespace extensions
{
17 ExtensionToolbarModel
* ExtensionToolbarModelFactory::GetForProfile(
19 return static_cast<ExtensionToolbarModel
*>(
20 GetInstance()->GetServiceForBrowserContext(profile
, true));
24 ExtensionToolbarModelFactory
* ExtensionToolbarModelFactory::GetInstance() {
25 return Singleton
<ExtensionToolbarModelFactory
>::get();
28 ExtensionToolbarModelFactory::ExtensionToolbarModelFactory()
29 : BrowserContextKeyedServiceFactory(
30 "ExtensionToolbarModel",
31 BrowserContextDependencyManager::GetInstance()) {
32 DependsOn(ExtensionPrefsFactory::GetInstance());
35 ExtensionToolbarModelFactory::~ExtensionToolbarModelFactory() {}
37 KeyedService
* ExtensionToolbarModelFactory::BuildServiceInstanceFor(
38 content::BrowserContext
* context
) const {
39 return new ExtensionToolbarModel(
40 Profile::FromBrowserContext(context
),
41 ExtensionPrefsFactory::GetForBrowserContext(context
));
44 content::BrowserContext
* ExtensionToolbarModelFactory::GetBrowserContextToUse(
45 content::BrowserContext
* context
) const {
46 return ExtensionsBrowserClient::Get()->GetOriginalContext(context
);
49 bool ExtensionToolbarModelFactory::ServiceIsCreatedWithBrowserContext() const {
53 bool ExtensionToolbarModelFactory::ServiceIsNULLWhileTesting() const {
57 } // namespace extensions