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

Unified Diff: components/search_engines/template_url_parser.cc

Issue 426653002: Import keywords for search engines imported from Firefox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 5c6eae5ef587141ae01d1cddb2f5123054ec9177..fc2943f467b43878f6a96107ff300f566a8b0bef 100644
--- a/components/search_engines/template_url_parser.cc
+++ b/components/search_engines/template_url_parser.cc
@@ -34,6 +34,7 @@ const char kImageElement[] = "Image";
const char kOpenSearchDescriptionElement[] = "OpenSearchDescription";
const char kFirefoxSearchDescriptionElement[] = "SearchPlugin";
const char kInputEncodingElement[] = "InputEncoding";
+const char kAliasElement[] = "Alias";
// Various XML attributes used.
const char kURLTypeAttribute[] = "type";
@@ -115,6 +116,7 @@ class TemplateURLParsingContext {
SHORT_NAME,
IMAGE,
INPUT_ENCODING,
+ ALIAS
Peter Kasting 2014/07/28 22:48:31 Nit: Add trailing comma (means future additions wo
Nikhil 2014/07/29 08:29:21 Done.
};
enum Method {
@@ -243,6 +245,9 @@ void TemplateURLParsingContext::EndElementImpl(void* ctx, const xmlChar* name) {
case TemplateURLParsingContext::SHORT_NAME:
Peter Kasting 2014/07/28 22:48:31 Nit: The order of cases in this switch seems rando
Nikhil 2014/07/29 08:29:21 Done.
context->data_.short_name = context->string_;
break;
+ case TemplateURLParsingContext::ALIAS:
+ context->data_.SetKeyword(context->string_);
+ break;
case TemplateURLParsingContext::IMAGE: {
GURL image_url(base::UTF16ToUTF8(context->string_));
if (image_url.SchemeIs(url::kDataScheme)) {
@@ -298,7 +303,12 @@ TemplateURL* TemplateURLParsingContext::GetTemplateURL(
if (derive_image_from_url_ && data_.favicon_url.is_empty())
data_.favicon_url = TemplateURL::GenerateFaviconURL(search_url);
- data_.SetKeyword(TemplateURL::GenerateKeyword(search_url));
+ // When |keyword| is equal to "dummy", it means that no alias was mentioned
+ // in XML file while importing search engines. We generate based on url in
+ // that case. Else, we use alias mentioned in XML file.
Peter Kasting 2014/07/28 22:48:31 Nit: Clearer and shorter: // Generate a keyword
Nikhil 2014/07/29 08:29:21 Done.
+ if (base::UTF16ToUTF8(data_.keyword()) == "dummy")
Peter Kasting 2014/07/28 22:48:31 I'm not a big fan of checking against "dummy", as
Nikhil 2014/07/29 08:29:21 Noted, it could very well be possible. To track th
+ data_.SetKeyword(TemplateURL::GenerateKeyword(search_url));
+
data_.show_in_default_list = show_in_default_list;
// Bail if the search URL is empty or if either TemplateURLRef is invalid.
@@ -325,6 +335,7 @@ void TemplateURLParsingContext::InitMapping() {
(*kElementNameToElementTypeMap)[kFirefoxSearchDescriptionElement] =
OPEN_SEARCH_DESCRIPTION;
(*kElementNameToElementTypeMap)[kInputEncodingElement] = INPUT_ENCODING;
+ (*kElementNameToElementTypeMap)[kAliasElement] = ALIAS;
}
void TemplateURLParsingContext::ParseURL(const xmlChar** atts) {
« chrome/utility/importer/firefox_importer.cc ('K') | « chrome/utility/importer/firefox_importer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698