| 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/shortcuts_backend_factory.h" | 5 #include "ios/chrome/browser/autocomplete/shortcuts_backend_factory.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
| 7 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 8 #include "components/keyed_service/core/service_access_type.h" | 9 #include "components/keyed_service/core/service_access_type.h" |
| 9 #include "components/keyed_service/ios/browser_state_dependency_manager.h" | 10 #include "components/keyed_service/ios/browser_state_dependency_manager.h" |
| 10 #include "components/omnibox/browser/shortcuts_backend.h" | 11 #include "components/omnibox/browser/shortcuts_backend.h" |
| 11 #include "components/omnibox/browser/shortcuts_constants.h" | 12 #include "components/omnibox/browser/shortcuts_constants.h" |
| 12 #include "components/prefs/pref_service.h" | 13 #include "components/prefs/pref_service.h" |
| 13 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 14 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 14 #include "ios/chrome/browser/history/history_service_factory.h" | 15 #include "ios/chrome/browser/history/history_service_factory.h" |
| 15 #include "ios/chrome/browser/pref_names.h" | 16 #include "ios/chrome/browser/pref_names.h" |
| 16 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" | 17 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
| 17 #include "ios/chrome/browser/search_engines/ui_thread_search_terms_data.h" | 18 #include "ios/chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 18 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 19 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 19 #include "ios/web/public/web_thread.h" | 20 #include "ios/web/public/web_thread.h" |
| 20 | 21 |
| 21 namespace ios { | 22 namespace ios { |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 scoped_refptr<ShortcutsBackend> CreateShortcutsBackend( | 25 scoped_refptr<ShortcutsBackend> CreateShortcutsBackend( |
| 25 ios::ChromeBrowserState* browser_state, | 26 ios::ChromeBrowserState* browser_state, |
| 26 bool suppress_db) { | 27 bool suppress_db) { |
| 27 scoped_refptr<ShortcutsBackend> shortcuts_backend(new ShortcutsBackend( | 28 scoped_refptr<ShortcutsBackend> shortcuts_backend(new ShortcutsBackend( |
| 28 ios::TemplateURLServiceFactory::GetForBrowserState(browser_state), | 29 ios::TemplateURLServiceFactory::GetForBrowserState(browser_state), |
| 29 make_scoped_ptr(new ios::UIThreadSearchTermsData(browser_state)), | 30 base::WrapUnique(new ios::UIThreadSearchTermsData(browser_state)), |
| 30 ios::HistoryServiceFactory::GetForBrowserState( | 31 ios::HistoryServiceFactory::GetForBrowserState( |
| 31 browser_state, ServiceAccessType::EXPLICIT_ACCESS), | 32 browser_state, ServiceAccessType::EXPLICIT_ACCESS), |
| 32 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB), | 33 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB), |
| 33 browser_state->GetStatePath().Append(kShortcutsDatabaseName), | 34 browser_state->GetStatePath().Append(kShortcutsDatabaseName), |
| 34 suppress_db)); | 35 suppress_db)); |
| 35 return shortcuts_backend->Init() ? shortcuts_backend : nullptr; | 36 return shortcuts_backend->Init() ? shortcuts_backend : nullptr; |
| 36 } | 37 } |
| 37 | 38 |
| 38 } // namespace | 39 } // namespace |
| 39 | 40 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 ios::ChromeBrowserState* browser_state = | 74 ios::ChromeBrowserState* browser_state = |
| 74 ios::ChromeBrowserState::FromBrowserState(context); | 75 ios::ChromeBrowserState::FromBrowserState(context); |
| 75 return CreateShortcutsBackend(browser_state, false /* suppress_db */); | 76 return CreateShortcutsBackend(browser_state, false /* suppress_db */); |
| 76 } | 77 } |
| 77 | 78 |
| 78 bool ShortcutsBackendFactory::ServiceIsNULLWhileTesting() const { | 79 bool ShortcutsBackendFactory::ServiceIsNULLWhileTesting() const { |
| 79 return true; | 80 return true; |
| 80 } | 81 } |
| 81 | 82 |
| 82 } // namespace ios | 83 } // namespace ios |
| OLD | NEW |