OLD | NEW |
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 "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/browser/history/history_service_factory.h" | 9 #include "chrome/browser/history/history_service_factory.h" |
10 #include "chrome/browser/profiles/incognito_helpers.h" | 10 #include "chrome/browser/profiles/incognito_helpers.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/search_engines/template_url_service_factory.h" | 12 #include "chrome/browser/search_engines/template_url_service_factory.h" |
13 #include "chrome/common/pref_names.h" | |
14 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 13 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
15 #include "components/keyed_service/core/service_access_type.h" | 14 #include "components/keyed_service/core/service_access_type.h" |
16 #include "components/omnibox/browser/in_memory_url_index.h" | 15 #include "components/omnibox/browser/in_memory_url_index.h" |
17 #include "components/prefs/pref_service.h" | |
18 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
20 | 18 |
21 // static | 19 // static |
22 InMemoryURLIndex* InMemoryURLIndexFactory::GetForProfile(Profile* profile) { | 20 InMemoryURLIndex* InMemoryURLIndexFactory::GetForProfile(Profile* profile) { |
23 return static_cast<InMemoryURLIndex*>( | 21 return static_cast<InMemoryURLIndex*>( |
24 GetInstance()->GetServiceForBrowserContext(profile, true)); | 22 GetInstance()->GetServiceForBrowserContext(profile, true)); |
25 } | 23 } |
26 | 24 |
27 // static | 25 // static |
(...skipping 18 matching lines...) Expand all Loading... |
46 // 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. |
47 Profile* profile = Profile::FromBrowserContext(context); | 45 Profile* profile = Profile::FromBrowserContext(context); |
48 SchemeSet chrome_schemes_to_whitelist; | 46 SchemeSet chrome_schemes_to_whitelist; |
49 chrome_schemes_to_whitelist.insert(content::kChromeUIScheme); | 47 chrome_schemes_to_whitelist.insert(content::kChromeUIScheme); |
50 InMemoryURLIndex* in_memory_url_index = new InMemoryURLIndex( | 48 InMemoryURLIndex* in_memory_url_index = new InMemoryURLIndex( |
51 BookmarkModelFactory::GetForProfile(profile), | 49 BookmarkModelFactory::GetForProfile(profile), |
52 HistoryServiceFactory::GetForProfile(profile, | 50 HistoryServiceFactory::GetForProfile(profile, |
53 ServiceAccessType::IMPLICIT_ACCESS), | 51 ServiceAccessType::IMPLICIT_ACCESS), |
54 TemplateURLServiceFactory::GetForProfile(profile), | 52 TemplateURLServiceFactory::GetForProfile(profile), |
55 content::BrowserThread::GetBlockingPool(), profile->GetPath(), | 53 content::BrowserThread::GetBlockingPool(), profile->GetPath(), |
56 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), | |
57 chrome_schemes_to_whitelist); | 54 chrome_schemes_to_whitelist); |
58 in_memory_url_index->Init(); | 55 in_memory_url_index->Init(); |
59 return in_memory_url_index; | 56 return in_memory_url_index; |
60 } | 57 } |
61 | 58 |
62 content::BrowserContext* InMemoryURLIndexFactory::GetBrowserContextToUse( | 59 content::BrowserContext* InMemoryURLIndexFactory::GetBrowserContextToUse( |
63 content::BrowserContext* context) const { | 60 content::BrowserContext* context) const { |
64 return chrome::GetBrowserContextRedirectedInIncognito(context); | 61 return chrome::GetBrowserContextRedirectedInIncognito(context); |
65 } | 62 } |
66 | 63 |
67 bool InMemoryURLIndexFactory::ServiceIsNULLWhileTesting() const { | 64 bool InMemoryURLIndexFactory::ServiceIsNULLWhileTesting() const { |
68 return true; | 65 return true; |
69 } | 66 } |
OLD | NEW |