| OLD | NEW |
| 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" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 user_prefs::PrefRegistrySyncable* registry) { | 293 user_prefs::PrefRegistrySyncable* registry) { |
| 294 #if defined(OS_IOS) || defined(OS_ANDROID) | 294 #if defined(OS_IOS) || defined(OS_ANDROID) |
| 295 uint32_t flags = PrefRegistry::NO_REGISTRATION_FLAGS; | 295 uint32_t flags = PrefRegistry::NO_REGISTRATION_FLAGS; |
| 296 #else | 296 #else |
| 297 uint32_t flags = user_prefs::PrefRegistrySyncable::SYNCABLE_PREF; | 297 uint32_t flags = user_prefs::PrefRegistrySyncable::SYNCABLE_PREF; |
| 298 #endif | 298 #endif |
| 299 registry->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID, | 299 registry->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID, |
| 300 std::string(), | 300 std::string(), |
| 301 flags); | 301 flags); |
| 302 registry->RegisterBooleanPref(prefs::kDefaultSearchProviderEnabled, true); | 302 registry->RegisterBooleanPref(prefs::kDefaultSearchProviderEnabled, true); |
| 303 registry->RegisterStringPref(prefs::kDefaultSearchProviderName, | |
| 304 std::string()); | |
| 305 registry->RegisterStringPref(prefs::kDefaultSearchProviderID, std::string()); | |
| 306 registry->RegisterStringPref(prefs::kDefaultSearchProviderPrepopulateID, | |
| 307 std::string()); | |
| 308 registry->RegisterStringPref(prefs::kDefaultSearchProviderSuggestURL, | |
| 309 std::string()); | |
| 310 registry->RegisterStringPref(prefs::kDefaultSearchProviderSearchURL, | |
| 311 std::string()); | |
| 312 registry->RegisterStringPref(prefs::kDefaultSearchProviderInstantURL, | |
| 313 std::string()); | |
| 314 registry->RegisterStringPref(prefs::kDefaultSearchProviderImageURL, | |
| 315 std::string()); | |
| 316 registry->RegisterStringPref(prefs::kDefaultSearchProviderNewTabURL, | |
| 317 std::string()); | |
| 318 registry->RegisterStringPref(prefs::kDefaultSearchProviderSearchURLPostParams, | |
| 319 std::string()); | |
| 320 registry->RegisterStringPref( | |
| 321 prefs::kDefaultSearchProviderSuggestURLPostParams, std::string()); | |
| 322 registry->RegisterStringPref( | |
| 323 prefs::kDefaultSearchProviderInstantURLPostParams, std::string()); | |
| 324 registry->RegisterStringPref(prefs::kDefaultSearchProviderImageURLPostParams, | |
| 325 std::string()); | |
| 326 registry->RegisterStringPref(prefs::kDefaultSearchProviderKeyword, | |
| 327 std::string()); | |
| 328 registry->RegisterStringPref(prefs::kDefaultSearchProviderIconURL, | |
| 329 std::string()); | |
| 330 registry->RegisterStringPref(prefs::kDefaultSearchProviderEncodings, | |
| 331 std::string()); | |
| 332 registry->RegisterListPref(prefs::kDefaultSearchProviderAlternateURLs); | |
| 333 registry->RegisterStringPref( | |
| 334 prefs::kDefaultSearchProviderSearchTermsReplacementKey, std::string()); | |
| 335 } | 303 } |
| 336 | 304 |
| 337 // static | 305 // static |
| 338 base::string16 TemplateURLService::CleanUserInputKeyword( | 306 base::string16 TemplateURLService::CleanUserInputKeyword( |
| 339 const base::string16& keyword) { | 307 const base::string16& keyword) { |
| 340 // Remove the scheme. | 308 // Remove the scheme. |
| 341 base::string16 result(base::i18n::ToLower(keyword)); | 309 base::string16 result(base::i18n::ToLower(keyword)); |
| 342 base::TrimWhitespace(result, base::TRIM_ALL, &result); | 310 base::TrimWhitespace(result, base::TRIM_ALL, &result); |
| 343 url::Component scheme_component; | 311 url::Component scheme_component; |
| 344 if (url::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(), | 312 if (url::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(), |
| (...skipping 2136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2481 const TemplateURLData& data, | 2449 const TemplateURLData& data, |
| 2482 TemplateURL::Type type) { | 2450 TemplateURL::Type type) { |
| 2483 DCHECK_NE(TemplateURL::NORMAL, type); | 2451 DCHECK_NE(TemplateURL::NORMAL, type); |
| 2484 for (const auto& turl : template_urls_) { | 2452 for (const auto& turl : template_urls_) { |
| 2485 if (turl->type() == type && | 2453 if (turl->type() == type && |
| 2486 TemplateURL::MatchesData(turl.get(), &data, search_terms_data())) | 2454 TemplateURL::MatchesData(turl.get(), &data, search_terms_data())) |
| 2487 return turl.get(); | 2455 return turl.get(); |
| 2488 } | 2456 } |
| 2489 return nullptr; | 2457 return nullptr; |
| 2490 } | 2458 } |
| OLD | NEW |