| 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 ShowInPrepopulatedList(t_url); |
| 401 t_url->SupportsReplacement(search_terms_data()); | |
| 402 } | 406 } |
| 403 | 407 |
| 404 void TemplateURLService::AddMatchingKeywords( | 408 void TemplateURLService::AddMatchingKeywords( |
| 405 const base::string16& prefix, | 409 const base::string16& prefix, |
| 406 bool supports_replacement_only, | 410 bool supports_replacement_only, |
| 407 TURLsAndMeaningfulLengths* matches) { | 411 TURLsAndMeaningfulLengths* matches) { |
| 408 AddMatchingKeywordsHelper( | 412 AddMatchingKeywordsHelper( |
| 409 keyword_to_turl_and_length_, prefix, supports_replacement_only, matches); | 413 keyword_to_turl_and_length_, prefix, supports_replacement_only, matches); |
| 410 } | 414 } |
| 411 | 415 |
| (...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2475 | 2479 |
| 2476 if (most_recently_intalled_default) { | 2480 if (most_recently_intalled_default) { |
| 2477 base::AutoReset<DefaultSearchChangeOrigin> change_origin( | 2481 base::AutoReset<DefaultSearchChangeOrigin> change_origin( |
| 2478 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); | 2482 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); |
| 2479 default_search_manager_.SetExtensionControlledDefaultSearchEngine( | 2483 default_search_manager_.SetExtensionControlledDefaultSearchEngine( |
| 2480 most_recently_intalled_default->data()); | 2484 most_recently_intalled_default->data()); |
| 2481 } else { | 2485 } else { |
| 2482 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); | 2486 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); |
| 2483 } | 2487 } |
| 2484 } | 2488 } |
| OLD | NEW |