| 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 ? initial_default_search_provider_.get() | 434 ? initial_default_search_provider_.get() |
| 435 : nullptr; | 435 : nullptr; |
| 436 } | 436 } |
| 437 | 437 |
| 438 TemplateURL* TemplateURLService::GetTemplateURLForHost( | 438 TemplateURL* TemplateURLService::GetTemplateURLForHost( |
| 439 const std::string& host) { | 439 const std::string& host) { |
| 440 if (loaded_) | 440 if (loaded_) |
| 441 return provider_map_->GetTemplateURLForHost(host); | 441 return provider_map_->GetTemplateURLForHost(host); |
| 442 TemplateURL* initial_dsp = initial_default_search_provider_.get(); | 442 TemplateURL* initial_dsp = initial_default_search_provider_.get(); |
| 443 return (initial_dsp && | 443 return (initial_dsp && |
| 444 (initial_dsp->GenerateSearchURL(search_terms_data()).host() == host)) | 444 (initial_dsp->GenerateSearchURL(search_terms_data()).host_piece() == |
| 445 host)) |
| 445 ? initial_dsp | 446 ? initial_dsp |
| 446 : nullptr; | 447 : nullptr; |
| 447 } | 448 } |
| 448 | 449 |
| 449 TemplateURL* TemplateURLService::Add( | 450 TemplateURL* TemplateURLService::Add( |
| 450 std::unique_ptr<TemplateURL> template_url) { | 451 std::unique_ptr<TemplateURL> template_url) { |
| 451 KeywordWebDataService::BatchModeScoper scoper(web_data_service_.get()); | 452 KeywordWebDataService::BatchModeScoper scoper(web_data_service_.get()); |
| 452 TemplateURL* template_url_ptr = AddNoNotify(std::move(template_url), true); | 453 TemplateURL* template_url_ptr = AddNoNotify(std::move(template_url), true); |
| 453 if (template_url_ptr) | 454 if (template_url_ptr) |
| 454 NotifyObservers(); | 455 NotifyObservers(); |
| (...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2473 | 2474 |
| 2474 if (most_recently_intalled_default) { | 2475 if (most_recently_intalled_default) { |
| 2475 base::AutoReset<DefaultSearchChangeOrigin> change_origin( | 2476 base::AutoReset<DefaultSearchChangeOrigin> change_origin( |
| 2476 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); | 2477 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); |
| 2477 default_search_manager_.SetExtensionControlledDefaultSearchEngine( | 2478 default_search_manager_.SetExtensionControlledDefaultSearchEngine( |
| 2478 most_recently_intalled_default->data()); | 2479 most_recently_intalled_default->data()); |
| 2479 } else { | 2480 } else { |
| 2480 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); | 2481 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); |
| 2481 } | 2482 } |
| 2482 } | 2483 } |
| OLD | NEW |