const char kOpenSearchDescriptionElement[] = "OpenSearchDescription";
const char kFirefoxSearchDescriptionElement[] = "SearchPlugin";
const char kInputEncodingElement[] = "InputEncoding";
+const char kAliasElement[] = "Alias";
// Various XML attributes used.
const char kURLTypeAttribute[] = "type";
SHORT_NAME,
IMAGE,
INPUT_ENCODING,
+ ALIAS,
};
enum Method {
// search. Note that we don't need a stack as URL nodes cannot be nested.
bool is_suggest_url_;
+ // If true, the user has set a keyword and we should use it. Otherwise,
+ // we generate a keyword based on the URL.
+ bool has_custom_keyword_;
+
// Whether we should derive the image from the URL (when images are data
// URLs).
bool derive_image_from_url_;
method_(GET),
suggestion_method_(GET),
is_suggest_url_(false),
+ has_custom_keyword_(false),
derive_image_from_url_(false) {
if (kElementNameToElementTypeMap == NULL)
InitMapping();
TemplateURLParsingContext* context =
reinterpret_cast<TemplateURLParsingContext*>(ctx);
switch (context->GetKnownType()) {
+ case TemplateURLParsingContext::URL:
+ context->ProcessURLParams();
+ break;
case TemplateURLParsingContext::SHORT_NAME:
context->data_.short_name = context->string_;
break;
context->data_.input_encodings.push_back(input_encoding);
break;
}
- case TemplateURLParsingContext::URL:
- context->ProcessURLParams();
+ case TemplateURLParsingContext::ALIAS: {
+ context->data_.SetKeyword(context->string_);
+ context->has_custom_keyword_ = true;
break;
+ }
default:
break;
}
if (derive_image_from_url_ && data_.favicon_url.is_empty())
data_.favicon_url = TemplateURL::GenerateFaviconURL(search_url);
- data_.SetKeyword(TemplateURL::GenerateKeyword(search_url));
+ // Generate a keyword for this search engine if a custom one was not present
+ // in the imported data.
+ if (!has_custom_keyword_)
+ 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.
(*kElementNameToElementTypeMap)[kFirefoxSearchDescriptionElement] =
OPEN_SEARCH_DESCRIPTION;
(*kElementNameToElementTypeMap)[kInputEncodingElement] = INPUT_ENCODING;
+ (*kElementNameToElementTypeMap)[kAliasElement] = ALIAS;
}
void TemplateURLParsingContext::ParseURL(const xmlChar** atts) {