Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / chrome / browser / autocomplete / in_memory_url_index_factory.cc
blob25d3a2af233faeeb0bd0650d098e1120874df911
1 // Copyright 2015 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.
5 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h"
7 #include "base/memory/singleton.h"
8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
10 #include "chrome/browser/history/history_service_factory.h"
11 #include "chrome/browser/profiles/incognito_helpers.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/pref_names.h"
14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
15 #include "components/keyed_service/core/service_access_type.h"
16 #include "components/omnibox/browser/in_memory_url_index.h"
17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/common/url_constants.h"
20 // static
21 InMemoryURLIndex* InMemoryURLIndexFactory::GetForProfile(Profile* profile) {
22 return static_cast<InMemoryURLIndex*>(
23 GetInstance()->GetServiceForBrowserContext(profile, true));
26 // static
27 InMemoryURLIndexFactory* InMemoryURLIndexFactory::GetInstance() {
28 return base::Singleton<InMemoryURLIndexFactory>::get();
31 InMemoryURLIndexFactory::InMemoryURLIndexFactory()
32 : BrowserContextKeyedServiceFactory(
33 "InMemoryURLIndex",
34 BrowserContextDependencyManager::GetInstance()) {
35 DependsOn(BookmarkModelFactory::GetInstance());
36 DependsOn(HistoryServiceFactory::GetInstance());
39 InMemoryURLIndexFactory::~InMemoryURLIndexFactory() {
42 KeyedService* InMemoryURLIndexFactory::BuildServiceInstanceFor(
43 content::BrowserContext* context) const {
44 // Do not force creation of the HistoryService if saving history is disabled.
45 Profile* profile = Profile::FromBrowserContext(context);
46 SchemeSet chrome_schemes_to_whitelist;
47 chrome_schemes_to_whitelist.insert(content::kChromeUIScheme);
48 InMemoryURLIndex* in_memory_url_index = new InMemoryURLIndex(
49 BookmarkModelFactory::GetForProfile(profile),
50 HistoryServiceFactory::GetForProfile(profile,
51 ServiceAccessType::IMPLICIT_ACCESS),
52 content::BrowserThread::GetBlockingPool(), profile->GetPath(),
53 profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
54 chrome_schemes_to_whitelist);
55 in_memory_url_index->Init();
56 return in_memory_url_index;
59 content::BrowserContext* InMemoryURLIndexFactory::GetBrowserContextToUse(
60 content::BrowserContext* context) const {
61 return chrome::GetBrowserContextRedirectedInIncognito(context);
64 bool InMemoryURLIndexFactory::ServiceIsNULLWhileTesting() const {
65 return true;