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

Side by Side Diff: components/search_engines/template_url_service.cc

Issue 1211083006: Move TemplateURLService preferences registration to the component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « components/search_engines/template_url_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/search_engines/template_url_service.h" 5 #include "components/search_engines/template_url_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/guid.h" 13 #include "base/guid.h"
14 #include "base/i18n/case_conversion.h" 14 #include "base/i18n/case_conversion.h"
15 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/profiler/scoped_tracker.h" 18 #include "base/profiler/scoped_tracker.h"
19 #include "base/stl_util.h" 19 #include "base/stl_util.h"
20 #include "base/strings/string_split.h" 20 #include "base/strings/string_split.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "base/time/default_clock.h" 23 #include "base/time/default_clock.h"
24 #include "base/time/time.h" 24 #include "base/time/time.h"
25 #include "components/pref_registry/pref_registry_syncable.h"
25 #include "components/rappor/rappor_service.h" 26 #include "components/rappor/rappor_service.h"
26 #include "components/search_engines/search_engines_pref_names.h" 27 #include "components/search_engines/search_engines_pref_names.h"
27 #include "components/search_engines/search_host_to_urls_map.h" 28 #include "components/search_engines/search_host_to_urls_map.h"
28 #include "components/search_engines/search_terms_data.h" 29 #include "components/search_engines/search_terms_data.h"
29 #include "components/search_engines/template_url.h" 30 #include "components/search_engines/template_url.h"
30 #include "components/search_engines/template_url_prepopulate_data.h" 31 #include "components/search_engines/template_url_prepopulate_data.h"
31 #include "components/search_engines/template_url_service_client.h" 32 #include "components/search_engines/template_url_service_client.h"
32 #include "components/search_engines/template_url_service_observer.h" 33 #include "components/search_engines/template_url_service_observer.h"
33 #include "components/search_engines/util.h" 34 #include "components/search_engines/util.h"
34 #include "components/url_fixer/url_fixer.h" 35 #include "components/url_fixer/url_fixer.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 Init(initializers, count); 236 Init(initializers, count);
236 } 237 }
237 238
238 TemplateURLService::~TemplateURLService() { 239 TemplateURLService::~TemplateURLService() {
239 // |web_data_service_| should be deleted during Shutdown(). 240 // |web_data_service_| should be deleted during Shutdown().
240 DCHECK(!web_data_service_.get()); 241 DCHECK(!web_data_service_.get());
241 STLDeleteElements(&template_urls_); 242 STLDeleteElements(&template_urls_);
242 } 243 }
243 244
244 // static 245 // static
246 void TemplateURLService::RegisterProfilePrefs(
247 user_prefs::PrefRegistrySyncable* registry) {
248 registry->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID,
249 std::string(),
250 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
251 registry->RegisterBooleanPref(prefs::kDefaultSearchProviderEnabled, true);
252 registry->RegisterStringPref(prefs::kDefaultSearchProviderName,
253 std::string());
254 registry->RegisterStringPref(prefs::kDefaultSearchProviderID, std::string());
255 registry->RegisterStringPref(prefs::kDefaultSearchProviderPrepopulateID,
256 std::string());
257 registry->RegisterStringPref(prefs::kDefaultSearchProviderSuggestURL,
258 std::string());
259 registry->RegisterStringPref(prefs::kDefaultSearchProviderSearchURL,
260 std::string());
261 registry->RegisterStringPref(prefs::kDefaultSearchProviderInstantURL,
262 std::string());
263 registry->RegisterStringPref(prefs::kDefaultSearchProviderImageURL,
264 std::string());
265 registry->RegisterStringPref(prefs::kDefaultSearchProviderNewTabURL,
266 std::string());
267 registry->RegisterStringPref(prefs::kDefaultSearchProviderSearchURLPostParams,
268 std::string());
269 registry->RegisterStringPref(
270 prefs::kDefaultSearchProviderSuggestURLPostParams, std::string());
271 registry->RegisterStringPref(
272 prefs::kDefaultSearchProviderInstantURLPostParams, std::string());
273 registry->RegisterStringPref(prefs::kDefaultSearchProviderImageURLPostParams,
274 std::string());
275 registry->RegisterStringPref(prefs::kDefaultSearchProviderKeyword,
276 std::string());
277 registry->RegisterStringPref(prefs::kDefaultSearchProviderIconURL,
278 std::string());
279 registry->RegisterStringPref(prefs::kDefaultSearchProviderEncodings,
280 std::string());
281 registry->RegisterListPref(prefs::kDefaultSearchProviderAlternateURLs);
282 registry->RegisterStringPref(
283 prefs::kDefaultSearchProviderSearchTermsReplacementKey, std::string());
284 }
285
286 // static
245 base::string16 TemplateURLService::CleanUserInputKeyword( 287 base::string16 TemplateURLService::CleanUserInputKeyword(
246 const base::string16& keyword) { 288 const base::string16& keyword) {
247 // Remove the scheme. 289 // Remove the scheme.
248 base::string16 result(base::i18n::ToLower(keyword)); 290 base::string16 result(base::i18n::ToLower(keyword));
249 base::TrimWhitespace(result, base::TRIM_ALL, &result); 291 base::TrimWhitespace(result, base::TRIM_ALL, &result);
250 url::Component scheme_component; 292 url::Component scheme_component;
251 if (url::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(), 293 if (url::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(),
252 static_cast<int>(keyword.length()), 294 static_cast<int>(keyword.length()),
253 &scheme_component)) { 295 &scheme_component)) {
254 // If the scheme isn't "http" or "https", bail. The user isn't trying to 296 // If the scheme isn't "http" or "https", bail. The user isn't trying to
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 2327
2286 if (most_recently_intalled_default) { 2328 if (most_recently_intalled_default) {
2287 base::AutoReset<DefaultSearchChangeOrigin> change_origin( 2329 base::AutoReset<DefaultSearchChangeOrigin> change_origin(
2288 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); 2330 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION);
2289 default_search_manager_.SetExtensionControlledDefaultSearchEngine( 2331 default_search_manager_.SetExtensionControlledDefaultSearchEngine(
2290 most_recently_intalled_default->data()); 2332 most_recently_intalled_default->data());
2291 } else { 2333 } else {
2292 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); 2334 default_search_manager_.ClearExtensionControlledDefaultSearchEngine();
2293 } 2335 }
2294 } 2336 }
OLDNEW
« no previous file with comments | « components/search_engines/template_url_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698