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

Unified Diff: components/search_engines/template_url_parser.cc

Issue 2902043004: Omnibox - Open Search - Handle Lack of Short Name Smartly (Closed)
Patch Set: pkasting comments Created 3 years, 7 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_parser.cc
diff --git a/components/search_engines/template_url_parser.cc b/components/search_engines/template_url_parser.cc
index 9d051056be59053399fba867444e4e8b733f3fd1..6f32a17d24d1fb67e930ad9d0025a2017588bb64 100644
--- a/components/search_engines/template_url_parser.cc
+++ b/components/search_engines/template_url_parser.cc
@@ -303,8 +303,7 @@ void TemplateURLParsingContext::CharactersImpl(void* ctx,
std::unique_ptr<TemplateURL> TemplateURLParsingContext::GetTemplateURL(
const SearchTermsData& search_terms_data) {
// TODO(jcampan): Support engines that use POST; see http://crbug.com/18107
- if (method_ == TemplateURLParsingContext::POST ||
- data_.short_name().empty() || !IsHTTPRef(data_.url()) ||
+ if (method_ == TemplateURLParsingContext::POST || !IsHTTPRef(data_.url()) ||
!IsHTTPRef(data_.suggestions_url))
return nullptr;
if (suggestion_method_ == TemplateURLParsingContext::POST)
@@ -321,6 +320,10 @@ std::unique_ptr<TemplateURL> TemplateURLParsingContext::GetTemplateURL(
if (!has_custom_keyword_)
data_.SetKeyword(TemplateURL::GenerateKeyword(search_url));
+ // If the OSDD omits or has an empty short name, use the keyword.
+ if (data_.short_name().empty())
+ data_.SetShortName(data_.keyword());
+
// Bail if the search URL is empty or if either TemplateURLRef is invalid.
std::unique_ptr<TemplateURL> template_url =
base::MakeUnique<TemplateURL>(data_);
« no previous file with comments | « components/search_engines/template_url_data.cc ('k') | components/test/data/search_engines/simple_open_search_no_name.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698