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

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

Issue 338363004: Remove Profile* from TemplateURL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
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 <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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 420
421 // Remove leading "www.". 421 // Remove leading "www.".
422 result = net::StripWWW(result); 422 result = net::StripWWW(result);
423 423
424 // Remove trailing "/". 424 // Remove trailing "/".
425 return (result.length() > 0 && result[result.length() - 1] == '/') ? 425 return (result.length() > 0 && result[result.length() - 1] == '/') ?
426 result.substr(0, result.length() - 1) : result; 426 result.substr(0, result.length() - 1) : result;
427 } 427 }
428 428
429 // static 429 // static
430 GURL TemplateURLService::GenerateSearchURL(TemplateURL* t_url) { 430 GURL TemplateURLService::GenerateSearchURL(
431 DCHECK(t_url);
432 UIThreadSearchTermsData search_terms_data(t_url->profile());
433 return GenerateSearchURLUsingTermsData(t_url, search_terms_data);
434 }
435
436 // static
437 GURL TemplateURLService::GenerateSearchURLUsingTermsData(
438 const TemplateURL* t_url, 431 const TemplateURL* t_url,
439 const SearchTermsData& search_terms_data) { 432 const SearchTermsData& search_terms_data) {
440 DCHECK(t_url); 433 DCHECK(t_url);
441 434
442 const TemplateURLRef& search_ref = t_url->url_ref(); 435 const TemplateURLRef& search_ref = t_url->url_ref();
443 if (!search_ref.IsValid(search_terms_data)) 436 if (!search_ref.IsValid(search_terms_data))
444 return GURL(); 437 return GURL();
445 438
446 if (!search_ref.SupportsReplacement(search_terms_data)) 439 if (!search_ref.SupportsReplacement(search_terms_data))
447 return GURL(t_url->url()); 440 return GURL(t_url->url());
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 605 }
613 606
614 TemplateURL* TemplateURLService::GetTemplateURLForHost( 607 TemplateURL* TemplateURLService::GetTemplateURLForHost(
615 const std::string& host) { 608 const std::string& host) {
616 if (loaded_) { 609 if (loaded_) {
617 TemplateURL* t_url = provider_map_->GetTemplateURLForHost(host); 610 TemplateURL* t_url = provider_map_->GetTemplateURLForHost(host);
618 if (t_url) 611 if (t_url)
619 return t_url; 612 return t_url;
620 } 613 }
621 return (!loaded_ && 614 return (!loaded_ &&
622 initial_default_search_provider_.get() && 615 initial_default_search_provider_.get() &&
623 (GenerateSearchURL(initial_default_search_provider_.get()).host() == 616 (GenerateSearchURL(initial_default_search_provider_.get(),
624 host)) ? initial_default_search_provider_.get() : NULL; 617 search_terms_data()).host() ==
618 host)) ? initial_default_search_provider_.get() : NULL;
Peter Kasting 2014/06/17 21:07:54 Nit: This line has gotten unwieldy. How about thi
hashimoto 2014/06/17 21:58:02 Makes sense. Done.
625 } 619 }
626 620
627 bool TemplateURLService::Add(TemplateURL* template_url) { 621 bool TemplateURLService::Add(TemplateURL* template_url) {
628 WebDataService::KeywordBatchModeScoper keyword_scoper(service_.get()); 622 WebDataService::KeywordBatchModeScoper keyword_scoper(service_.get());
629 if (!AddNoNotify(template_url, true)) 623 if (!AddNoNotify(template_url, true))
630 return false; 624 return false;
631 NotifyObservers(); 625 NotifyObservers();
632 return true; 626 return true;
633 } 627 }
634 628
635 void TemplateURLService::AddAndSetProfile(TemplateURL* template_url,
636 Profile* profile) {
637 template_url->profile_ = profile;
638 Add(template_url);
639 }
640
641 void TemplateURLService::AddWithOverrides(TemplateURL* template_url, 629 void TemplateURLService::AddWithOverrides(TemplateURL* template_url,
642 const base::string16& short_name, 630 const base::string16& short_name,
643 const base::string16& keyword, 631 const base::string16& keyword,
644 const std::string& url) { 632 const std::string& url) {
645 DCHECK(!keyword.empty()); 633 DCHECK(!keyword.empty());
646 DCHECK(!url.empty()); 634 DCHECK(!url.empty());
647 template_url->data_.short_name = short_name; 635 template_url->data_.short_name = short_name;
648 template_url->data_.SetKeyword(keyword); 636 template_url->data_.SetKeyword(keyword);
649 template_url->SetURL(url); 637 template_url->SetURL(url);
650 Add(template_url); 638 Add(template_url);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 base::Time created_before) { 697 base::Time created_before) {
710 GURL o(origin.GetOrigin()); 698 GURL o(origin.GetOrigin());
711 bool should_notify = false; 699 bool should_notify = false;
712 WebDataService::KeywordBatchModeScoper keyword_scoper(service_.get()); 700 WebDataService::KeywordBatchModeScoper keyword_scoper(service_.get());
713 for (size_t i = 0; i < template_urls_.size();) { 701 for (size_t i = 0; i < template_urls_.size();) {
714 if (template_urls_[i]->date_created() >= created_after && 702 if (template_urls_[i]->date_created() >= created_after &&
715 (created_before.is_null() || 703 (created_before.is_null() ||
716 template_urls_[i]->date_created() < created_before) && 704 template_urls_[i]->date_created() < created_before) &&
717 CanReplace(template_urls_[i]) && 705 CanReplace(template_urls_[i]) &&
718 (o.is_empty() || 706 (o.is_empty() ||
719 GenerateSearchURL(template_urls_[i]).GetOrigin() == o)) { 707 GenerateSearchURL(template_urls_[i],
708 search_terms_data()).GetOrigin() == o)) {
720 RemoveNoNotify(template_urls_[i]); 709 RemoveNoNotify(template_urls_[i]);
721 should_notify = true; 710 should_notify = true;
722 } else { 711 } else {
723 ++i; 712 ++i;
724 } 713 }
725 } 714 }
726 if (should_notify) 715 if (should_notify)
727 NotifyObservers(); 716 NotifyObservers();
728 } 717 }
729 718
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 840
852 // Remove items. 841 // Remove items.
853 for (std::vector<TemplateURL*>::iterator i = actions.removed_engines.begin(); 842 for (std::vector<TemplateURL*>::iterator i = actions.removed_engines.begin();
854 i < actions.removed_engines.end(); ++i) 843 i < actions.removed_engines.end(); ++i)
855 RemoveNoNotify(*i); 844 RemoveNoNotify(*i);
856 845
857 // Edit items. 846 // Edit items.
858 for (EditedEngines::iterator i(actions.edited_engines.begin()); 847 for (EditedEngines::iterator i(actions.edited_engines.begin());
859 i < actions.edited_engines.end(); ++i) { 848 i < actions.edited_engines.end(); ++i) {
860 UIThreadSearchTermsData search_terms_data(profile()); 849 UIThreadSearchTermsData search_terms_data(profile());
861 TemplateURL new_values(profile(), i->second); 850 TemplateURL new_values(i->second);
862 UpdateNoNotify(i->first, new_values, search_terms_data); 851 UpdateNoNotify(i->first, new_values, search_terms_data);
863 } 852 }
864 853
865 // Add items. 854 // Add items.
866 for (std::vector<TemplateURLData>::const_iterator i = 855 for (std::vector<TemplateURLData>::const_iterator i =
867 actions.added_engines.begin(); 856 actions.added_engines.begin();
868 i < actions.added_engines.end(); 857 i < actions.added_engines.end();
869 ++i) { 858 ++i) {
870 AddNoNotify(new TemplateURL(profile_, *i), true); 859 AddNoNotify(new TemplateURL(*i), true);
871 } 860 }
872 861
873 base::AutoReset<DefaultSearchChangeOrigin> change_origin( 862 base::AutoReset<DefaultSearchChangeOrigin> change_origin(
874 &dsp_change_origin_, DSP_CHANGE_PROFILE_RESET); 863 &dsp_change_origin_, DSP_CHANGE_PROFILE_RESET);
875 864
876 default_search_manager_.ClearUserSelectedDefaultSearchEngine(); 865 default_search_manager_.ClearUserSelectedDefaultSearchEngine();
877 866
878 if (!default_search_provider_) { 867 if (!default_search_provider_) {
879 // If the default search provider came from a user pref we would have been 868 // If the default search provider came from a user pref we would have been
880 // notified of the new (fallback-provided) value in 869 // notified of the new (fallback-provided) value in
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 // not ideal, but it prevents a far more severe bug where the default is 1086 // not ideal, but it prevents a far more severe bug where the default is
1098 // unexpectedly swapped to something else. The user can safely delete 1087 // unexpectedly swapped to something else. The user can safely delete
1099 // the extra entry again later, if they choose. Most users who do not 1088 // the extra entry again later, if they choose. Most users who do not
1100 // look at the search engines UI will not notice this. 1089 // look at the search engines UI will not notice this.
1101 // Note that we append a special character to the end of the keyword in 1090 // Note that we append a special character to the end of the keyword in
1102 // an attempt to avoid a ping-poinging situation where receiving clients 1091 // an attempt to avoid a ping-poinging situation where receiving clients
1103 // may try to continually delete the resurrected entry. 1092 // may try to continually delete the resurrected entry.
1104 base::string16 updated_keyword = UniquifyKeyword(*existing_turl, true); 1093 base::string16 updated_keyword = UniquifyKeyword(*existing_turl, true);
1105 TemplateURLData data(existing_turl->data()); 1094 TemplateURLData data(existing_turl->data());
1106 data.SetKeyword(updated_keyword); 1095 data.SetKeyword(updated_keyword);
1107 TemplateURL new_turl(existing_turl->profile(), data); 1096 TemplateURL new_turl(data);
1108 UIThreadSearchTermsData search_terms_data(existing_turl->profile()); 1097 if (UpdateNoNotify(existing_turl, new_turl, search_terms_data()))
1109 if (UpdateNoNotify(existing_turl, new_turl, search_terms_data))
1110 NotifyObservers(); 1098 NotifyObservers();
1111 1099
1112 syncer::SyncData sync_data = CreateSyncDataFromTemplateURL(new_turl); 1100 syncer::SyncData sync_data = CreateSyncDataFromTemplateURL(new_turl);
1113 new_changes.push_back(syncer::SyncChange(FROM_HERE, 1101 new_changes.push_back(syncer::SyncChange(FROM_HERE,
1114 syncer::SyncChange::ACTION_ADD, 1102 syncer::SyncChange::ACTION_ADD,
1115 sync_data)); 1103 sync_data));
1116 // Ignore the delete attempt. This means we never end up resetting the 1104 // Ignore the delete attempt. This means we never end up resetting the
1117 // default search provider due to an ACTION_DELETE from sync. 1105 // default search provider due to an ACTION_DELETE from sync.
1118 continue; 1106 continue;
1119 } 1107 }
(...skipping 10 matching lines...) Expand all
1130 if (existing_keyword_turl) { 1118 if (existing_keyword_turl) {
1131 // Resolve any conflicts so we can safely add the new entry. 1119 // Resolve any conflicts so we can safely add the new entry.
1132 ResolveSyncKeywordConflict(turl.get(), existing_keyword_turl, 1120 ResolveSyncKeywordConflict(turl.get(), existing_keyword_turl,
1133 &new_changes); 1121 &new_changes);
1134 } 1122 }
1135 base::AutoReset<DefaultSearchChangeOrigin> change_origin( 1123 base::AutoReset<DefaultSearchChangeOrigin> change_origin(
1136 &dsp_change_origin_, DSP_CHANGE_SYNC_ADD); 1124 &dsp_change_origin_, DSP_CHANGE_SYNC_ADD);
1137 // Force the local ID to kInvalidTemplateURLID so we can add it. 1125 // Force the local ID to kInvalidTemplateURLID so we can add it.
1138 TemplateURLData data(turl->data()); 1126 TemplateURLData data(turl->data());
1139 data.id = kInvalidTemplateURLID; 1127 data.id = kInvalidTemplateURLID;
1140 TemplateURL* added = new TemplateURL(profile_, data); 1128 TemplateURL* added = new TemplateURL(data);
1141 if (Add(added)) 1129 if (Add(added))
1142 MaybeUpdateDSEAfterSync(added); 1130 MaybeUpdateDSEAfterSync(added);
1143 } else if (iter->change_type() == syncer::SyncChange::ACTION_UPDATE) { 1131 } else if (iter->change_type() == syncer::SyncChange::ACTION_UPDATE) {
1144 if (!existing_turl) { 1132 if (!existing_turl) {
1145 error = sync_error_factory_->CreateAndUploadError( 1133 error = sync_error_factory_->CreateAndUploadError(
1146 FROM_HERE, 1134 FROM_HERE,
1147 "ProcessSyncChanges failed on ChangeType ACTION_UPDATE"); 1135 "ProcessSyncChanges failed on ChangeType ACTION_UPDATE");
1148 continue; 1136 continue;
1149 } 1137 }
1150 if (existing_keyword_turl && (existing_keyword_turl != existing_turl)) { 1138 if (existing_keyword_turl && (existing_keyword_turl != existing_turl)) {
1151 // Resolve any conflicts with other entries so we can safely update the 1139 // Resolve any conflicts with other entries so we can safely update the
1152 // keyword. 1140 // keyword.
1153 ResolveSyncKeywordConflict(turl.get(), existing_keyword_turl, 1141 ResolveSyncKeywordConflict(turl.get(), existing_keyword_turl,
1154 &new_changes); 1142 &new_changes);
1155 } 1143 }
1156 UIThreadSearchTermsData search_terms_data(existing_turl->profile()); 1144 if (UpdateNoNotify(existing_turl, *turl, search_terms_data())) {
1157 if (UpdateNoNotify(existing_turl, *turl, search_terms_data)) {
1158 NotifyObservers(); 1145 NotifyObservers();
1159 MaybeUpdateDSEAfterSync(existing_turl); 1146 MaybeUpdateDSEAfterSync(existing_turl);
1160 } 1147 }
1161 } else { 1148 } else {
1162 // We've unexpectedly received an ACTION_INVALID. 1149 // We've unexpectedly received an ACTION_INVALID.
1163 error = sync_error_factory_->CreateAndUploadError( 1150 error = sync_error_factory_->CreateAndUploadError(
1164 FROM_HERE, 1151 FROM_HERE,
1165 "ProcessSyncChanges received an ACTION_INVALID"); 1152 "ProcessSyncChanges received an ACTION_INVALID");
1166 } 1153 }
1167 } 1154 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 DCHECK(IsFromSync(local_turl, sync_data_map)); 1233 DCHECK(IsFromSync(local_turl, sync_data_map));
1247 // This local search engine is already synced. If the timestamp differs 1234 // This local search engine is already synced. If the timestamp differs
1248 // from Sync, we need to update locally or to the cloud. Note that if the 1235 // from Sync, we need to update locally or to the cloud. Note that if the
1249 // timestamps are equal, we touch neither. 1236 // timestamps are equal, we touch neither.
1250 if (sync_turl->last_modified() > local_turl->last_modified()) { 1237 if (sync_turl->last_modified() > local_turl->last_modified()) {
1251 // We've received an update from Sync. We should replace all synced 1238 // We've received an update from Sync. We should replace all synced
1252 // fields in the local TemplateURL. Note that this includes the 1239 // fields in the local TemplateURL. Note that this includes the
1253 // TemplateURLID and the TemplateURL may have to be reparsed. This 1240 // TemplateURLID and the TemplateURL may have to be reparsed. This
1254 // also makes the local data's last_modified timestamp equal to Sync's, 1241 // also makes the local data's last_modified timestamp equal to Sync's,
1255 // avoiding an Update on the next MergeData call. 1242 // avoiding an Update on the next MergeData call.
1256 UIThreadSearchTermsData search_terms_data(local_turl->profile()); 1243 if (UpdateNoNotify(local_turl, *sync_turl, search_terms_data()))
1257 if (UpdateNoNotify(local_turl, *sync_turl, search_terms_data))
1258 NotifyObservers(); 1244 NotifyObservers();
1259 merge_result.set_num_items_modified( 1245 merge_result.set_num_items_modified(
1260 merge_result.num_items_modified() + 1); 1246 merge_result.num_items_modified() + 1);
1261 } else if (sync_turl->last_modified() < local_turl->last_modified()) { 1247 } else if (sync_turl->last_modified() < local_turl->last_modified()) {
1262 // Otherwise, we know we have newer data, so update Sync with our 1248 // Otherwise, we know we have newer data, so update Sync with our
1263 // data fields. 1249 // data fields.
1264 new_changes.push_back( 1250 new_changes.push_back(
1265 syncer::SyncChange(FROM_HERE, 1251 syncer::SyncChange(FROM_HERE,
1266 syncer::SyncChange::ACTION_UPDATE, 1252 syncer::SyncChange::ACTION_UPDATE,
1267 local_data_map[local_turl->sync_guid()])); 1253 local_data_map[local_turl->sync_guid()]));
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 bool deduped = DeDupeEncodings(&data.input_encodings); 1432 bool deduped = DeDupeEncodings(&data.input_encodings);
1447 data.date_created = base::Time::FromInternalValue(specifics.date_created()); 1433 data.date_created = base::Time::FromInternalValue(specifics.date_created());
1448 data.last_modified = base::Time::FromInternalValue(specifics.last_modified()); 1434 data.last_modified = base::Time::FromInternalValue(specifics.last_modified());
1449 data.prepopulate_id = specifics.prepopulate_id(); 1435 data.prepopulate_id = specifics.prepopulate_id();
1450 data.sync_guid = specifics.sync_guid(); 1436 data.sync_guid = specifics.sync_guid();
1451 data.alternate_urls.clear(); 1437 data.alternate_urls.clear();
1452 for (int i = 0; i < specifics.alternate_urls_size(); ++i) 1438 for (int i = 0; i < specifics.alternate_urls_size(); ++i)
1453 data.alternate_urls.push_back(specifics.alternate_urls(i)); 1439 data.alternate_urls.push_back(specifics.alternate_urls(i));
1454 data.search_terms_replacement_key = specifics.search_terms_replacement_key(); 1440 data.search_terms_replacement_key = specifics.search_terms_replacement_key();
1455 1441
1456 TemplateURL* turl = new TemplateURL(profile, data); 1442 TemplateURL* turl = new TemplateURL(data);
1457 UIThreadSearchTermsData search_terms_data(profile); 1443 UIThreadSearchTermsData search_terms_data(profile);
1458 // If this TemplateURL matches a built-in prepopulated template URL, it's 1444 // If this TemplateURL matches a built-in prepopulated template URL, it's
1459 // possible that sync is trying to modify fields that should not be touched. 1445 // possible that sync is trying to modify fields that should not be touched.
1460 // Revert these fields to the built-in values. 1446 // Revert these fields to the built-in values.
1461 UpdateTemplateURLIfPrepopulated(turl, profile); 1447 UpdateTemplateURLIfPrepopulated(turl, profile);
1462 DCHECK_NE(TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION, turl->GetType()); 1448 DCHECK_NE(TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION, turl->GetType());
1463 if (reset_keyword || deduped) { 1449 if (reset_keyword || deduped) {
1464 if (reset_keyword) 1450 if (reset_keyword)
1465 turl->ResetKeywordIfNecessary(search_terms_data, true); 1451 turl->ResetKeywordIfNecessary(search_terms_data, true);
1466 syncer::SyncData sync_data = CreateSyncDataFromTemplateURL(*turl); 1452 syncer::SyncData sync_data = CreateSyncDataFromTemplateURL(*turl);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 DCHECK(initializers[i].keyword); 1540 DCHECK(initializers[i].keyword);
1555 DCHECK(initializers[i].url); 1541 DCHECK(initializers[i].url);
1556 DCHECK(initializers[i].content); 1542 DCHECK(initializers[i].content);
1557 1543
1558 // TemplateURLService ends up owning the TemplateURL, don't try and free 1544 // TemplateURLService ends up owning the TemplateURL, don't try and free
1559 // it. 1545 // it.
1560 TemplateURLData data; 1546 TemplateURLData data;
1561 data.short_name = base::UTF8ToUTF16(initializers[i].content); 1547 data.short_name = base::UTF8ToUTF16(initializers[i].content);
1562 data.SetKeyword(base::UTF8ToUTF16(initializers[i].keyword)); 1548 data.SetKeyword(base::UTF8ToUTF16(initializers[i].keyword));
1563 data.SetURL(initializers[i].url); 1549 data.SetURL(initializers[i].url);
1564 TemplateURL* template_url = new TemplateURL(profile_, data); 1550 TemplateURL* template_url = new TemplateURL(data);
1565 AddNoNotify(template_url, true); 1551 AddNoNotify(template_url, true);
1566 1552
1567 // Set the first provided identifier to be the default. 1553 // Set the first provided identifier to be the default.
1568 if (i == 0) 1554 if (i == 0)
1569 default_search_manager_.SetUserSelectedDefaultSearchEngine(data); 1555 default_search_manager_.SetUserSelectedDefaultSearchEngine(data);
1570 } 1556 }
1571 } 1557 }
1572 1558
1573 // Request a server check for the correct Google URL if Google is the 1559 // Request a server check for the correct Google URL if Google is the
1574 // default search engine and not in headless mode. 1560 // default search engine and not in headless mode.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 if (best_fallback) 1597 if (best_fallback)
1612 keyword_to_template_map_[keyword] = best_fallback; 1598 keyword_to_template_map_[keyword] = best_fallback;
1613 else 1599 else
1614 keyword_to_template_map_.erase(keyword); 1600 keyword_to_template_map_.erase(keyword);
1615 } 1601 }
1616 1602
1617 if (!template_url->sync_guid().empty()) 1603 if (!template_url->sync_guid().empty())
1618 guid_to_template_map_.erase(template_url->sync_guid()); 1604 guid_to_template_map_.erase(template_url->sync_guid());
1619 // |provider_map_| is only initialized after loading has completed. 1605 // |provider_map_| is only initialized after loading has completed.
1620 if (loaded_) { 1606 if (loaded_) {
1621 UIThreadSearchTermsData search_terms_data(template_url->profile()); 1607 provider_map_->Remove(template_url, search_terms_data());
1622 provider_map_->Remove(template_url, search_terms_data);
1623 } 1608 }
1624 } 1609 }
1625 1610
1626 void TemplateURLService::AddToMaps(TemplateURL* template_url) { 1611 void TemplateURLService::AddToMaps(TemplateURL* template_url) {
1627 bool template_url_is_omnibox_api = 1612 bool template_url_is_omnibox_api =
1628 template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION; 1613 template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION;
1629 const base::string16& keyword = template_url->keyword(); 1614 const base::string16& keyword = template_url->keyword();
1630 KeywordToTemplateMap::const_iterator i = 1615 KeywordToTemplateMap::const_iterator i =
1631 keyword_to_template_map_.find(keyword); 1616 keyword_to_template_map_.find(keyword);
1632 if (i == keyword_to_template_map_.end()) { 1617 if (i == keyword_to_template_map_.end()) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 return; 1807 return;
1823 1808
1824 size_t default_search_index; 1809 size_t default_search_index;
1825 ScopedVector<TemplateURLData> prepopulated_urls = 1810 ScopedVector<TemplateURLData> prepopulated_urls =
1826 TemplateURLPrepopulateData::GetPrepopulatedEngines( 1811 TemplateURLPrepopulateData::GetPrepopulatedEngines(
1827 profile ? profile->GetPrefs() : NULL, &default_search_index); 1812 profile ? profile->GetPrefs() : NULL, &default_search_index);
1828 1813
1829 for (size_t i = 0; i < prepopulated_urls.size(); ++i) { 1814 for (size_t i = 0; i < prepopulated_urls.size(); ++i) {
1830 if (prepopulated_urls[i]->prepopulate_id == prepopulate_id) { 1815 if (prepopulated_urls[i]->prepopulate_id == prepopulate_id) {
1831 MergeIntoPrepopulatedEngineData(template_url, prepopulated_urls[i]); 1816 MergeIntoPrepopulatedEngineData(template_url, prepopulated_urls[i]);
1832 template_url->CopyFrom(TemplateURL(profile, *prepopulated_urls[i])); 1817 template_url->CopyFrom(TemplateURL(*prepopulated_urls[i]));
1833 } 1818 }
1834 } 1819 }
1835 } 1820 }
1836 1821
1837 void TemplateURLService::MaybeUpdateDSEAfterSync(TemplateURL* synced_turl) { 1822 void TemplateURLService::MaybeUpdateDSEAfterSync(TemplateURL* synced_turl) {
1838 if (GetPrefs() && 1823 if (GetPrefs() &&
1839 (synced_turl->sync_guid() == 1824 (synced_turl->sync_guid() ==
1840 GetPrefs()->GetString(prefs::kSyncedDefaultSearchProviderGUID))) { 1825 GetPrefs()->GetString(prefs::kSyncedDefaultSearchProviderGUID))) {
1841 default_search_manager_.SetUserSelectedDefaultSearchEngine( 1826 default_search_manager_.SetUserSelectedDefaultSearchEngine(
1842 synced_turl->data()); 1827 synced_turl->data());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 history::SOURCE_BROWSED, false); 1890 history::SOURCE_BROWSED, false);
1906 } 1891 }
1907 1892
1908 void TemplateURLService::GoogleBaseURLChanged(const GURL& old_base_url) { 1893 void TemplateURLService::GoogleBaseURLChanged(const GURL& old_base_url) {
1909 WebDataService::KeywordBatchModeScoper keyword_scoper(service_.get()); 1894 WebDataService::KeywordBatchModeScoper keyword_scoper(service_.get());
1910 bool something_changed = false; 1895 bool something_changed = false;
1911 for (TemplateURLVector::iterator i(template_urls_.begin()); 1896 for (TemplateURLVector::iterator i(template_urls_.begin());
1912 i != template_urls_.end(); ++i) { 1897 i != template_urls_.end(); ++i) {
1913 TemplateURL* t_url = *i; 1898 TemplateURL* t_url = *i;
1914 if (t_url->HasGoogleBaseURLs(search_terms_data())) { 1899 if (t_url->HasGoogleBaseURLs(search_terms_data())) {
1915 TemplateURL updated_turl(t_url->profile(), t_url->data()); 1900 TemplateURL updated_turl(t_url->data());
1916 updated_turl.ResetKeywordIfNecessary(search_terms_data(), false); 1901 updated_turl.ResetKeywordIfNecessary(search_terms_data(), false);
1917 KeywordToTemplateMap::const_iterator existing_entry = 1902 KeywordToTemplateMap::const_iterator existing_entry =
1918 keyword_to_template_map_.find(updated_turl.keyword()); 1903 keyword_to_template_map_.find(updated_turl.keyword());
1919 if ((existing_entry != keyword_to_template_map_.end()) && 1904 if ((existing_entry != keyword_to_template_map_.end()) &&
1920 (existing_entry->second != t_url)) { 1905 (existing_entry->second != t_url)) {
1921 // The new autogenerated keyword conflicts with another TemplateURL. 1906 // The new autogenerated keyword conflicts with another TemplateURL.
1922 // Overwrite it if it's replaceable; otherwise, leave |t_url| using its 1907 // Overwrite it if it's replaceable; otherwise, leave |t_url| using its
1923 // current keyword. (This will not prevent |t_url| from auto-updating 1908 // current keyword. (This will not prevent |t_url| from auto-updating
1924 // the keyword in the future if the conflicting TemplateURL disappears.) 1909 // the keyword in the future if the conflicting TemplateURL disappears.)
1925 // Note that we must still update |t_url| in this case, or the 1910 // Note that we must still update |t_url| in this case, or the
1926 // |provider_map_| will not be updated correctly. 1911 // |provider_map_| will not be updated correctly.
1927 if (CanReplace(existing_entry->second)) 1912 if (CanReplace(existing_entry->second))
1928 RemoveNoNotify(existing_entry->second); 1913 RemoveNoNotify(existing_entry->second);
1929 else 1914 else
1930 updated_turl.data_.SetKeyword(t_url->keyword()); 1915 updated_turl.data_.SetKeyword(t_url->keyword());
1931 } 1916 }
1932 something_changed = true; 1917 something_changed = true;
1933 // This will send the keyword change to sync. Note that other clients 1918 // This will send the keyword change to sync. Note that other clients
1934 // need to reset the keyword to an appropriate local value when this 1919 // need to reset the keyword to an appropriate local value when this
1935 // change arrives; see CreateTemplateURLFromTemplateURLAndSyncData(). 1920 // change arrives; see CreateTemplateURLFromTemplateURLAndSyncData().
1936 UpdateNoNotify(t_url, updated_turl, 1921 UpdateNoNotify(t_url, updated_turl,
1937 OldBaseURLSearchTermsData(t_url->profile(), old_base_url.spec())); 1922 OldBaseURLSearchTermsData(profile(), old_base_url.spec()));
1938 } 1923 }
1939 } 1924 }
1940 if (something_changed) 1925 if (something_changed)
1941 NotifyObservers(); 1926 NotifyObservers();
1942 } 1927 }
1943 1928
1944 void TemplateURLService::OnGoogleURLUpdated(GURL old_url, GURL new_url) { 1929 void TemplateURLService::OnGoogleURLUpdated(GURL old_url, GURL new_url) {
1945 if (loaded_) 1930 if (loaded_)
1946 GoogleBaseURLChanged(old_url); 1931 GoogleBaseURLChanged(old_url);
1947 } 1932 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 const TemplateURLData* data, 1965 const TemplateURLData* data,
1981 DefaultSearchManager::Source source) { 1966 DefaultSearchManager::Source source) {
1982 if (!loaded_) { 1967 if (!loaded_) {
1983 // Set |initial_default_search_provider_| from the preferences. This is 1968 // Set |initial_default_search_provider_| from the preferences. This is
1984 // mainly so we can hold ownership until we get to the point where the list 1969 // mainly so we can hold ownership until we get to the point where the list
1985 // of keywords from Web Data is the owner of everything including the 1970 // of keywords from Web Data is the owner of everything including the
1986 // default. 1971 // default.
1987 bool changed = TemplateURL::MatchesData( 1972 bool changed = TemplateURL::MatchesData(
1988 initial_default_search_provider_.get(), data, search_terms_data()); 1973 initial_default_search_provider_.get(), data, search_terms_data());
1989 initial_default_search_provider_.reset( 1974 initial_default_search_provider_.reset(
1990 data ? new TemplateURL(profile_, *data) : NULL); 1975 data ? new TemplateURL(*data) : NULL);
1991 default_search_provider_source_ = source; 1976 default_search_provider_source_ = source;
1992 return changed; 1977 return changed;
1993 } 1978 }
1994 1979
1995 // Prevent recursion if we update the value stored in default_search_manager_. 1980 // Prevent recursion if we update the value stored in default_search_manager_.
1996 // Note that we exclude the case of data == NULL because that could cause a 1981 // Note that we exclude the case of data == NULL because that could cause a
1997 // false positive for recursion when the initial_default_search_provider_ is 1982 // false positive for recursion when the initial_default_search_provider_ is
1998 // NULL due to policy. We'll never actually get recursion with data == NULL. 1983 // NULL due to policy. We'll never actually get recursion with data == NULL.
1999 if (source == default_search_provider_source_ && data != NULL && 1984 if (source == default_search_provider_source_ && data != NULL &&
2000 TemplateURL::MatchesData(default_search_provider_, data, 1985 TemplateURL::MatchesData(default_search_provider_, data,
(...skipping 23 matching lines...) Expand all
2024 default_search_provider_ = 2009 default_search_provider_ =
2025 FindPrepopulatedTemplateURL(data->prepopulate_id); 2010 FindPrepopulatedTemplateURL(data->prepopulate_id);
2026 if (default_search_provider_) { 2011 if (default_search_provider_) {
2027 TemplateURLData update_data(*data); 2012 TemplateURLData update_data(*data);
2028 update_data.sync_guid = default_search_provider_->sync_guid(); 2013 update_data.sync_guid = default_search_provider_->sync_guid();
2029 if (!default_search_provider_->safe_for_autoreplace()) { 2014 if (!default_search_provider_->safe_for_autoreplace()) {
2030 update_data.safe_for_autoreplace = false; 2015 update_data.safe_for_autoreplace = false;
2031 update_data.SetKeyword(default_search_provider_->keyword()); 2016 update_data.SetKeyword(default_search_provider_->keyword());
2032 update_data.short_name = default_search_provider_->short_name(); 2017 update_data.short_name = default_search_provider_->short_name();
2033 } 2018 }
2034 UIThreadSearchTermsData search_terms_data(
2035 default_search_provider_->profile());
2036 UpdateNoNotify(default_search_provider_, 2019 UpdateNoNotify(default_search_provider_,
2037 TemplateURL(profile_, update_data), 2020 TemplateURL(update_data),
2038 search_terms_data); 2021 search_terms_data());
2039 } else { 2022 } else {
2040 // Normally the prepopulated fallback should be present in 2023 // Normally the prepopulated fallback should be present in
2041 // |template_urls_|, but in a few cases it might not be: 2024 // |template_urls_|, but in a few cases it might not be:
2042 // (1) Tests that initialize the TemplateURLService in peculiar ways. 2025 // (1) Tests that initialize the TemplateURLService in peculiar ways.
2043 // (2) If the user deleted the pre-populated default and we subsequently 2026 // (2) If the user deleted the pre-populated default and we subsequently
2044 // lost their user-selected value. 2027 // lost their user-selected value.
2045 TemplateURL* new_dse = new TemplateURL(profile_, *data); 2028 TemplateURL* new_dse = new TemplateURL(*data);
2046 if (AddNoNotify(new_dse, true)) 2029 if (AddNoNotify(new_dse, true))
2047 default_search_provider_ = new_dse; 2030 default_search_provider_ = new_dse;
2048 } 2031 }
2049 } else if (source == DefaultSearchManager::FROM_USER) { 2032 } else if (source == DefaultSearchManager::FROM_USER) {
2050 default_search_provider_ = GetTemplateURLForGUID(data->sync_guid); 2033 default_search_provider_ = GetTemplateURLForGUID(data->sync_guid);
2051 if (!default_search_provider_ && data->prepopulate_id) { 2034 if (!default_search_provider_ && data->prepopulate_id) {
2052 default_search_provider_ = 2035 default_search_provider_ =
2053 FindPrepopulatedTemplateURL(data->prepopulate_id); 2036 FindPrepopulatedTemplateURL(data->prepopulate_id);
2054 } 2037 }
2055 TemplateURLData new_data(*data); 2038 TemplateURLData new_data(*data);
2056 new_data.show_in_default_list = true; 2039 new_data.show_in_default_list = true;
2057 if (default_search_provider_) { 2040 if (default_search_provider_) {
2058 UIThreadSearchTermsData search_terms_data(
2059 default_search_provider_->profile());
2060 UpdateNoNotify(default_search_provider_, 2041 UpdateNoNotify(default_search_provider_,
2061 TemplateURL(profile_, new_data), 2042 TemplateURL(new_data),
2062 search_terms_data); 2043 search_terms_data());
2063 } else { 2044 } else {
2064 new_data.id = kInvalidTemplateURLID; 2045 new_data.id = kInvalidTemplateURLID;
2065 TemplateURL* new_dse = new TemplateURL(profile_, new_data); 2046 TemplateURL* new_dse = new TemplateURL(new_data);
2066 if (AddNoNotify(new_dse, true)) 2047 if (AddNoNotify(new_dse, true))
2067 default_search_provider_ = new_dse; 2048 default_search_provider_ = new_dse;
2068 } 2049 }
2069 if (default_search_provider_ && GetPrefs()) { 2050 if (default_search_provider_ && GetPrefs()) {
2070 GetPrefs()->SetString( 2051 GetPrefs()->SetString(
2071 prefs::kSyncedDefaultSearchProviderGUID, 2052 prefs::kSyncedDefaultSearchProviderGUID,
2072 default_search_provider_->sync_guid()); 2053 default_search_provider_->sync_guid());
2073 } 2054 }
2074 2055
2075 } 2056 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 TemplateURLData data(url->data()); 2187 TemplateURLData data(url->data());
2207 data.short_name = title; 2188 data.short_name = title;
2208 data.SetKeyword(keyword); 2189 data.SetKeyword(keyword);
2209 if (search_url != data.url()) { 2190 if (search_url != data.url()) {
2210 data.SetURL(search_url); 2191 data.SetURL(search_url);
2211 // The urls have changed, reset the favicon url. 2192 // The urls have changed, reset the favicon url.
2212 data.favicon_url = GURL(); 2193 data.favicon_url = GURL();
2213 } 2194 }
2214 data.safe_for_autoreplace = false; 2195 data.safe_for_autoreplace = false;
2215 data.last_modified = time_provider_(); 2196 data.last_modified = time_provider_();
2216 UIThreadSearchTermsData search_terms_data(url->profile()); 2197 return UpdateNoNotify(url, TemplateURL(data), search_terms_data());
2217 return UpdateNoNotify(url, TemplateURL(profile_, data), search_terms_data);
2218 } 2198 }
2219 2199
2220 void TemplateURLService::NotifyObservers() { 2200 void TemplateURLService::NotifyObservers() {
2221 if (!loaded_) 2201 if (!loaded_)
2222 return; 2202 return;
2223 2203
2224 FOR_EACH_OBSERVER(TemplateURLServiceObserver, model_observers_, 2204 FOR_EACH_OBSERVER(TemplateURLServiceObserver, model_observers_,
2225 OnTemplateURLServiceChanged()); 2205 OnTemplateURLServiceChanged());
2226 } 2206 }
2227 2207
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 } 2245 }
2266 } 2246 }
2267 2247
2268 if (default_from_prefs) { 2248 if (default_from_prefs) {
2269 default_search_provider_ = NULL; 2249 default_search_provider_ = NULL;
2270 default_search_provider_source_ = DefaultSearchManager::FROM_POLICY; 2250 default_search_provider_source_ = DefaultSearchManager::FROM_POLICY;
2271 TemplateURLData new_data(*default_from_prefs); 2251 TemplateURLData new_data(*default_from_prefs);
2272 if (new_data.sync_guid.empty()) 2252 if (new_data.sync_guid.empty())
2273 new_data.sync_guid = base::GenerateGUID(); 2253 new_data.sync_guid = base::GenerateGUID();
2274 new_data.created_by_policy = true; 2254 new_data.created_by_policy = true;
2275 TemplateURL* new_dse = new TemplateURL(profile_, new_data); 2255 TemplateURL* new_dse = new TemplateURL(new_data);
2276 if (AddNoNotify(new_dse, true)) 2256 if (AddNoNotify(new_dse, true))
2277 default_search_provider_ = new_dse; 2257 default_search_provider_ = new_dse;
2278 } 2258 }
2279 } 2259 }
2280 2260
2281 void TemplateURLService::ResetTemplateURLGUID(TemplateURL* url, 2261 void TemplateURLService::ResetTemplateURLGUID(TemplateURL* url,
2282 const std::string& guid) { 2262 const std::string& guid) {
2283 DCHECK(loaded_); 2263 DCHECK(loaded_);
2284 DCHECK(!guid.empty()); 2264 DCHECK(!guid.empty());
2285 2265
2286 TemplateURLData data(url->data()); 2266 TemplateURLData data(url->data());
2287 data.sync_guid = guid; 2267 data.sync_guid = guid;
2288 UIThreadSearchTermsData search_terms_data(url->profile()); 2268 UpdateNoNotify(url, TemplateURL(data), search_terms_data());
2289 UpdateNoNotify(url, TemplateURL(profile_, data), search_terms_data);
2290 } 2269 }
2291 2270
2292 base::string16 TemplateURLService::UniquifyKeyword(const TemplateURL& turl, 2271 base::string16 TemplateURLService::UniquifyKeyword(const TemplateURL& turl,
2293 bool force) { 2272 bool force) {
2294 if (!force) { 2273 if (!force) {
2295 // Already unique. 2274 // Already unique.
2296 if (!GetTemplateURLForKeyword(turl.keyword())) 2275 if (!GetTemplateURLForKeyword(turl.keyword()))
2297 return turl.keyword(); 2276 return turl.keyword();
2298 2277
2299 // First, try to return the generated keyword for the TemplateURL (except 2278 // First, try to return the generated keyword for the TemplateURL (except
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2350 base::string16 new_keyword = UniquifyKeyword(*loser, false); 2329 base::string16 new_keyword = UniquifyKeyword(*loser, false);
2351 DCHECK(!GetTemplateURLForKeyword(new_keyword)); 2330 DCHECK(!GetTemplateURLForKeyword(new_keyword));
2352 if (applied_turl_is_better) { 2331 if (applied_turl_is_better) {
2353 // Just set the keyword of |unapplied_sync_turl|. The caller is responsible 2332 // Just set the keyword of |unapplied_sync_turl|. The caller is responsible
2354 // for adding or updating unapplied_sync_turl in the local model. 2333 // for adding or updating unapplied_sync_turl in the local model.
2355 unapplied_sync_turl->data_.SetKeyword(new_keyword); 2334 unapplied_sync_turl->data_.SetKeyword(new_keyword);
2356 } else { 2335 } else {
2357 // Update |applied_sync_turl| in the local model with the new keyword. 2336 // Update |applied_sync_turl| in the local model with the new keyword.
2358 TemplateURLData data(applied_sync_turl->data()); 2337 TemplateURLData data(applied_sync_turl->data());
2359 data.SetKeyword(new_keyword); 2338 data.SetKeyword(new_keyword);
2360 UIThreadSearchTermsData search_terms_data(applied_sync_turl->profile());
2361 if (UpdateNoNotify( 2339 if (UpdateNoNotify(
2362 applied_sync_turl, TemplateURL(profile_, data), search_terms_data)) 2340 applied_sync_turl, TemplateURL(data), search_terms_data()))
2363 NotifyObservers(); 2341 NotifyObservers();
2364 } 2342 }
2365 // The losing TemplateURL should have their keyword updated. Send a change to 2343 // The losing TemplateURL should have their keyword updated. Send a change to
2366 // the server to reflect this change. 2344 // the server to reflect this change.
2367 syncer::SyncData sync_data = CreateSyncDataFromTemplateURL(*loser); 2345 syncer::SyncData sync_data = CreateSyncDataFromTemplateURL(*loser);
2368 change_list->push_back(syncer::SyncChange(FROM_HERE, 2346 change_list->push_back(syncer::SyncChange(FROM_HERE,
2369 syncer::SyncChange::ACTION_UPDATE, 2347 syncer::SyncChange::ACTION_UPDATE,
2370 sync_data)); 2348 sync_data));
2371 } 2349 }
2372 2350
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 // This TemplateURL was either removed or overwritten in the local model. 2403 // This TemplateURL was either removed or overwritten in the local model.
2426 // Remove the entry from the local data so it isn't pushed up to Sync. 2404 // Remove the entry from the local data so it isn't pushed up to Sync.
2427 local_data->erase(guid); 2405 local_data->erase(guid);
2428 } 2406 }
2429 } 2407 }
2430 2408
2431 if (should_add_sync_turl) { 2409 if (should_add_sync_turl) {
2432 // Force the local ID to kInvalidTemplateURLID so we can add it. 2410 // Force the local ID to kInvalidTemplateURLID so we can add it.
2433 TemplateURLData data(sync_turl->data()); 2411 TemplateURLData data(sync_turl->data());
2434 data.id = kInvalidTemplateURLID; 2412 data.id = kInvalidTemplateURLID;
2435 TemplateURL* added = new TemplateURL(profile_, data); 2413 TemplateURL* added = new TemplateURL(data);
2436 base::AutoReset<DefaultSearchChangeOrigin> change_origin( 2414 base::AutoReset<DefaultSearchChangeOrigin> change_origin(
2437 &dsp_change_origin_, DSP_CHANGE_SYNC_ADD); 2415 &dsp_change_origin_, DSP_CHANGE_SYNC_ADD);
2438 if (Add(added)) 2416 if (Add(added))
2439 MaybeUpdateDSEAfterSync(added); 2417 MaybeUpdateDSEAfterSync(added);
2440 merge_result->set_num_items_added( 2418 merge_result->set_num_items_added(
2441 merge_result->num_items_added() + 1); 2419 merge_result->num_items_added() + 1);
2442 } 2420 }
2443 } 2421 }
2444 2422
2445 void TemplateURLService::PatchMissingSyncGUIDs( 2423 void TemplateURLService::PatchMissingSyncGUIDs(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2487 2465
2488 TemplateURL* TemplateURLService::CreateTemplateURLForExtension( 2466 TemplateURL* TemplateURLService::CreateTemplateURLForExtension(
2489 const ExtensionKeyword& extension_keyword) { 2467 const ExtensionKeyword& extension_keyword) {
2490 TemplateURLData data; 2468 TemplateURLData data;
2491 data.short_name = base::UTF8ToUTF16(extension_keyword.extension_name); 2469 data.short_name = base::UTF8ToUTF16(extension_keyword.extension_name);
2492 data.SetKeyword(base::UTF8ToUTF16(extension_keyword.extension_keyword)); 2470 data.SetKeyword(base::UTF8ToUTF16(extension_keyword.extension_keyword));
2493 // This URL is not actually used for navigation. It holds the extension's 2471 // This URL is not actually used for navigation. It holds the extension's
2494 // ID, as well as forcing the TemplateURL to be treated as a search keyword. 2472 // ID, as well as forcing the TemplateURL to be treated as a search keyword.
2495 data.SetURL(std::string(extensions::kExtensionScheme) + "://" + 2473 data.SetURL(std::string(extensions::kExtensionScheme) + "://" +
2496 extension_keyword.extension_id + "/?q={searchTerms}"); 2474 extension_keyword.extension_id + "/?q={searchTerms}");
2497 return new TemplateURL(profile_, data); 2475 return new TemplateURL(data);
2498 } 2476 }
2499 2477
2500 TemplateURL* TemplateURLService::FindTemplateURLForExtension( 2478 TemplateURL* TemplateURLService::FindTemplateURLForExtension(
2501 const std::string& extension_id, 2479 const std::string& extension_id,
2502 TemplateURL::Type type) { 2480 TemplateURL::Type type) {
2503 DCHECK_NE(TemplateURL::NORMAL, type); 2481 DCHECK_NE(TemplateURL::NORMAL, type);
2504 for (TemplateURLVector::const_iterator i = template_urls_.begin(); 2482 for (TemplateURLVector::const_iterator i = template_urls_.begin();
2505 i != template_urls_.end(); ++i) { 2483 i != template_urls_.end(); ++i) {
2506 if ((*i)->GetType() == type && 2484 if ((*i)->GetType() == type &&
2507 (*i)->GetExtensionId() == extension_id) 2485 (*i)->GetExtensionId() == extension_id)
(...skipping 30 matching lines...) Expand all
2538 2516
2539 if (most_recently_intalled_default) { 2517 if (most_recently_intalled_default) {
2540 base::AutoReset<DefaultSearchChangeOrigin> change_origin( 2518 base::AutoReset<DefaultSearchChangeOrigin> change_origin(
2541 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); 2519 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION);
2542 default_search_manager_.SetExtensionControlledDefaultSearchEngine( 2520 default_search_manager_.SetExtensionControlledDefaultSearchEngine(
2543 most_recently_intalled_default->data()); 2521 most_recently_intalled_default->data());
2544 } else { 2522 } else {
2545 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); 2523 default_search_manager_.ClearExtensionControlledDefaultSearchEngine();
2546 } 2524 }
2547 } 2525 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698