• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/predictors/autocomplete_action_predictor_factory.h"
6 
7 #include "chrome/browser/history/history_service_factory.h"
8 #include "chrome/browser/predictors/autocomplete_action_predictor.h"
9 #include "chrome/browser/predictors/predictor_database_factory.h"
10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 
14 namespace predictors {
15 
16 // static
GetForProfile(Profile * profile)17 AutocompleteActionPredictor* AutocompleteActionPredictorFactory::GetForProfile(
18     Profile* profile) {
19   return static_cast<AutocompleteActionPredictor*>(
20       GetInstance()->GetServiceForBrowserContext(profile, true));
21 }
22 
23 // static
24 AutocompleteActionPredictorFactory*
GetInstance()25     AutocompleteActionPredictorFactory::GetInstance() {
26   return Singleton<AutocompleteActionPredictorFactory>::get();
27 }
28 
AutocompleteActionPredictorFactory()29 AutocompleteActionPredictorFactory::AutocompleteActionPredictorFactory()
30     : BrowserContextKeyedServiceFactory(
31         "AutocompleteActionPredictor",
32         BrowserContextDependencyManager::GetInstance()) {
33   DependsOn(HistoryServiceFactory::GetInstance());
34   DependsOn(PredictorDatabaseFactory::GetInstance());
35 }
36 
~AutocompleteActionPredictorFactory()37 AutocompleteActionPredictorFactory::~AutocompleteActionPredictorFactory() {}
38 
39 content::BrowserContext*
GetBrowserContextToUse(content::BrowserContext * context) const40 AutocompleteActionPredictorFactory::GetBrowserContextToUse(
41     content::BrowserContext* context) const {
42   return chrome::GetBrowserContextOwnInstanceInIncognito(context);
43 }
44 
BuildServiceInstanceFor(content::BrowserContext * profile) const45 KeyedService* AutocompleteActionPredictorFactory::BuildServiceInstanceFor(
46     content::BrowserContext* profile) const {
47   return new AutocompleteActionPredictor(static_cast<Profile*>(profile));
48 }
49 
50 }  // namespace predictors
51