| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 223 |
| 224 void InProcessImporterBridge::SetPasswordForm( | 224 void InProcessImporterBridge::SetPasswordForm( |
| 225 const autofill::PasswordForm& form) { | 225 const autofill::PasswordForm& form) { |
| 226 writer_->AddPasswordForm(form); | 226 writer_->AddPasswordForm(form); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void InProcessImporterBridge::SetAutofillFormData( | 229 void InProcessImporterBridge::SetAutofillFormData( |
| 230 const std::vector<ImporterAutofillFormDataEntry>& entries) { | 230 const std::vector<ImporterAutofillFormDataEntry>& entries) { |
| 231 std::vector<autofill::AutofillEntry> autofill_entries; | 231 std::vector<autofill::AutofillEntry> autofill_entries; |
| 232 for (size_t i = 0; i < entries.size(); ++i) { | 232 for (size_t i = 0; i < entries.size(); ++i) { |
| 233 autofill_entries.push_back(autofill::AutofillEntry( | 233 // Using method c_str() in order to avoid data which contains null |
| 234 autofill::AutofillKey(entries[i].name, entries[i].value), | 234 // terminating symbols. |
| 235 entries[i].first_used, | 235 const base::string16 name = entries[i].name.c_str(); |
| 236 entries[i].last_used)); | 236 const base::string16 value = entries[i].value.c_str(); |
| 237 if (name.empty() || value.empty()) |
| 238 continue; |
| 239 autofill_entries.push_back( |
| 240 autofill::AutofillEntry(autofill::AutofillKey(name, value), |
| 241 entries[i].first_used, entries[i].last_used)); |
| 237 } | 242 } |
| 238 | 243 |
| 239 writer_->AddAutofillFormDataEntries(autofill_entries); | 244 writer_->AddAutofillFormDataEntries(autofill_entries); |
| 240 } | 245 } |
| 241 | 246 |
| 242 void InProcessImporterBridge::NotifyStarted() { | 247 void InProcessImporterBridge::NotifyStarted() { |
| 243 host_->NotifyImportStarted(); | 248 host_->NotifyImportStarted(); |
| 244 } | 249 } |
| 245 | 250 |
| 246 void InProcessImporterBridge::NotifyItemStarted(importer::ImportItem item) { | 251 void InProcessImporterBridge::NotifyItemStarted(importer::ImportItem item) { |
| 247 host_->NotifyImportItemStarted(item); | 252 host_->NotifyImportItemStarted(item); |
| 248 } | 253 } |
| 249 | 254 |
| 250 void InProcessImporterBridge::NotifyItemEnded(importer::ImportItem item) { | 255 void InProcessImporterBridge::NotifyItemEnded(importer::ImportItem item) { |
| 251 host_->NotifyImportItemEnded(item); | 256 host_->NotifyImportItemEnded(item); |
| 252 } | 257 } |
| 253 | 258 |
| 254 void InProcessImporterBridge::NotifyEnded() { | 259 void InProcessImporterBridge::NotifyEnded() { |
| 255 host_->NotifyImportEnded(); | 260 host_->NotifyImportEnded(); |
| 256 } | 261 } |
| 257 | 262 |
| 258 base::string16 InProcessImporterBridge::GetLocalizedString(int message_id) { | 263 base::string16 InProcessImporterBridge::GetLocalizedString(int message_id) { |
| 259 return l10n_util::GetStringUTF16(message_id); | 264 return l10n_util::GetStringUTF16(message_id); |
| 260 } | 265 } |
| 261 | 266 |
| 262 InProcessImporterBridge::~InProcessImporterBridge() {} | 267 InProcessImporterBridge::~InProcessImporterBridge() {} |
| OLD | NEW |