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/utility/importer/external_process_importer_bridge.h" | 5 #include "chrome/utility/importer/external_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/logging.h" | 9 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
11 #include "base/task_runner.h" | 12 #include "base/task_runner.h" |
12 #include "base/values.h" | 13 #include "base/values.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_data_types.h" | 16 #include "chrome/common/importer/importer_data_types.h" |
16 #include "chrome/common/importer/profile_import_process_messages.h" | 17 #include "chrome/common/importer/profile_import_process_messages.h" |
17 #include "components/autofill/core/common/password_form.h" | 18 #include "components/autofill/core/common/password_form.h" |
18 #include "ipc/ipc_sender.h" | 19 #include "ipc/ipc_sender.h" |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 // Rather than sending all import items over IPC at once we chunk them into | 23 // Rather than sending all import items over IPC at once we chunk them into |
23 // separate requests. This avoids the case of a large import causing | 24 // separate requests. This avoids the case of a large import causing |
24 // oversized IPC messages. | 25 // oversized IPC messages. |
25 const int kNumBookmarksToSend = 100; | 26 const int kNumBookmarksToSend = 100; |
26 const int kNumHistoryRowsToSend = 100; | 27 const int kNumHistoryRowsToSend = 100; |
27 const int kNumFaviconsToSend = 100; | 28 const int kNumFaviconsToSend = 100; |
28 const int kNumAutofillFormDataToSend = 100; | 29 const int kNumAutofillFormDataToSend = 100; |
| 30 |
| 31 // http://crbug.com/404012. Let's see where the empty fields come from. |
| 32 void CheckForEmptyUsernameAndPassword(const autofill::PasswordForm& form) { |
| 33 if (form.username_value.empty() && |
| 34 form.password_value.empty() && |
| 35 !form.blacklisted_by_user) { |
| 36 base::debug::DumpWithoutCrashing(); |
| 37 } |
29 } | 38 } |
| 39 } // namespace |
30 | 40 |
31 ExternalProcessImporterBridge::ExternalProcessImporterBridge( | 41 ExternalProcessImporterBridge::ExternalProcessImporterBridge( |
32 const base::DictionaryValue& localized_strings, | 42 const base::DictionaryValue& localized_strings, |
33 IPC::Sender* sender, | 43 IPC::Sender* sender, |
34 base::TaskRunner* task_runner) | 44 base::TaskRunner* task_runner) |
35 : sender_(sender), | 45 : sender_(sender), |
36 task_runner_(task_runner) { | 46 task_runner_(task_runner) { |
37 // Bridge needs to make its own copy because OS 10.6 autoreleases the | 47 // Bridge needs to make its own copy because OS 10.6 autoreleases the |
38 // localized_strings value that is passed in (see http://crbug.com/46003 ). | 48 // localized_strings value that is passed in (see http://crbug.com/46003 ). |
39 localized_strings_.reset(localized_strings.DeepCopy()); | 49 localized_strings_.reset(localized_strings.DeepCopy()); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 141 } |
132 | 142 |
133 void ExternalProcessImporterBridge::SetFirefoxSearchEnginesXMLData( | 143 void ExternalProcessImporterBridge::SetFirefoxSearchEnginesXMLData( |
134 const std::vector<std::string>& search_engine_data) { | 144 const std::vector<std::string>& search_engine_data) { |
135 Send(new ProfileImportProcessHostMsg_NotifyFirefoxSearchEngData( | 145 Send(new ProfileImportProcessHostMsg_NotifyFirefoxSearchEngData( |
136 search_engine_data)); | 146 search_engine_data)); |
137 } | 147 } |
138 | 148 |
139 void ExternalProcessImporterBridge::SetPasswordForm( | 149 void ExternalProcessImporterBridge::SetPasswordForm( |
140 const autofill::PasswordForm& form) { | 150 const autofill::PasswordForm& form) { |
| 151 CheckForEmptyUsernameAndPassword(form); |
141 Send(new ProfileImportProcessHostMsg_NotifyPasswordFormReady(form)); | 152 Send(new ProfileImportProcessHostMsg_NotifyPasswordFormReady(form)); |
142 } | 153 } |
143 | 154 |
144 void ExternalProcessImporterBridge::SetAutofillFormData( | 155 void ExternalProcessImporterBridge::SetAutofillFormData( |
145 const std::vector<ImporterAutofillFormDataEntry>& entries) { | 156 const std::vector<ImporterAutofillFormDataEntry>& entries) { |
146 Send(new ProfileImportProcessHostMsg_AutofillFormDataImportStart( | 157 Send(new ProfileImportProcessHostMsg_AutofillFormDataImportStart( |
147 entries.size())); | 158 entries.size())); |
148 | 159 |
149 // |autofill_form_data_entries_left| is required for the checks below as | 160 // |autofill_form_data_entries_left| is required for the checks below as |
150 // Windows has a Debug bounds-check which prevents pushing an iterator beyond | 161 // Windows has a Debug bounds-check which prevents pushing an iterator beyond |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 task_runner_->PostTask( | 209 task_runner_->PostTask( |
199 FROM_HERE, | 210 FROM_HERE, |
200 base::Bind(&ExternalProcessImporterBridge::SendInternal, | 211 base::Bind(&ExternalProcessImporterBridge::SendInternal, |
201 this, message)); | 212 this, message)); |
202 } | 213 } |
203 | 214 |
204 void ExternalProcessImporterBridge::SendInternal(IPC::Message* message) { | 215 void ExternalProcessImporterBridge::SendInternal(IPC::Message* message) { |
205 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 216 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
206 sender_->Send(message); | 217 sender_->Send(message); |
207 } | 218 } |
OLD | NEW |