Index: chrome/utility/importer/firefox_importer.cc |
diff --git a/chrome/utility/importer/firefox_importer.cc b/chrome/utility/importer/firefox_importer.cc |
index 6f37095f7cf8efafc1905a5eecb8fae644990354..6444e29bdfb56afd07e74d0355f568520ab095b5 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[] = |
+ "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"); |