Chromium Code Reviews| 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" | |
| 8 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/importer/external_process_importer_host.h" | 12 #include "chrome/browser/importer/external_process_importer_host.h" |
| 12 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 13 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 13 #include "chrome/common/importer/imported_bookmark_entry.h" | 14 #include "chrome/common/importer/imported_bookmark_entry.h" |
| 14 #include "chrome/common/importer/imported_favicon_usage.h" | 15 #include "chrome/common/importer/imported_favicon_usage.h" |
| 15 #include "chrome/common/importer/importer_autofill_form_data_entry.h" | 16 #include "chrome/common/importer/importer_autofill_form_data_entry.h" |
| 16 #include "components/autofill/core/browser/webdata/autofill_entry.h" | 17 #include "components/autofill/core/browser/webdata/autofill_entry.h" |
| 17 #include "components/autofill/core/common/password_form.h" | 18 #include "components/autofill/core/common/password_form.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 return history::SOURCE_FIREFOX_IMPORTED; | 56 return history::SOURCE_FIREFOX_IMPORTED; |
| 56 case importer::VISIT_SOURCE_IE_IMPORTED: | 57 case importer::VISIT_SOURCE_IE_IMPORTED: |
| 57 return history::SOURCE_IE_IMPORTED; | 58 return history::SOURCE_IE_IMPORTED; |
| 58 case importer::VISIT_SOURCE_SAFARI_IMPORTED: | 59 case importer::VISIT_SOURCE_SAFARI_IMPORTED: |
| 59 return history::SOURCE_SAFARI_IMPORTED; | 60 return history::SOURCE_SAFARI_IMPORTED; |
| 60 } | 61 } |
| 61 NOTREACHED(); | 62 NOTREACHED(); |
| 62 return history::SOURCE_SYNCED; | 63 return history::SOURCE_SYNCED; |
| 63 } | 64 } |
| 64 | 65 |
| 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(); | |
|
Ilya Sherman
2014/09/17 18:35:12
Optional nit: Since the condition for this if-stmt
vasilii
2014/09/18 08:54:34
Done.
| |
| 72 } | |
| 73 | |
| 65 } // namespace | 74 } // namespace |
| 66 | 75 |
| 67 using content::BrowserThread; | 76 using content::BrowserThread; |
| 68 | 77 |
| 69 namespace { | 78 namespace { |
| 70 | 79 |
| 71 // FirefoxURLParameterFilter is used to remove parameter mentioning Firefox from | 80 // FirefoxURLParameterFilter is used to remove parameter mentioning Firefox from |
| 72 // the search URL when importing search engines. | 81 // the search URL when importing search engines. |
| 73 class FirefoxURLParameterFilter : public TemplateURLParser::ParameterFilter { | 82 class FirefoxURLParameterFilter : public TemplateURLParser::ParameterFilter { |
| 74 public: | 83 public: |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 std::copy(search_engines.begin(), search_engines.end(), | 253 std::copy(search_engines.begin(), search_engines.end(), |
| 245 std::back_inserter(owned_template_urls)); | 254 std::back_inserter(owned_template_urls)); |
| 246 | 255 |
| 247 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 256 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 248 base::Bind(&ProfileWriter::AddKeywords, writer_, | 257 base::Bind(&ProfileWriter::AddKeywords, writer_, |
| 249 base::Passed(&owned_template_urls), true)); | 258 base::Passed(&owned_template_urls), true)); |
| 250 } | 259 } |
| 251 | 260 |
| 252 void InProcessImporterBridge::SetPasswordForm( | 261 void InProcessImporterBridge::SetPasswordForm( |
| 253 const autofill::PasswordForm& form) { | 262 const autofill::PasswordForm& form) { |
| 263 CheckForEmptyUsernameAndPassword(form); | |
| 254 BrowserThread::PostTask( | 264 BrowserThread::PostTask( |
| 255 BrowserThread::UI, FROM_HERE, | 265 BrowserThread::UI, FROM_HERE, |
| 256 base::Bind(&ProfileWriter::AddPasswordForm, writer_, form)); | 266 base::Bind(&ProfileWriter::AddPasswordForm, writer_, form)); |
| 257 } | 267 } |
| 258 | 268 |
| 259 void InProcessImporterBridge::SetAutofillFormData( | 269 void InProcessImporterBridge::SetAutofillFormData( |
| 260 const std::vector<ImporterAutofillFormDataEntry>& entries) { | 270 const std::vector<ImporterAutofillFormDataEntry>& entries) { |
| 261 std::vector<autofill::AutofillEntry> autofill_entries; | 271 std::vector<autofill::AutofillEntry> autofill_entries; |
| 262 for (size_t i = 0; i < entries.size(); ++i) { | 272 for (size_t i = 0; i < entries.size(); ++i) { |
| 263 autofill_entries.push_back(autofill::AutofillEntry( | 273 autofill_entries.push_back(autofill::AutofillEntry( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 BrowserThread::PostTask( | 307 BrowserThread::PostTask( |
| 298 BrowserThread::UI, FROM_HERE, | 308 BrowserThread::UI, FROM_HERE, |
| 299 base::Bind(&ExternalProcessImporterHost::NotifyImportEnded, host_)); | 309 base::Bind(&ExternalProcessImporterHost::NotifyImportEnded, host_)); |
| 300 } | 310 } |
| 301 | 311 |
| 302 base::string16 InProcessImporterBridge::GetLocalizedString(int message_id) { | 312 base::string16 InProcessImporterBridge::GetLocalizedString(int message_id) { |
| 303 return l10n_util::GetStringUTF16(message_id); | 313 return l10n_util::GetStringUTF16(message_id); |
| 304 } | 314 } |
| 305 | 315 |
| 306 InProcessImporterBridge::~InProcessImporterBridge() {} | 316 InProcessImporterBridge::~InProcessImporterBridge() {} |
| OLD | NEW |