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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 // We don't have a TemplateURL with keyword. We still may not allow this | 388 // We don't have a TemplateURL with keyword. We still may not allow this |
389 // keyword if there's evidence we may have created this keyword before and | 389 // keyword if there's evidence we may have created this keyword before and |
390 // the user renamed it (because, for instance, the keyword is a common word | 390 // the user renamed it (because, for instance, the keyword is a common word |
391 // that may interfere with search queries). An easy heuristic for this is | 391 // that may interfere with search queries). An easy heuristic for this is |
392 // whether the user has a TemplateURL that has been manually modified (e.g., | 392 // whether the user has a TemplateURL that has been manually modified (e.g., |
393 // renamed) connected to the same host. | 393 // renamed) connected to the same host. |
394 return !url.is_valid() || url.host().empty() || | 394 return !url.is_valid() || url.host().empty() || |
395 CanAddAutogeneratedKeywordForHost(url.host()); | 395 CanAddAutogeneratedKeywordForHost(url.host()); |
396 } | 396 } |
397 | 397 |
398 bool TemplateURLService::ShowInPrepopulatedList(const TemplateURL* t_url) { | |
399 return (t_url->prepopulate_id() > 0 || t_url->created_by_policy()) && | |
400 t_url->SupportsReplacement(search_terms_data()); | |
401 } | |
402 | |
398 bool TemplateURLService::ShowInDefaultList(const TemplateURL* t_url) { | 403 bool TemplateURLService::ShowInDefaultList(const TemplateURL* t_url) { |
399 return (t_url == default_search_provider_ || t_url->prepopulate_id() > 0 || | 404 return (t_url == default_search_provider_ && |
400 t_url->created_by_policy()) && | 405 t_url->SupportsReplacement(search_terms_data())) || |
Peter Kasting
2016/11/23 21:30:27
I don't think we should explicitly check SupportsR
ltian
2016/11/29 02:44:03
Done.
| |
401 t_url->SupportsReplacement(search_terms_data()); | 406 ShowInPrepopulatedList(t_url); |
402 } | 407 } |
403 | 408 |
404 void TemplateURLService::AddMatchingKeywords( | 409 void TemplateURLService::AddMatchingKeywords( |
405 const base::string16& prefix, | 410 const base::string16& prefix, |
406 bool supports_replacement_only, | 411 bool supports_replacement_only, |
407 TURLsAndMeaningfulLengths* matches) { | 412 TURLsAndMeaningfulLengths* matches) { |
408 AddMatchingKeywordsHelper( | 413 AddMatchingKeywordsHelper( |
409 keyword_to_turl_and_length_, prefix, supports_replacement_only, matches); | 414 keyword_to_turl_and_length_, prefix, supports_replacement_only, matches); |
410 } | 415 } |
411 | 416 |
(...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2475 | 2480 |
2476 if (most_recently_intalled_default) { | 2481 if (most_recently_intalled_default) { |
2477 base::AutoReset<DefaultSearchChangeOrigin> change_origin( | 2482 base::AutoReset<DefaultSearchChangeOrigin> change_origin( |
2478 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); | 2483 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); |
2479 default_search_manager_.SetExtensionControlledDefaultSearchEngine( | 2484 default_search_manager_.SetExtensionControlledDefaultSearchEngine( |
2480 most_recently_intalled_default->data()); | 2485 most_recently_intalled_default->data()); |
2481 } else { | 2486 } else { |
2482 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); | 2487 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); |
2483 } | 2488 } |
2484 } | 2489 } |
OLD | NEW |