Chromium Code Reviews| Index: chrome/utility/importer/firefox_importer.cc |
| diff --git a/chrome/utility/importer/firefox_importer.cc b/chrome/utility/importer/firefox_importer.cc |
| index 1711d144e33867f817c50d1395ff3bda204f629a..2dce503bec173dd0c039c8c95e8394c3fe003d3d 100644 |
| --- a/chrome/utility/importer/firefox_importer.cc |
| +++ b/chrome/utility/importer/firefox_importer.cc |
| @@ -18,6 +18,7 @@ |
| #include "chrome/common/importer/firefox_importer_utils.h" |
| #include "chrome/common/importer/imported_bookmark_entry.h" |
| #include "chrome/common/importer/imported_favicon_usage.h" |
| +#include "chrome/common/importer/importer_autofill_form_data_entry.h" |
| #include "chrome/common/importer/importer_bridge.h" |
| #include "chrome/common/importer/importer_url_row.h" |
| #include "chrome/grit/generated_resources.h" |
| @@ -140,6 +141,11 @@ void FirefoxImporter::StartImport( |
| ImportPasswords(); |
| bridge_->NotifyItemEnded(importer::PASSWORDS); |
| } |
| + if ((items & importer::AUTOFILL_FORM_DATA) && !cancelled()) { |
| + bridge_->NotifyItemStarted(importer::AUTOFILL_FORM_DATA); |
| + ImportAutofillFormData(); |
| + bridge_->NotifyItemEnded(importer::AUTOFILL_FORM_DATA); |
| + } |
| bridge_->NotifyEnded(); |
| } |
| @@ -382,6 +388,41 @@ void FirefoxImporter::ImportHomepage() { |
| } |
| } |
| +void FirefoxImporter::ImportAutofillFormData() { |
| + base::FilePath file = source_path_.AppendASCII("formhistory.sqlite"); |
| + if (!base::PathExists(file)) |
| + return; |
| + |
| + sql::Connection db; |
| + if (!db.Open(file)) |
| + return; |
| + |
| + const char* query = |
|
Ilya Sherman
2014/08/20 05:47:42
nit: "const char query[] =" is more const (both th
Nikhil
2014/08/20 11:29:18
Changes done for this. But there are other queries
Ilya Sherman
2014/08/20 20:47:22
Yes, this would be great to fix in a follow-up pat
Nikhil
2014/08/21 07:35:36
Acknowledged.
|
| + "SELECT fieldname, value, timesUsed, firstUsed, lastUsed FROM " |
| + "moz_formhistory"; |
| + |
| + sql::Statement s(db.GetUniqueStatement(query)); |
| + |
| + std::vector<ImporterAutofillFormDataEntry> form_entries; |
| + while (s.Step() && !cancelled()) { |
| + ImporterAutofillFormDataEntry form_entry; |
| + form_entry.name = s.ColumnString16(0); |
| + form_entry.value = s.ColumnString16(1); |
| + form_entry.times_used = s.ColumnInt(2); |
| + form_entry.first_used = base::Time::FromTimeT(s.ColumnInt64(3) / 1000000); |
| + form_entry.last_used = base::Time::FromTimeT(s.ColumnInt64(4) / 1000000); |
| + |
| + // Don't import search bar history. |
| + if (base::UTF16ToUTF8(form_entry.name) == "searchbar-history") |
| + continue; |
| + |
| + form_entries.push_back(form_entry); |
| + } |
| + |
| + if (!form_entries.empty() && !cancelled()) |
| + bridge_->SetAutofillFormData(form_entries); |
| +} |
| + |
| void FirefoxImporter::GetSearchEnginesXMLData( |
| std::vector<std::string>* search_engine_data) { |
| base::FilePath file = source_path_.AppendASCII("search.sqlite"); |