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

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

Issue 1192373002: Prepare AutocompleteController for componentization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@componentize_zero_suggest_provider
Patch Set: Response to review 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chrome_autocomplete_provider_client.h" 5 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 8 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
9 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" 9 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
10 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h"
10 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" 11 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h"
11 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h" 12 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h"
12 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h" 13 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h"
13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
14 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/history/history_service_factory.h" 16 #include "chrome/browser/history/history_service_factory.h"
16 #include "chrome/browser/history/top_sites_factory.h" 17 #include "chrome/browser/history/top_sites_factory.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/search_engines/template_url_service_factory.h" 19 #include "chrome/browser/search_engines/template_url_service_factory.h"
19 #include "chrome/browser/sync/profile_sync_service.h" 20 #include "chrome/browser/sync/profile_sync_service.h"
20 #include "chrome/browser/sync/profile_sync_service_factory.h" 21 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "components/history/core/browser/history_service.h" 23 #include "components/history/core/browser/history_service.h"
23 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
24 25
26 #if defined(ENABLE_EXTENSIONS)
27 #include "chrome/browser/autocomplete/keyword_extensions_delegate_impl.h"
28 #endif
29
25 ChromeAutocompleteProviderClient::ChromeAutocompleteProviderClient( 30 ChromeAutocompleteProviderClient::ChromeAutocompleteProviderClient(
26 Profile* profile) 31 Profile* profile)
27 : profile_(profile), 32 : profile_(profile),
28 scheme_classifier_(profile), 33 scheme_classifier_(profile),
29 search_terms_data_(profile_) { 34 search_terms_data_(profile_) {
30 } 35 }
31 36
32 ChromeAutocompleteProviderClient::~ChromeAutocompleteProviderClient() { 37 ChromeAutocompleteProviderClient::~ChromeAutocompleteProviderClient() {
33 } 38 }
34 39
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 71 }
67 72
68 history::URLDatabase* ChromeAutocompleteProviderClient::GetInMemoryDatabase() { 73 history::URLDatabase* ChromeAutocompleteProviderClient::GetInMemoryDatabase() {
69 history::HistoryService* history_service = GetHistoryService(); 74 history::HistoryService* history_service = GetHistoryService();
70 75
71 // This method is called in unit test contexts where the HistoryService isn't 76 // This method is called in unit test contexts where the HistoryService isn't
72 // loaded. 77 // loaded.
73 return history_service ? history_service->InMemoryDatabase() : NULL; 78 return history_service ? history_service->InMemoryDatabase() : NULL;
74 } 79 }
75 80
81 InMemoryURLIndex* ChromeAutocompleteProviderClient::GetInMemoryURLIndex() {
82 return InMemoryURLIndexFactory::GetForProfile(profile_);
83 }
84
76 TemplateURLService* ChromeAutocompleteProviderClient::GetTemplateURLService() { 85 TemplateURLService* ChromeAutocompleteProviderClient::GetTemplateURLService() {
77 return TemplateURLServiceFactory::GetForProfile(profile_); 86 return TemplateURLServiceFactory::GetForProfile(profile_);
78 } 87 }
79 88
80 const TemplateURLService* 89 const TemplateURLService*
81 ChromeAutocompleteProviderClient::GetTemplateURLService() const { 90 ChromeAutocompleteProviderClient::GetTemplateURLService() const {
82 return TemplateURLServiceFactory::GetForProfile(profile_); 91 return TemplateURLServiceFactory::GetForProfile(profile_);
83 } 92 }
84 93
85 const 94 const
86 SearchTermsData& ChromeAutocompleteProviderClient::GetSearchTermsData() const { 95 SearchTermsData& ChromeAutocompleteProviderClient::GetSearchTermsData() const {
87 return search_terms_data_; 96 return search_terms_data_;
88 } 97 }
89 98
90 scoped_refptr<ShortcutsBackend> 99 scoped_refptr<ShortcutsBackend>
91 ChromeAutocompleteProviderClient::GetShortcutsBackend() { 100 ChromeAutocompleteProviderClient::GetShortcutsBackend() {
92 return ShortcutsBackendFactory::GetForProfile(profile_); 101 return ShortcutsBackendFactory::GetForProfile(profile_);
93 } 102 }
94 103
95 scoped_refptr<ShortcutsBackend> 104 scoped_refptr<ShortcutsBackend>
96 ChromeAutocompleteProviderClient::GetShortcutsBackendIfExists() { 105 ChromeAutocompleteProviderClient::GetShortcutsBackendIfExists() {
97 return ShortcutsBackendFactory::GetForProfileIfExists(profile_); 106 return ShortcutsBackendFactory::GetForProfileIfExists(profile_);
98 } 107 }
99 108
109 scoped_ptr<KeywordExtensionsDelegate>
110 ChromeAutocompleteProviderClient::GetKeywordExtensionsDelegate(
111 KeywordProvider* keyword_provider) {
112 #if defined(ENABLE_EXTENSIONS)
113 return make_scoped_ptr(
114 new KeywordExtensionsDelegateImpl(profile_, keyword_provider));
115 #else
116 return nullptr;
117 #endif
118 }
119
100 std::string ChromeAutocompleteProviderClient::GetAcceptLanguages() const { 120 std::string ChromeAutocompleteProviderClient::GetAcceptLanguages() const {
101 return profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); 121 return profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
102 } 122 }
103 123
104 bool ChromeAutocompleteProviderClient::IsOffTheRecord() const { 124 bool ChromeAutocompleteProviderClient::IsOffTheRecord() const {
105 return profile_->IsOffTheRecord(); 125 return profile_->IsOffTheRecord();
106 } 126 }
107 127
108 bool ChromeAutocompleteProviderClient::SearchSuggestEnabled() const { 128 bool ChromeAutocompleteProviderClient::SearchSuggestEnabled() const {
109 return profile_->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled); 129 return profile_->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 image_service->Prefetch(url); 170 image_service->Prefetch(url);
151 } 171 }
152 172
153 void ChromeAutocompleteProviderClient::OnAutocompleteControllerResultReady( 173 void ChromeAutocompleteProviderClient::OnAutocompleteControllerResultReady(
154 AutocompleteController* controller) { 174 AutocompleteController* controller) {
155 content::NotificationService::current()->Notify( 175 content::NotificationService::current()->Notify(
156 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, 176 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
157 content::Source<AutocompleteController>(controller), 177 content::Source<AutocompleteController>(controller),
158 content::NotificationService::NoDetails()); 178 content::NotificationService::NoDetails());
159 } 179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698