| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/importer/in_process_importer_bridge.h" | 5 #include "chrome/browser/importer/in_process_importer_bridge.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/dump_without_crashing.h" | |
| 9 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 10 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/importer/external_process_importer_host.h" | 11 #include "chrome/browser/importer/external_process_importer_host.h" |
| 13 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 12 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 14 #include "chrome/common/importer/imported_bookmark_entry.h" | 13 #include "chrome/common/importer/imported_bookmark_entry.h" |
| 15 #include "chrome/common/importer/imported_favicon_usage.h" | 14 #include "chrome/common/importer/imported_favicon_usage.h" |
| 16 #include "chrome/common/importer/importer_autofill_form_data_entry.h" | 15 #include "chrome/common/importer/importer_autofill_form_data_entry.h" |
| 17 #include "components/autofill/core/browser/webdata/autofill_entry.h" | 16 #include "components/autofill/core/browser/webdata/autofill_entry.h" |
| 18 #include "components/autofill/core/common/password_form.h" | 17 #include "components/autofill/core/common/password_form.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 return history::SOURCE_FIREFOX_IMPORTED; | 55 return history::SOURCE_FIREFOX_IMPORTED; |
| 57 case importer::VISIT_SOURCE_IE_IMPORTED: | 56 case importer::VISIT_SOURCE_IE_IMPORTED: |
| 58 return history::SOURCE_IE_IMPORTED; | 57 return history::SOURCE_IE_IMPORTED; |
| 59 case importer::VISIT_SOURCE_SAFARI_IMPORTED: | 58 case importer::VISIT_SOURCE_SAFARI_IMPORTED: |
| 60 return history::SOURCE_SAFARI_IMPORTED; | 59 return history::SOURCE_SAFARI_IMPORTED; |
| 61 } | 60 } |
| 62 NOTREACHED(); | 61 NOTREACHED(); |
| 63 return history::SOURCE_SYNCED; | 62 return history::SOURCE_SYNCED; |
| 64 } | 63 } |
| 65 | 64 |
| 66 // http://crbug.com/404012. Let's see where the empty fields come from. | |
| 67 void CheckForEmptyUsernameAndPassword(const autofill::PasswordForm& form) { | |
| 68 if (form.username_value.empty() && | |
| 69 form.password_value.empty() && | |
| 70 !form.blacklisted_by_user) { | |
| 71 base::debug::DumpWithoutCrashing(); | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 } // namespace | 65 } // namespace |
| 76 | 66 |
| 77 using content::BrowserThread; | 67 using content::BrowserThread; |
| 78 | 68 |
| 79 namespace { | 69 namespace { |
| 80 | 70 |
| 81 // FirefoxURLParameterFilter is used to remove parameter mentioning Firefox from | 71 // FirefoxURLParameterFilter is used to remove parameter mentioning Firefox from |
| 82 // the search URL when importing search engines. | 72 // the search URL when importing search engines. |
| 83 class FirefoxURLParameterFilter : public TemplateURLParser::ParameterFilter { | 73 class FirefoxURLParameterFilter : public TemplateURLParser::ParameterFilter { |
| 84 public: | 74 public: |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 std::copy(search_engines.begin(), search_engines.end(), | 244 std::copy(search_engines.begin(), search_engines.end(), |
| 255 std::back_inserter(owned_template_urls)); | 245 std::back_inserter(owned_template_urls)); |
| 256 | 246 |
| 257 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 247 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 258 base::Bind(&ProfileWriter::AddKeywords, writer_, | 248 base::Bind(&ProfileWriter::AddKeywords, writer_, |
| 259 base::Passed(&owned_template_urls), true)); | 249 base::Passed(&owned_template_urls), true)); |
| 260 } | 250 } |
| 261 | 251 |
| 262 void InProcessImporterBridge::SetPasswordForm( | 252 void InProcessImporterBridge::SetPasswordForm( |
| 263 const autofill::PasswordForm& form) { | 253 const autofill::PasswordForm& form) { |
| 264 CheckForEmptyUsernameAndPassword(form); | |
| 265 BrowserThread::PostTask( | 254 BrowserThread::PostTask( |
| 266 BrowserThread::UI, FROM_HERE, | 255 BrowserThread::UI, FROM_HERE, |
| 267 base::Bind(&ProfileWriter::AddPasswordForm, writer_, form)); | 256 base::Bind(&ProfileWriter::AddPasswordForm, writer_, form)); |
| 268 } | 257 } |
| 269 | 258 |
| 270 void InProcessImporterBridge::SetAutofillFormData( | 259 void InProcessImporterBridge::SetAutofillFormData( |
| 271 const std::vector<ImporterAutofillFormDataEntry>& entries) { | 260 const std::vector<ImporterAutofillFormDataEntry>& entries) { |
| 272 std::vector<autofill::AutofillEntry> autofill_entries; | 261 std::vector<autofill::AutofillEntry> autofill_entries; |
| 273 for (size_t i = 0; i < entries.size(); ++i) { | 262 for (size_t i = 0; i < entries.size(); ++i) { |
| 274 autofill_entries.push_back(autofill::AutofillEntry( | 263 autofill_entries.push_back(autofill::AutofillEntry( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 BrowserThread::PostTask( | 297 BrowserThread::PostTask( |
| 309 BrowserThread::UI, FROM_HERE, | 298 BrowserThread::UI, FROM_HERE, |
| 310 base::Bind(&ExternalProcessImporterHost::NotifyImportEnded, host_)); | 299 base::Bind(&ExternalProcessImporterHost::NotifyImportEnded, host_)); |
| 311 } | 300 } |
| 312 | 301 |
| 313 base::string16 InProcessImporterBridge::GetLocalizedString(int message_id) { | 302 base::string16 InProcessImporterBridge::GetLocalizedString(int message_id) { |
| 314 return l10n_util::GetStringUTF16(message_id); | 303 return l10n_util::GetStringUTF16(message_id); |
| 315 } | 304 } |
| 316 | 305 |
| 317 InProcessImporterBridge::~InProcessImporterBridge() {} | 306 InProcessImporterBridge::~InProcessImporterBridge() {} |
| OLD | NEW |