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

Unified Diff: chrome/browser/search_engines/template_url_service.cc

Issue 8689007: Defend against deleting the default search provider when merging duplicate TURLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/search_engines/template_url_service_sync_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search_engines/template_url_service.cc
===================================================================
--- chrome/browser/search_engines/template_url_service.cc (revision 111543)
+++ chrome/browser/search_engines/template_url_service.cc (working copy)
@@ -1807,10 +1807,22 @@
// rather than ResetTemplateURL, |sync_url| is added with a fresh
// TemplateURLID. We don't need to sync the new ID back to the server since
// it's only relevant locally.
- Remove(local_turl);
- // Force the local ID to 0 so we can add it.
- scoped_sync_turl->set_id(0);
- Add(scoped_sync_turl.release());
+ bool delete_default = (local_turl == GetDefaultSearchProvider());
+ if (delete_default && is_default_search_managed_) {
+ NOTREACHED() << "Tried to delete managed default search provider";
+ } else {
+ if (delete_default)
+ default_search_provider_ = NULL;
+
+ Remove(local_turl);
+
+ // Force the local ID to 0 so we can add it.
+ scoped_sync_turl->set_id(0);
+ TemplateURL* temp = scoped_sync_turl.release();
+ Add(temp);
+ if (delete_default)
+ SetDefaultSearchProvider(temp);
+ }
} else {
// Change the local TURL's GUID to the server's GUID and push an update to
// Sync. This ensures that the rest of local_url's fields are sync'd up to
« no previous file with comments | « no previous file | chrome/browser/search_engines/template_url_service_sync_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698