Delete from Sync the artificial search engines created by the omnibox extensions.
They are not synced for almost two years. However, the old entries may still reside in the server data. Now the client will remove them.
BUG=411197
Review-Url: https://codereview.chromium.org/2354413004
Cr-Commit-Position: refs/heads/master@{#423489}
diff --git a/components/search_engines/template_url.h b/components/search_engines/template_url.h
index fe4fc313..e931a0a 100644
--- a/components/search_engines/template_url.h
+++ b/components/search_engines/template_url.h
@@ -613,9 +613,6 @@
}
Type type() const { return type_; }
- // TODO(ianwen): remove set_type() once RestoreExtensionInfoIfNecessary() no
- // longer needs it.
- void set_type(Type type) { type_ = type; }
// This setter shouldn't be used except by TemplateURLService and
// TemplateURLServiceClient implementations.
@@ -757,7 +754,7 @@
TemplateURLRef contextual_search_url_ref_;
std::unique_ptr<AssociatedExtensionInfo> extension_info_;
- Type type_;
+ const Type type_;
// Caches the computed engine type across successive calls to GetEngineType().
mutable SearchEngineType engine_type_;
diff --git a/components/search_engines/template_url_service.cc b/components/search_engines/template_url_service.cc
index a079513e..29a06ed 100644
--- a/components/search_engines/template_url_service.cc
+++ b/components/search_engines/template_url_service.cc
@@ -1351,15 +1351,17 @@
UpdateTemplateURLIfPrepopulated(turl.get(), prefs);
// We used to sync keywords associated with omnibox extensions, but no longer
- // want to. However, if we delete these keywords from sync, we'll break any
- // synced old versions of Chrome which were relying on them. Instead, for now
- // we simply ignore these.
- // TODO(vasilii): After a few Chrome versions, change this to go ahead and
- // delete these from sync.
+ // want to. Delete them from the server.
+ // TODO(vasilii): After a few Chrome versions, delete this code together with
+ // IsOmniboxExtensionURL().
DCHECK(client);
- client->RestoreExtensionInfoIfNecessary(turl.get());
- if (turl->type() == TemplateURL::OMNIBOX_API_EXTENSION)
+ if (client->IsOmniboxExtensionURL(turl->url())) {
+ change_list->push_back(
+ syncer::SyncChange(FROM_HERE,
+ syncer::SyncChange::ACTION_DELETE,
+ sync_data));
return nullptr;
+ }
DCHECK_EQ(TemplateURL::NORMAL, turl->type());
if (reset_keyword || deduped) {
diff --git a/components/search_engines/template_url_service_client.h b/components/search_engines/template_url_service_client.h
index 46147ae..77a22d2 100644
--- a/components/search_engines/template_url_service_client.h
+++ b/components/search_engines/template_url_service_client.h
@@ -37,8 +37,9 @@
// Adds the given URL to history as a keyword generated visit.
virtual void AddKeywordGeneratedVisit(const GURL& url) = 0;
- // Restores the extension info of a TemplateURL loaded from the database.
- virtual void RestoreExtensionInfoIfNecessary(TemplateURL* template_url) = 0;
+ // Given the main search |url| for a TemplateURL, returns whether the
+ // TemplateURL is from an omnibox extension.
+ virtual bool IsOmniboxExtensionURL(const std::string& url) = 0;
};
#endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_CLIENT_H_