Index: chrome/browser/search_engines/template_url_service.cc |
=================================================================== |
--- chrome/browser/search_engines/template_url_service.cc (revision 259649) |
+++ chrome/browser/search_engines/template_url_service.cc (working copy) |
@@ -888,13 +888,12 @@ |
// TODO(pkasting): Rather than communicating via prefs, we should eventually |
// observe policy changes directly. |
UpdateDefaultSearch(); |
- } else if (type == chrome::NOTIFICATION_GOOGLE_URL_UPDATED) { |
+ } else { |
+ DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_URL_UPDATED, type); |
if (loaded_) { |
GoogleBaseURLChanged( |
content::Details<GoogleURLTracker::UpdatedDetails>(details)->first); |
} |
- } else { |
- NOTREACHED(); |
} |
} |
@@ -992,11 +991,9 @@ |
FindNonExtensionTemplateURLForKeyword(turl->keyword()); |
if (iter->change_type() == syncer::SyncChange::ACTION_DELETE) { |
if (!existing_turl) { |
- NOTREACHED() << "Unexpected sync change state."; |
error = sync_error_factory_->CreateAndUploadError( |
FROM_HERE, |
"ProcessSyncChanges failed on ChangeType ACTION_DELETE"); |
- LOG(ERROR) << "Trying to delete a non-existent TemplateURL."; |
continue; |
} |
if (existing_turl == GetDefaultSearchProvider()) { |
@@ -1034,11 +1031,9 @@ |
Remove(existing_turl); |
} else if (iter->change_type() == syncer::SyncChange::ACTION_ADD) { |
if (existing_turl) { |
- NOTREACHED() << "Unexpected sync change state."; |
error = sync_error_factory_->CreateAndUploadError( |
FROM_HERE, |
"ProcessSyncChanges failed on ChangeType ACTION_ADD"); |
- LOG(ERROR) << "Trying to add an existing TemplateURL."; |
continue; |
} |
const std::string guid = turl->sync_guid(); |
@@ -1056,11 +1051,9 @@ |
SetDefaultSearchProviderIfNewlySynced(guid); |
} else if (iter->change_type() == syncer::SyncChange::ACTION_UPDATE) { |
if (!existing_turl) { |
- NOTREACHED() << "Unexpected sync change state."; |
error = sync_error_factory_->CreateAndUploadError( |
FROM_HERE, |
"ProcessSyncChanges failed on ChangeType ACTION_UPDATE"); |
- LOG(ERROR) << "Trying to update a non-existent TemplateURL."; |
continue; |
} |
if (existing_keyword_turl && (existing_keyword_turl != existing_turl)) { |
@@ -1074,7 +1067,6 @@ |
NotifyObservers(); |
} else { |
// We've unexpectedly received an ACTION_INVALID. |
- NOTREACHED() << "Unexpected sync change state."; |
error = sync_error_factory_->CreateAndUploadError( |
FROM_HERE, |
"ProcessSyncChanges received an ACTION_INVALID"); |
@@ -1453,8 +1445,8 @@ |
&TemplateURLService::OnSyncedDefaultSearchProviderGUIDChanged, |
base::Unretained(this))); |
} |
- notification_registrar_.Add(this, |
- chrome::NOTIFICATION_DEFAULT_SEARCH_POLICY_CHANGED, |
+ notification_registrar_.Add( |
+ this, chrome::NOTIFICATION_DEFAULT_SEARCH_POLICY_CHANGED, |
content::NotificationService::AllSources()); |
if (num_initializers > 0) { |
@@ -2187,7 +2179,7 @@ |
} |
if (service_.get()) |
- service_->SetDefaultSearchProvider(url); |
+ service_->SetDefaultSearchProviderID(url ? url->id() : 0); |
// Inform sync the change to the show_in_default_list flag. |
if (url) |
@@ -2252,17 +2244,13 @@ |
} |
void TemplateURLService::RemoveNoNotify(TemplateURL* template_url) { |
+ DCHECK(template_url != default_search_provider_); |
+ |
TemplateURLVector::iterator i = |
std::find(template_urls_.begin(), template_urls_.end(), template_url); |
if (i == template_urls_.end()) |
return; |
- if (template_url == default_search_provider_) { |
- // Should never delete the default search provider. |
- NOTREACHED(); |
- return; |
- } |
- |
RemoveFromMaps(template_url); |
// Remove it from the vector containing all TemplateURLs. |