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
14namespace predictors {
15
16// static
17AutocompleteActionPredictor* AutocompleteActionPredictorFactory::GetForProfile(
18    Profile* profile) {
19  return static_cast<AutocompleteActionPredictor*>(
20      GetInstance()->GetServiceForBrowserContext(profile, true));
21}
22
23// static
24AutocompleteActionPredictorFactory*
25    AutocompleteActionPredictorFactory::GetInstance() {
26  return Singleton<AutocompleteActionPredictorFactory>::get();
27}
28
29AutocompleteActionPredictorFactory::AutocompleteActionPredictorFactory()
30    : BrowserContextKeyedServiceFactory(
31        "AutocompleteActionPredictor",
32        BrowserContextDependencyManager::GetInstance()) {
33  DependsOn(HistoryServiceFactory::GetInstance());
34  DependsOn(PredictorDatabaseFactory::GetInstance());
35}
36
37AutocompleteActionPredictorFactory::~AutocompleteActionPredictorFactory() {}
38
39content::BrowserContext*
40AutocompleteActionPredictorFactory::GetBrowserContextToUse(
41    content::BrowserContext* context) const {
42  return chrome::GetBrowserContextOwnInstanceInIncognito(context);
43}
44
45KeyedService* AutocompleteActionPredictorFactory::BuildServiceInstanceFor(
46    content::BrowserContext* profile) const {
47  return new AutocompleteActionPredictor(static_cast<Profile*>(profile));
48}
49
50}  // namespace predictors
51