Chromium Code Reviews| Index: chrome/utility/importer/firefox_importer.cc |
| diff --git a/chrome/utility/importer/firefox_importer.cc b/chrome/utility/importer/firefox_importer.cc |
| index a682dbdf70d1bd85a81ba90f79ac42de44725c6f..1d4534ea7c0c0c4c30a0d2802351a53b6e2fbc4d 100644 |
| --- a/chrome/utility/importer/firefox_importer.cc |
| +++ b/chrome/utility/importer/firefox_importer.cc |
| @@ -480,6 +480,18 @@ void FirefoxImporter::GetSearchEnginesXMLData( |
| void FirefoxImporter::GetSearchEnginesXMLDataFromJSON( |
| std::vector<std::string>* search_engine_data) { |
| + // search-metadata.json contains keywords for search engines. This |
| + // file exists only if the user has set keywords for search engines. |
| + base::FilePath search_metadata_json_file = |
| + source_path_.AppendASCII("search-metadata.json"); |
| + JSONFileValueSerializer metadata_serializer(search_metadata_json_file); |
| + scoped_ptr<base::Value> metadata_root( |
| + metadata_serializer.Deserialize(NULL, NULL)); |
| + const base::DictionaryValue* search_metadata_root = NULL; |
| + if (metadata_root) |
| + metadata_root->GetAsDictionary(&search_metadata_root); |
| + |
| + // search.json contains information about search engines to import. |
| base::FilePath search_json_file = source_path_.AppendASCII("search.json"); |
| if (!base::PathExists(search_json_file)) |
| return; |
| @@ -556,6 +568,22 @@ void FirefoxImporter::GetSearchEnginesXMLDataFromJSON( |
| std::string file_data; |
| base::ReadFileToString(xml_file, &file_data); |
| + |
| + // If a keyword is mentioned for this search engine, then add |
| + // it to the XML string as an <Alias> element and use this updated |
| + // string. |
| + const base::DictionaryValue* search_xml_path = NULL; |
| + if (search_metadata_root && search_metadata_root->HasKey(file_path) && |
| + search_metadata_root->GetDictionaryWithoutPathExpansion( |
| + file_path, &search_xml_path)) { |
| + std::string alias; |
| + search_xml_path->GetString("alias", &alias); |
| + |
| + // Add <Alias> element as the last child element. |
| + size_t end_of_parent = file_data.find("</SearchPlugin>"); |
| + if (end_of_parent != std::string::npos && !alias.empty()) |
|
Peter Kasting
2014/07/31 18:28:21
Make sure you have a testcase with an empty alias.
Nikhil
2014/08/04 12:15:11
Done.
|
| + file_data.insert(end_of_parent, "<Alias>" + alias + "</Alias> \n"); |
| + } |
| search_engine_data->push_back(file_data); |
| } |
| } |