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

Side by Side Diff: chrome/browser/search_engines/template_url_service.cc

Issue 10065016: [protector] Refactoring of --no-protector code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/protector/protector_service.cc ('k') | chrome/browser/ui/browser_init.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/search_engines/template_url_service.h" 5 #include "chrome/browser/search_engines/template_url_service.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/i18n/case_conversion.h" 10 #include "base/i18n/case_conversion.h"
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 647
648 // This initializes provider_map_ which should be done before 648 // This initializes provider_map_ which should be done before
649 // calling UpdateKeywordSearchTermsForURL. 649 // calling UpdateKeywordSearchTermsForURL.
650 ChangeToLoadedState(); 650 ChangeToLoadedState();
651 651
652 // Index any visits that occurred before we finished loading. 652 // Index any visits that occurred before we finished loading.
653 for (size_t i = 0; i < visits_to_add_.size(); ++i) 653 for (size_t i = 0; i < visits_to_add_.size(); ++i)
654 UpdateKeywordSearchTermsForURL(visits_to_add_[i]); 654 UpdateKeywordSearchTermsForURL(visits_to_add_[i]);
655 visits_to_add_.clear(); 655 visits_to_add_.clear();
656 656
657 if (new_resource_keyword_version && service_.get()) 657 if (new_resource_keyword_version)
658 service_->SetBuiltinKeywordVersion(new_resource_keyword_version); 658 service_->SetBuiltinKeywordVersion(new_resource_keyword_version);
659 659
660 #if defined(ENABLE_PROTECTOR_SERVICE) 660 #if defined(ENABLE_PROTECTOR_SERVICE)
661 // Don't do anything if the default search provider has been changed since the 661 // Don't do anything if the default search provider has been changed since the
662 // check at the beginning (overridden by Sync). 662 // check at the beginning (overridden by Sync).
663 if (is_default_search_hijacked && 663 if (is_default_search_hijacked &&
664 default_search_provider_ == hijacked_default_search_provider) { 664 default_search_provider_ == hijacked_default_search_provider) {
665 // The histograms should be reported even when Protector is disabled. 665 // The histograms should be reported even when Protector is disabled.
666 scoped_ptr<protector::BaseSettingChange> change( 666 scoped_ptr<protector::BaseSettingChange> change(
667 protector::CreateDefaultSearchProviderChange( 667 protector::CreateDefaultSearchProviderChange(
668 hijacked_default_search_provider, 668 hijacked_default_search_provider,
669 backup_default_search_provider.release())); 669 backup_default_search_provider.release()));
670 if (protector::IsEnabled()) { 670 if (protector::IsEnabled()) {
671 protector::ProtectorService* protector_service = 671 protector::ProtectorService* protector_service =
672 protector::ProtectorServiceFactory::GetForProfile(profile()); 672 protector::ProtectorServiceFactory::GetForProfile(profile());
673 DCHECK(protector_service); 673 DCHECK(protector_service);
674 protector_service->ShowChange(change.release()); 674 protector_service->ShowChange(change.release());
675 } else { 675 } else {
676 // Protector is turned off: set the current default search to itself 676 // Protector is turned off: set the current default search to itself
677 // to update the backup and sign it. Otherwise, change will be reported 677 // to update the backup and sign it. Otherwise, change will be reported
678 // every time when keywords are loaded until a search provider is added. 678 // every time when keywords are loaded until a search provider is added.
679 // Note that this saves the default search provider to prefs. 679 service_->SetDefaultSearchProvider(default_search_provider_);
680 SetDefaultSearchProviderNoNotify(default_search_provider_);
681 } 680 }
682 } 681 }
683 #endif 682 #endif
684 683
685 if (!is_default_search_managed_) { 684 if (!is_default_search_managed_) {
686 UMA_HISTOGRAM_BOOLEAN("Search.HasDefaultSearchProvider", 685 UMA_HISTOGRAM_BOOLEAN("Search.HasDefaultSearchProvider",
687 default_search_provider_ != NULL); 686 default_search_provider_ != NULL);
688 // Ensure that default search provider exists. See http://crbug.com/116952. 687 // Ensure that default search provider exists. See http://crbug.com/116952.
689 if (!default_search_provider_) 688 if (!default_search_provider_)
690 SetDefaultSearchProviderNoNotify(FindNewDefaultSearchProvider()); 689 SetDefaultSearchProviderNoNotify(FindNewDefaultSearchProvider());
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 // TODO(mpcomplete): If we allow editing extension keywords, then those 1970 // TODO(mpcomplete): If we allow editing extension keywords, then those
1972 // should be persisted to disk and synced. 1971 // should be persisted to disk and synced.
1973 if (template_url->sync_guid().empty() && 1972 if (template_url->sync_guid().empty() &&
1974 !template_url->IsExtensionKeyword()) { 1973 !template_url->IsExtensionKeyword()) {
1975 template_url->data_.sync_guid = guid::GenerateGUID(); 1974 template_url->data_.sync_guid = guid::GenerateGUID();
1976 if (service_.get()) 1975 if (service_.get())
1977 service_->UpdateKeyword(*template_url); 1976 service_->UpdateKeyword(*template_url);
1978 } 1977 }
1979 } 1978 }
1980 } 1979 }
OLDNEW
« no previous file with comments | « chrome/browser/protector/protector_service.cc ('k') | chrome/browser/ui/browser_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698