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

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

Issue 2799083003: Replace manual GoogleURLTracker update request with call to utility function. (Closed)
Patch Set: Created 3 years, 8 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 | « chrome/browser/profile_resetter/profile_resetter.cc ('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"
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 i < actions.added_engines.end(); 664 i < actions.added_engines.end();
665 ++i) { 665 ++i) {
666 AddNoNotify(base::MakeUnique<TemplateURL>(*i), true); 666 AddNoNotify(base::MakeUnique<TemplateURL>(*i), true);
667 } 667 }
668 668
669 base::AutoReset<DefaultSearchChangeOrigin> change_origin( 669 base::AutoReset<DefaultSearchChangeOrigin> change_origin(
670 &dsp_change_origin_, DSP_CHANGE_PROFILE_RESET); 670 &dsp_change_origin_, DSP_CHANGE_PROFILE_RESET);
671 671
672 default_search_manager_.ClearUserSelectedDefaultSearchEngine(); 672 default_search_manager_.ClearUserSelectedDefaultSearchEngine();
673 673
674 if (!default_search_provider_) { 674 if (default_search_provider_) {
675 // If the default search provider came from a user pref we would have been
676 // notified of the new (fallback-provided) value in
677 // ClearUserSelectedDefaultSearchEngine() above. Since we are here, the
678 // value was presumably originally a fallback value (which may have been
679 // repaired).
680 DefaultSearchManager::Source source;
681 const TemplateURLData* new_dse =
682 default_search_manager_.GetDefaultSearchEngine(&source);
683 // ApplyDefaultSearchChange will notify observers once it is done.
684 ApplyDefaultSearchChange(new_dse, source);
685 } else {
686 // Set fallback engine as user selected, because repair is considered a user 675 // Set fallback engine as user selected, because repair is considered a user
687 // action and we are expected to sync new fallback engine to other devices. 676 // action and we are expected to sync new fallback engine to other devices.
688 const TemplateURLData* fallback_engine_data = 677 const TemplateURLData* fallback_engine_data =
689 default_search_manager_.GetFallbackSearchEngine(); 678 default_search_manager_.GetFallbackSearchEngine();
690 if (fallback_engine_data) { 679 if (fallback_engine_data) {
691 TemplateURL* fallback_engine = 680 TemplateURL* fallback_engine =
692 FindPrepopulatedTemplateURL(fallback_engine_data->prepopulate_id); 681 FindPrepopulatedTemplateURL(fallback_engine_data->prepopulate_id);
693 // The fallback engine is created from built-in/override data that should 682 // The fallback engine is created from built-in/override data that should
694 // always have a prepopulate ID, so this engine should always exist after 683 // always have a prepopulate ID, so this engine should always exist after
695 // a repair. 684 // a repair.
696 DCHECK(fallback_engine); 685 DCHECK(fallback_engine);
697 // Write the fallback engine's GUID to prefs, which will cause 686 // Write the fallback engine's GUID to prefs, which will cause
698 // OnSyncedDefaultSearchProviderGUIDChanged() to set it as the new 687 // OnSyncedDefaultSearchProviderGUIDChanged() to set it as the new
699 // user-selected engine. 688 // user-selected engine.
700 prefs_->SetString(prefs::kSyncedDefaultSearchProviderGUID, 689 prefs_->SetString(prefs::kSyncedDefaultSearchProviderGUID,
701 fallback_engine->sync_guid()); 690 fallback_engine->sync_guid());
702 } 691 }
703 NotifyObservers(); 692 NotifyObservers();
693 RequestGoogleURLTrackerServerCheckIfNecessary();
vasilii 2017/04/06 09:33:17 There is a behavior change here. ProfileResetter c
Peter Kasting 2017/04/06 09:43:26 I missed that. Why did the old code set force=tru
694 } else {
695 // If the default search provider came from a user pref we would have been
696 // notified of the new (fallback-provided) value in
697 // ClearUserSelectedDefaultSearchEngine() above. Since we are here, the
698 // value was presumably originally a fallback value (which may have been
699 // repaired).
700 DefaultSearchManager::Source source;
701 const TemplateURLData* new_dse =
702 default_search_manager_.GetDefaultSearchEngine(&source);
703 // ApplyDefaultSearchChange will notify observers once it is done.
704 ApplyDefaultSearchChange(new_dse, source);
704 } 705 }
705 } 706 }
706 707
707 void TemplateURLService::AddObserver(TemplateURLServiceObserver* observer) { 708 void TemplateURLService::AddObserver(TemplateURLServiceObserver* observer) {
708 model_observers_.AddObserver(observer); 709 model_observers_.AddObserver(observer);
709 } 710 }
710 711
711 void TemplateURLService::RemoveObserver(TemplateURLServiceObserver* observer) { 712 void TemplateURLService::RemoveObserver(TemplateURLServiceObserver* observer) {
712 model_observers_.RemoveObserver(observer); 713 model_observers_.RemoveObserver(observer);
713 } 714 }
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 if (keyword_to_template_url.find(template_url->keyword()) != 2515 if (keyword_to_template_url.find(template_url->keyword()) !=
2515 keyword_to_template_url.end()) { 2516 keyword_to_template_url.end()) {
2516 return true; 2517 return true;
2517 } 2518 }
2518 keyword_to_template_url[template_url->keyword()] = template_url.get(); 2519 keyword_to_template_url[template_url->keyword()] = template_url.get();
2519 } 2520 }
2520 } 2521 }
2521 return false; 2522 return false;
2522 } 2523 }
2523 #endif 2524 #endif
OLDNEW
« no previous file with comments | « chrome/browser/profile_resetter/profile_resetter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698