Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Unified Diff: chrome/utility/importer/firefox_importer.cc

Issue 480953002: Implement "Autofill form data" import for Firefox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback (simplify Read method) Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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");
« no previous file with comments | « chrome/utility/importer/firefox_importer.h ('k') | components/autofill/core/browser/webdata/autofill_webdata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698