instant_service_factory.cc revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
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.
4
5#include "chrome/browser/search/instant_service_factory.h"
6
7#include "chrome/browser/profiles/incognito_helpers.h"
8#include "chrome/browser/profiles/profile.h"
9#include "chrome/browser/search/instant_service.h"
10#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
11
12// static
13InstantService* InstantServiceFactory::GetForProfile(Profile* profile) {
14  return static_cast<InstantService*>(
15      GetInstance()->GetServiceForBrowserContext(profile, true));
16}
17
18// static
19InstantServiceFactory* InstantServiceFactory::GetInstance() {
20  return Singleton<InstantServiceFactory>::get();
21}
22
23InstantServiceFactory::InstantServiceFactory()
24    : BrowserContextKeyedServiceFactory(
25        "InstantService",
26        BrowserContextDependencyManager::GetInstance()) {
27  // No dependencies.
28}
29
30InstantServiceFactory::~InstantServiceFactory() {
31}
32
33content::BrowserContext* InstantServiceFactory::GetBrowserContextToUse(
34    content::BrowserContext* context) const {
35  return chrome::GetBrowserContextOwnInstanceInIncognito(context);
36}
37
38BrowserContextKeyedService* InstantServiceFactory::BuildServiceInstanceFor(
39    content::BrowserContext* profile) const {
40  return new InstantService(static_cast<Profile*>(profile));
41}
42