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 "ios/chrome/browser/autocomplete/in_memory_url_index_factory.h" | 5 #include "ios/chrome/browser/autocomplete/in_memory_url_index_factory.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "components/keyed_service/core/service_access_type.h" | 10 #include "components/keyed_service/core/service_access_type.h" |
11 #include "components/keyed_service/ios/browser_state_dependency_manager.h" | 11 #include "components/keyed_service/ios/browser_state_dependency_manager.h" |
12 #include "components/omnibox/browser/in_memory_url_index.h" | 12 #include "components/omnibox/browser/in_memory_url_index.h" |
13 #include "components/prefs/pref_service.h" | |
14 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" | 13 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" |
15 #include "ios/chrome/browser/browser_state/browser_state_otr_helper.h" | 14 #include "ios/chrome/browser/browser_state/browser_state_otr_helper.h" |
16 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 15 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
17 #include "ios/chrome/browser/chrome_url_constants.h" | 16 #include "ios/chrome/browser/chrome_url_constants.h" |
18 #include "ios/chrome/browser/history/history_service_factory.h" | 17 #include "ios/chrome/browser/history/history_service_factory.h" |
19 #include "ios/chrome/browser/pref_names.h" | |
20 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" | 18 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
21 #include "ios/web/public/web_thread.h" | 19 #include "ios/web/public/web_thread.h" |
22 | 20 |
23 namespace ios { | 21 namespace ios { |
24 | 22 |
25 namespace { | 23 namespace { |
26 | 24 |
27 scoped_ptr<KeyedService> BuildInMemoryURLIndex(web::BrowserState* context) { | 25 scoped_ptr<KeyedService> BuildInMemoryURLIndex(web::BrowserState* context) { |
28 ios::ChromeBrowserState* browser_state = | 26 ios::ChromeBrowserState* browser_state = |
29 ios::ChromeBrowserState::FromBrowserState(context); | 27 ios::ChromeBrowserState::FromBrowserState(context); |
30 | 28 |
31 SchemeSet schemes_to_whilelist; | 29 SchemeSet schemes_to_whilelist; |
32 schemes_to_whilelist.insert(kChromeUIScheme); | 30 schemes_to_whilelist.insert(kChromeUIScheme); |
33 | 31 |
34 // Do not force creation of the HistoryService if saving history is disabled. | 32 // Do not force creation of the HistoryService if saving history is disabled. |
35 scoped_ptr<InMemoryURLIndex> in_memory_url_index(new InMemoryURLIndex( | 33 scoped_ptr<InMemoryURLIndex> in_memory_url_index(new InMemoryURLIndex( |
36 ios::BookmarkModelFactory::GetForBrowserState(browser_state), | 34 ios::BookmarkModelFactory::GetForBrowserState(browser_state), |
37 ios::HistoryServiceFactory::GetForBrowserState( | 35 ios::HistoryServiceFactory::GetForBrowserState( |
38 browser_state, ServiceAccessType::IMPLICIT_ACCESS), | 36 browser_state, ServiceAccessType::IMPLICIT_ACCESS), |
39 ios::TemplateURLServiceFactory::GetForBrowserState(browser_state), | 37 ios::TemplateURLServiceFactory::GetForBrowserState(browser_state), |
40 web::WebThread::GetBlockingPool(), browser_state->GetStatePath(), | 38 web::WebThread::GetBlockingPool(), browser_state->GetStatePath(), |
41 browser_state->GetPrefs()->GetString(prefs::kAcceptLanguages), | |
42 schemes_to_whilelist)); | 39 schemes_to_whilelist)); |
43 in_memory_url_index->Init(); | 40 in_memory_url_index->Init(); |
44 return std::move(in_memory_url_index); | 41 return std::move(in_memory_url_index); |
45 } | 42 } |
46 | 43 |
47 } // namespace | 44 } // namespace |
48 | 45 |
49 // static | 46 // static |
50 InMemoryURLIndex* InMemoryURLIndexFactory::GetForBrowserState( | 47 InMemoryURLIndex* InMemoryURLIndexFactory::GetForBrowserState( |
51 ios::ChromeBrowserState* browser_state) { | 48 ios::ChromeBrowserState* browser_state) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 web::BrowserState* InMemoryURLIndexFactory::GetBrowserStateToUse( | 80 web::BrowserState* InMemoryURLIndexFactory::GetBrowserStateToUse( |
84 web::BrowserState* context) const { | 81 web::BrowserState* context) const { |
85 return GetBrowserStateRedirectedInIncognito(context); | 82 return GetBrowserStateRedirectedInIncognito(context); |
86 } | 83 } |
87 | 84 |
88 bool InMemoryURLIndexFactory::ServiceIsNULLWhileTesting() const { | 85 bool InMemoryURLIndexFactory::ServiceIsNULLWhileTesting() const { |
89 return true; | 86 return true; |
90 } | 87 } |
91 | 88 |
92 } // namespace ios | 89 } // namespace ios |
OLD | NEW |