Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / search / instant_service_factory.cc
blobfc2160b700a75eed7c575f89094416a4689344e2
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/search/instant_service_factory.h"
7 #include "chrome/browser/history/top_sites_factory.h"
8 #include "chrome/browser/profiles/incognito_helpers.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search/instant_service.h"
11 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 #include "chrome/browser/themes/theme_service_factory.h"
13 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 #include "components/search/search.h"
16 // static
17 InstantService* InstantServiceFactory::GetForProfile(Profile* profile) {
18 if (!search::IsInstantExtendedAPIEnabled())
19 return NULL;
21 return static_cast<InstantService*>(
22 GetInstance()->GetServiceForBrowserContext(profile, true));
25 // static
26 InstantServiceFactory* InstantServiceFactory::GetInstance() {
27 return Singleton<InstantServiceFactory>::get();
30 InstantServiceFactory::InstantServiceFactory()
31 : BrowserContextKeyedServiceFactory(
32 "InstantService",
33 BrowserContextDependencyManager::GetInstance()) {
34 DependsOn(TemplateURLServiceFactory::GetInstance());
35 #if defined(ENABLE_THEMES)
36 DependsOn(ThemeServiceFactory::GetInstance());
37 #endif
38 DependsOn(TopSitesFactory::GetInstance());
41 InstantServiceFactory::~InstantServiceFactory() {
44 content::BrowserContext* InstantServiceFactory::GetBrowserContextToUse(
45 content::BrowserContext* context) const {
46 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
49 KeyedService* InstantServiceFactory::BuildServiceInstanceFor(
50 content::BrowserContext* profile) const {
51 return search::IsInstantExtendedAPIEnabled()
52 ? new InstantService(static_cast<Profile*>(profile))
53 : NULL;