Chromium Code Reviews| Index: chrome/browser/importer/in_process_importer_bridge.cc |
| diff --git a/chrome/browser/importer/in_process_importer_bridge.cc b/chrome/browser/importer/in_process_importer_bridge.cc |
| index 3bd1fde5be8c905e1ea3b3014adf69bb691b80f0..d94ae1393c01ebec3a9d861d67698600d0b9f3a4 100644 |
| --- a/chrome/browser/importer/in_process_importer_bridge.cc |
| +++ b/chrome/browser/importer/in_process_importer_bridge.cc |
| @@ -91,25 +91,20 @@ class FirefoxURLParameterFilter : public TemplateURLParser::ParameterFilter { |
| DISALLOW_COPY_AND_ASSIGN(FirefoxURLParameterFilter); |
| }; |
| -// Creates a TemplateURL with the |keyword| and |url|. |title| may be empty. |
| +// Attempts to create a TemplateURL from the provided data. |title| is optional. |
| +// If TemplateURL creation fails, returns NULL. |
| // This function transfers ownership of the created TemplateURL to the caller. |
| TemplateURL* CreateTemplateURL(const base::string16& title, |
| const base::string16& keyword, |
| - const GURL& url) { |
| - // Skip if the url is invalid. |
| - if (!url.is_valid()) |
| + const base::string16& url) { |
| + if (url.empty() || keyword.empty()) |
| return NULL; |
| - |
| TemplateURLData data; |
| - if (keyword.empty()) |
| - data.SetKeyword(TemplateURL::GenerateKeyword(url)); |
| - else |
| - data.SetKeyword(keyword); |
| + data.SetKeyword(keyword); |
| // We set short name by using the title if it exists. |
| // Otherwise, we use the shortcut. |
| - data.short_name = title.empty() ? keyword : title; |
| - data.SetURL( |
| - TemplateURLRef::DisplayURLToURLRef(base::UTF8ToUTF16(url.spec()))); |
| + data.short_name = title.empty() ? data.keyword() : title; |
|
Peter Kasting
2014/12/12 01:04:42
Nit: After I harassed you to use data.keyword() he
Tapu Ghose
2014/12/12 05:20:54
I was about to do the same. But then thought you m
|
| + data.SetURL(TemplateURLRef::DisplayURLToURLRef(url)); |
| return new TemplateURL(data); |
| } |
| @@ -221,14 +216,16 @@ void InProcessImporterBridge::SetHistoryItems( |
| } |
| void InProcessImporterBridge::SetKeywords( |
| - const std::vector<importer::URLKeywordInfo>& url_keywords, |
| + const std::vector<importer::SearchEngineInfo>& search_engines, |
| bool unique_on_host_and_path) { |
| ScopedVector<TemplateURL> owned_template_urls; |
| - for (size_t i = 0; i < url_keywords.size(); ++i) { |
| - owned_template_urls.push_back( |
| - CreateTemplateURL(url_keywords[i].display_name, |
| - url_keywords[i].keyword, |
| - url_keywords[i].url)); |
| + for (const auto& search_engine : search_engines) { |
| + TemplateURL* owned_template_url = |
| + CreateTemplateURL(search_engine.display_name, |
|
Peter Kasting
2014/12/12 01:04:42
Tiny nit: I'd probably pass the args in the order
Tapu Ghose
2014/12/12 05:20:54
Acknowledged.
|
| + search_engine.keyword, |
| + search_engine.url); |
| + if (owned_template_url) |
| + owned_template_urls.push_back(owned_template_url); |
| } |
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| base::Bind(&ProfileWriter::AddKeywords, writer_, |