Home | History | Annotate | Download | only in search_engines
      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
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
      6 
      7 #include "chrome/browser/profiles/incognito_helpers.h"
      8 #include "chrome/browser/profiles/profile.h"
      9 #include "chrome/browser/search_engines/template_url_fetcher.h"
     10 #include "chrome/browser/search_engines/template_url_service_factory.h"
     11 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
     12 
     13 // static
     14 TemplateURLFetcher* TemplateURLFetcherFactory::GetForProfile(
     15     Profile* profile) {
     16   return static_cast<TemplateURLFetcher*>(
     17       GetInstance()->GetServiceForBrowserContext(profile, true));
     18 }
     19 
     20 // static
     21 TemplateURLFetcherFactory* TemplateURLFetcherFactory::GetInstance() {
     22   return Singleton<TemplateURLFetcherFactory>::get();
     23 }
     24 
     25 // static
     26 void TemplateURLFetcherFactory::ShutdownForProfile(Profile* profile) {
     27   TemplateURLFetcherFactory* factory = GetInstance();
     28   factory->BrowserContextShutdown(profile);
     29   factory->BrowserContextDestroyed(profile);
     30 }
     31 
     32 TemplateURLFetcherFactory::TemplateURLFetcherFactory()
     33     : BrowserContextKeyedServiceFactory(
     34         "TemplateURLFetcher",
     35         BrowserContextDependencyManager::GetInstance()) {
     36   DependsOn(TemplateURLServiceFactory::GetInstance());
     37 }
     38 
     39 TemplateURLFetcherFactory::~TemplateURLFetcherFactory() {
     40 }
     41 
     42 BrowserContextKeyedService* TemplateURLFetcherFactory::BuildServiceInstanceFor(
     43     content::BrowserContext* profile) const {
     44   return new TemplateURLFetcher(static_cast<Profile*>(profile));
     45 }
     46 
     47 content::BrowserContext* TemplateURLFetcherFactory::GetBrowserContextToUse(
     48     content::BrowserContext* context) const {
     49   return chrome::GetBrowserContextRedirectedInIncognito(context);
     50 }
     51