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

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

Issue 3161038: Nothing is ever added to hosts_to_delete_, so this code does nothing useful. (Closed)
Patch Set: Created 10 years, 4 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/search_engines/template_url_model.h ('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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_model.h" 5 #include "chrome/browser/search_engines/template_url_model.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.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/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 if (keyword_result.builtin_keyword_version != resource_keyword_version) { 558 if (keyword_result.builtin_keyword_version != resource_keyword_version) {
559 MergeEnginesFromPrepopulateData(); 559 MergeEnginesFromPrepopulateData();
560 service_->SetBuiltinKeywordVersion(resource_keyword_version); 560 service_->SetBuiltinKeywordVersion(resource_keyword_version);
561 } 561 }
562 562
563 // Always save the default search provider to prefs. That way we don't have to 563 // Always save the default search provider to prefs. That way we don't have to
564 // worry about it being out of sync. 564 // worry about it being out of sync.
565 if (default_search_provider_) 565 if (default_search_provider_)
566 SaveDefaultSearchProviderToPrefs(default_search_provider_); 566 SaveDefaultSearchProviderToPrefs(default_search_provider_);
567 567
568 // Delete any hosts that were deleted before we finished loading.
569 for (std::vector<std::wstring>::iterator i = hosts_to_delete_.begin();
570 i != hosts_to_delete_.end(); ++i) {
571 DeleteGeneratedKeywordsMatchingHost(*i);
572 }
573 hosts_to_delete_.clear();
574
575 // Index any visits that occurred before we finished loading. 568 // Index any visits that occurred before we finished loading.
576 for (size_t i = 0; i < visits_to_add_.size(); ++i) 569 for (size_t i = 0; i < visits_to_add_.size(); ++i)
577 UpdateKeywordSearchTermsForURL(visits_to_add_[i]); 570 UpdateKeywordSearchTermsForURL(visits_to_add_[i]);
578 visits_to_add_.clear(); 571 visits_to_add_.clear();
579 572
580 loaded_ = true; 573 loaded_ = true;
581 574
582 FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_, 575 FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_,
583 OnTemplateURLModelChanged()); 576 OnTemplateURLModelChanged());
584 577
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 const std::vector<const TemplateURL*>& urls) { 747 const std::vector<const TemplateURL*>& urls) {
755 // Add mappings for the new items. 748 // Add mappings for the new items.
756 for (TemplateURLVector::const_iterator i = urls.begin(); i != urls.end(); 749 for (TemplateURLVector::const_iterator i = urls.begin(); i != urls.end();
757 ++i) { 750 ++i) {
758 next_id_ = std::max(next_id_, (*i)->id()); 751 next_id_ = std::max(next_id_, (*i)->id());
759 AddToMaps(*i); 752 AddToMaps(*i);
760 template_urls_.push_back(*i); 753 template_urls_.push_back(*i);
761 } 754 }
762 } 755 }
763 756
764 void TemplateURLModel::DeleteGeneratedKeywordsMatchingHost(
765 const std::wstring& host) {
766 const std::wstring host_slash = host + L"/";
767 // Iterate backwards as we may end up removing multiple entries.
768 for (int i = static_cast<int>(template_urls_.size()) - 1; i >= 0; --i) {
769 if (CanReplace(template_urls_[i]) &&
770 (template_urls_[i]->keyword() == host ||
771 template_urls_[i]->keyword().compare(0, host_slash.length(),
772 host_slash) == 0)) {
773 Remove(template_urls_[i]);
774 }
775 }
776 }
777
778 void TemplateURLModel::NotifyLoaded() { 757 void TemplateURLModel::NotifyLoaded() {
779 NotificationService::current()->Notify( 758 NotificationService::current()->Notify(
780 NotificationType::TEMPLATE_URL_MODEL_LOADED, 759 NotificationType::TEMPLATE_URL_MODEL_LOADED,
781 Source<TemplateURLModel>(this), 760 Source<TemplateURLModel>(this),
782 NotificationService::NoDetails()); 761 NotificationService::NoDetails());
783 762
784 for (size_t i = 0; i < pending_extension_ids_.size(); ++i) { 763 for (size_t i = 0; i < pending_extension_ids_.size(); ++i) {
785 Extension* extension = profile_->GetExtensionsService()-> 764 Extension* extension = profile_->GetExtensionsService()->
786 GetExtensionById(pending_extension_ids_[i], true); 765 GetExtensionById(pending_extension_ids_[i], true);
787 if (extension) 766 if (extension)
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 AddToMaps(t_url); 1091 AddToMaps(t_url);
1113 something_changed = true; 1092 something_changed = true;
1114 } 1093 }
1115 } 1094 }
1116 1095
1117 if (something_changed && loaded_) { 1096 if (something_changed && loaded_) {
1118 FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_, 1097 FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_,
1119 OnTemplateURLModelChanged()); 1098 OnTemplateURLModelChanged());
1120 } 1099 }
1121 } 1100 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_model.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698