Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Side by Side Diff: chrome/browser/autocomplete/in_memory_url_index_factory.cc

Issue 1181353003: Revert of Revert of Abstract //content-level dependencies out of InMemoryURLIndex (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h" 5 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/autocomplete/in_memory_url_index.h" 9 #include "chrome/browser/autocomplete/in_memory_url_index.h"
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
11 #include "chrome/browser/history/history_service_factory.h" 11 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/profiles/incognito_helpers.h" 12 #include "chrome/browser/profiles/incognito_helpers.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "components/keyed_service/content/browser_context_dependency_manager.h" 15 #include "components/keyed_service/content/browser_context_dependency_manager.h"
16 #include "components/keyed_service/core/service_access_type.h" 16 #include "components/keyed_service/core/service_access_type.h"
17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/common/url_constants.h"
17 19
18 // static 20 // static
19 InMemoryURLIndex* InMemoryURLIndexFactory::GetForProfile(Profile* profile) { 21 InMemoryURLIndex* InMemoryURLIndexFactory::GetForProfile(Profile* profile) {
20 return static_cast<InMemoryURLIndex*>( 22 return static_cast<InMemoryURLIndex*>(
21 GetInstance()->GetServiceForBrowserContext(profile, true)); 23 GetInstance()->GetServiceForBrowserContext(profile, true));
22 } 24 }
23 25
24 // static 26 // static
25 InMemoryURLIndexFactory* InMemoryURLIndexFactory::GetInstance() { 27 InMemoryURLIndexFactory* InMemoryURLIndexFactory::GetInstance() {
26 return Singleton<InMemoryURLIndexFactory>::get(); 28 return Singleton<InMemoryURLIndexFactory>::get();
27 } 29 }
28 30
29 InMemoryURLIndexFactory::InMemoryURLIndexFactory() 31 InMemoryURLIndexFactory::InMemoryURLIndexFactory()
30 : BrowserContextKeyedServiceFactory( 32 : BrowserContextKeyedServiceFactory(
31 "InMemoryURLIndex", 33 "InMemoryURLIndex",
32 BrowserContextDependencyManager::GetInstance()) { 34 BrowserContextDependencyManager::GetInstance()) {
33 DependsOn(BookmarkModelFactory::GetInstance()); 35 DependsOn(BookmarkModelFactory::GetInstance());
34 DependsOn(HistoryServiceFactory::GetInstance()); 36 DependsOn(HistoryServiceFactory::GetInstance());
35 } 37 }
36 38
37 InMemoryURLIndexFactory::~InMemoryURLIndexFactory() { 39 InMemoryURLIndexFactory::~InMemoryURLIndexFactory() {
38 } 40 }
39 41
40 KeyedService* InMemoryURLIndexFactory::BuildServiceInstanceFor( 42 KeyedService* InMemoryURLIndexFactory::BuildServiceInstanceFor(
41 content::BrowserContext* context) const { 43 content::BrowserContext* context) const {
42 // Do not force creation of the HistoryService if saving history is disabled. 44 // Do not force creation of the HistoryService if saving history is disabled.
43 Profile* profile = Profile::FromBrowserContext(context); 45 Profile* profile = Profile::FromBrowserContext(context);
46 SchemeSet chrome_schemes_to_whitelist;
47 chrome_schemes_to_whitelist.insert(content::kChromeUIScheme);
44 InMemoryURLIndex* in_memory_url_index = new InMemoryURLIndex( 48 InMemoryURLIndex* in_memory_url_index = new InMemoryURLIndex(
45 BookmarkModelFactory::GetForProfile(profile), 49 BookmarkModelFactory::GetForProfile(profile),
46 HistoryServiceFactory::GetForProfile(profile, 50 HistoryServiceFactory::GetForProfile(profile,
47 ServiceAccessType::IMPLICIT_ACCESS), 51 ServiceAccessType::IMPLICIT_ACCESS),
48 profile->GetPath(), 52 content::BrowserThread::GetBlockingPool(), profile->GetPath(),
49 profile->GetPrefs()->GetString(prefs::kAcceptLanguages)); 53 profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
54 chrome_schemes_to_whitelist);
50 in_memory_url_index->Init(); 55 in_memory_url_index->Init();
51 return in_memory_url_index; 56 return in_memory_url_index;
52 } 57 }
53 58
54 content::BrowserContext* InMemoryURLIndexFactory::GetBrowserContextToUse( 59 content::BrowserContext* InMemoryURLIndexFactory::GetBrowserContextToUse(
55 content::BrowserContext* context) const { 60 content::BrowserContext* context) const {
56 return chrome::GetBrowserContextRedirectedInIncognito(context); 61 return chrome::GetBrowserContextRedirectedInIncognito(context);
57 } 62 }
58 63
59 bool InMemoryURLIndexFactory::ServiceIsNULLWhileTesting() const { 64 bool InMemoryURLIndexFactory::ServiceIsNULLWhileTesting() const {
60 return true; 65 return true;
61 } 66 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/in_memory_url_index.cc ('k') | chrome/browser/autocomplete/in_memory_url_index_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698