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

Unified Diff: components/search_engines/template_url_service.h

Issue 2682453002: Changed keywords conflicts resolution for extensions search engines. (Closed)
Patch Set: Updated after review, round 3 Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: components/search_engines/template_url_service.h
diff --git a/components/search_engines/template_url_service.h b/components/search_engines/template_url_service.h
index a0368a31078bccf32142651047df2388b11b4da7..497e5c34f3d2f641e7b8904eb9e9de0e048ae3a3 100644
--- a/components/search_engines/template_url_service.h
+++ b/components/search_engines/template_url_service.h
@@ -227,7 +227,8 @@ class TemplateURLService : public WebDataServiceConsumer,
void RegisterOmniboxKeyword(const std::string& extension_id,
const std::string& extension_name,
const std::string& keyword,
- const std::string& template_url_string);
+ const std::string& template_url_string,
+ const base::Time& extension_install_time);
// Returns the set of URLs describing the keywords. The elements are owned
// by TemplateURLService and should not be deleted.
@@ -414,6 +415,9 @@ class TemplateURLService : public WebDataServiceConsumer,
FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, ChangeGoogleBaseValue);
FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, MergeDeletesUnusedProviders);
FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, AddExtensionKeyword);
+ FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, ExtensionsWithSameKeywords);
+ FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest,
+ CheckEnginesWithSameKeywords);
FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, LastVisitedTimeUpdate);
FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, UniquifyKeyword);
FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest,
@@ -480,6 +484,14 @@ class TemplateURLService : public WebDataServiceConsumer,
void Init(const Initializer* initializers, int num_initializers);
+ // Returns best engine that should be used from two search engines with equal
+ // keywords. This is only can happen if at least one of engines is installed
+ // by extension. One of arguments allowed to be nullptr, in this case another
vasilii 2017/02/21 13:17:51 is allowed
Alexander Yashkin 2017/02/21 14:02:21 Done.
+ // is returned. Ranking order is:
+ // omnibox api extension keywords > extension search engines > user engines
+ // When there are multiple extensions, the last-added wins.
+ TemplateURL* BestEngineForKeyword(TemplateURL* engine1, TemplateURL* engine2);
+
// Removes |template_url| from various internal maps
// (|keyword_to_turl_and_length_|, |keyword_domain_to_turl_and_length_|,
// |guid_to_turl_|, |provider_map_|).
@@ -705,9 +717,11 @@ class TemplateURLService : public WebDataServiceConsumer,
TemplateURL* FindTemplateURLForExtension(const std::string& extension_id,
TemplateURL::Type type);
- // Finds the extension-supplied TemplateURL that matches |data|, if any.
- TemplateURL* FindMatchingExtensionTemplateURL(const TemplateURLData& data,
- TemplateURL::Type type);
+ // Finds the extension-supplied TemplateURL of type
+ // NORMAL_CONTROLLED_BY_EXTENSION that matches |data| and wants to be default.
+ // Returns nullptr if not found.
+ TemplateURL* FindMatchingDefaultExtensionTemplateURL(
+ const TemplateURLData& data);
// Finds the most recently-installed NORMAL_CONTROLLED_BY_EXTENSION engine
// that supports replacement and wants to be default, if any. Notifies the

Powered by Google App Engine
This is Rietveld 408576698