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..addefe6e58a2024978a78ec24022a2807d0b836b 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, |
+ DefaultExtensionAndEnginesWithSameKeywords); |
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 for keyword from two candidates. |
+ // |existing_engine| can be nullptr, in this case new_engine is returned. |
+ // Ranking order is: |
+ // omnibox api extension keywords > extension search engines > user engines |
+ // When there are multiple extensions, the last-added wins. |
vasilii
2017/02/20 15:30:08
The comment leaves a question. Is it possible that
Alexander Yashkin
2017/02/20 19:52:47
Changed comment and updated function.
New variant
|
+ TemplateURL* BestEngineForKeyword(TemplateURL* existing_engine, |
+ TemplateURL* new_engine); |
+ |
// 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 |