Bug 721265 - Firefox migrator: form history support r=mak
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Sat, 28 Jan 2012 13:16:18 -0800
changeset 86899 7d6ce43efe5edec5352f4c2bfb9608b4d30c9e5c
parent 86898 c84e0881d475c812b7a248760088dda42e1c0001
child 86900 ec666b4c8d84873e7e6eac77f77cfd647a6356dd
child 86903 ab3edf81a46f7beebd5c01cdd254df9e16945346
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs721265
milestone12.0a1
Bug 721265 - Firefox migrator: form history support r=mak
browser/components/migration/src/FirefoxProfileMigrator.js
browser/locales/en-US/chrome/browser/migration/migration.properties
--- a/browser/components/migration/src/FirefoxProfileMigrator.js
+++ b/browser/components/migration/src/FirefoxProfileMigrator.js
@@ -27,21 +27,22 @@ Components.utils.import("resource://gre/
 function FirefoxProfileMigrator()
 {
   // profD is not available when the migrator is run during startup so use ProfDS.
   this._paths.currentProfile = FileUtils.getDir("ProfDS", []);
 }
 
 FirefoxProfileMigrator.prototype = {
   _paths: {
-    bookmarks : null,
-    cookies : null,
+    bookmarks: null,
+    cookies: null,
     currentProfile: null,    // The currently running (destination) profile.
     encryptionKey: null,
-    history : null,
+    formData: null,
+    history: null,
     passwords: null,
   },
 
   _homepageURL : null,
   _replaceBookmarks : false,
   _sourceProfile: null,
   _profilesCache: null,
 
@@ -180,16 +181,36 @@ FirefoxProfileMigrator.prototype = {
     } catch (e) {
       Cu.reportError(e);
       this._notifyError(MIGRATOR.PASSWORDS);
     } finally {
       this._notifyCompleted(MIGRATOR.PASSWORDS);
     }
   },
 
+  /**
+   * Migrating form history (satchel)
+   */
+  _migrateFormData : function Firefox_migrateFormData()
+  {
+    this._notifyStart(MIGRATOR.FORMDATA);
+
+    try {
+      // Access sqlite3 database of form history.
+      let file = Cc[LOCAL_FILE_CID].createInstance(Ci.nsILocalFile);
+      file.initWithPath(this._paths.formData);
+      file.copyTo(this._paths.currentProfile, null);
+    } catch (e) {
+      Cu.reportError(e);
+      this._notifyError(MIGRATOR.FORMDATA);
+    } finally {
+      this._notifyCompleted(MIGRATOR.FORMDATA);
+    }
+  },
+
 
   /**
    * nsIBrowserProfileMigrator interface implementation
    */
 
   /**
    * Let's migrate all items
    *
@@ -220,16 +241,19 @@ FirefoxProfileMigrator.prototype = {
       this._migrateCookies();
 
     if (aItems & MIGRATOR.BOOKMARKS)
       this._migrateBookmarks();
 
     if (aItems & MIGRATOR.PASSWORDS)
       this._migratePasswords();
 
+    if (aItems & MIGRATOR.FORMDATA)
+      this._migrateFormData();
+
     if (--this._pendingCount == 0) {
       // When async imports are immediately completed unfortunately,
       // this will be called.
       // Usually, this notification is sent by _notifyCompleted()
       Services.obs.notifyObservers(null, "Migration:Ended", null);
     }
   },
 
@@ -305,16 +329,28 @@ FirefoxProfileMigrator.prototype = {
         this._paths.passwords = passwords.path;
         this._paths.encryptionKey = encryptionKey.path;
         result += MIGRATOR.PASSWORDS;
       }
     } catch (e) {
       Cu.reportError(e);
     }
 
+    // Form data
+    try {
+      let file = this._sourceProfile.clone();
+      file.append("formhistory.sqlite");
+      if (file.exists()) {
+        this._paths.formData = file.path;
+        result += MIGRATOR.FORMDATA;
+      }
+    } catch (e) {
+      Cu.reportError(e);
+    }
+
     return result;
   },
 
   /**
    * Whether we support migration of Firefox
    *
    * @return true if supported
    */
--- a/browser/locales/en-US/chrome/browser/migration/migration.properties
+++ b/browser/locales/en-US/chrome/browser/migration/migration.properties
@@ -26,16 +26,17 @@ 2_firefox=Cookies
 4_ie=Browsing History
 4_safari=Browsing History
 4_chrome=Browsing History
 4_firefox=Browsing History
 
 8_ie=Saved Form History
 8_safari=Saved Form History
 8_chrome=Saved Form History
+8_firefox=Saved Form History
 
 16_ie=Saved Passwords
 16_safari=Saved Passwords
 16_chrome=Saved Passwords
 16_firefox=Saved Passwords
 
 32_ie=Favorites
 32_safari=Bookmarks