Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / history / chrome_history_client_factory.cc
1 // Copyright 2014 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/history/chrome_history_client_factory.h"
6
7 #include "base/memory/singleton.h"
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
9 #include "chrome/browser/history/chrome_history_client.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 // static
15 ChromeHistoryClient* ChromeHistoryClientFactory::GetForProfile(
16     Profile* profile) {
17   return static_cast<ChromeHistoryClient*>(
18       GetInstance()->GetServiceForBrowserContext(profile, true));
19 }
20
21 // static
22 ChromeHistoryClientFactory* ChromeHistoryClientFactory::GetInstance() {
23   return Singleton<ChromeHistoryClientFactory>::get();
24 }
25
26 ChromeHistoryClientFactory::ChromeHistoryClientFactory()
27     : BrowserContextKeyedServiceFactory(
28           "ChromeHistoryClient",
29           BrowserContextDependencyManager::GetInstance()) {
30   DependsOn(BookmarkModelFactory::GetInstance());
31 }
32
33 ChromeHistoryClientFactory::~ChromeHistoryClientFactory() {
34 }
35
36 KeyedService* ChromeHistoryClientFactory::BuildServiceInstanceFor(
37     content::BrowserContext* context) const {
38   Profile* profile = static_cast<Profile*>(context);
39   return new ChromeHistoryClient(BookmarkModelFactory::GetForProfile(profile),
40                                  profile,
41                                  profile->GetTopSites());
42 }
43
44 content::BrowserContext* ChromeHistoryClientFactory::GetBrowserContextToUse(
45     content::BrowserContext* context) const {
46   return chrome::GetBrowserContextRedirectedInIncognito(context);
47 }
48
49 bool ChromeHistoryClientFactory::ServiceIsNULLWhileTesting() const {
50   return true;
51 }