Bug 1434167 - remove getSourceHomePageURL implementations and callsites, r?dthayer draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 07 Feb 2018 10:18:46 +0000
changeset 751980 dff816a6ed8b53de2b88b39275c7996d657295f5
parent 751155 48def8fbcc6f08263d5970c61f74095b1129322b
child 751981 92b7976d2c17e68273c89eb45d380823c715cca3
child 751982 0fd9a21e6313813be53033c9699969882c41ac1b
push id98119
push usergijskruitbosch@gmail.com
push dateWed, 07 Feb 2018 10:40:01 +0000
reviewersdthayer
bugs1434167
milestone60.0a1
Bug 1434167 - remove getSourceHomePageURL implementations and callsites, r?dthayer MozReview-Commit-ID: 98p2Iy70EPv
browser/components/migration/ChromeProfileMigrator.js
browser/components/migration/IEProfileMigrator.js
browser/components/migration/MigrationUtils.jsm
browser/components/migration/SafariProfileMigrator.js
browser/components/migration/content/migration.js
browser/components/migration/nsIBrowserProfileMigrator.idl
--- a/browser/components/migration/ChromeProfileMigrator.js
+++ b/browser/components/migration/ChromeProfileMigrator.js
@@ -189,33 +189,16 @@ ChromeProfileMigrator.prototype.getSourc
 
     // Only list profiles from which any data can be imported
     this.__sourceProfiles = profileResources.filter(({resources}) => {
       return resources && resources.length > 0;
     }, this).map(({profile}) => profile);
     return this.__sourceProfiles;
   };
 
-ChromeProfileMigrator.prototype.getSourceHomePageURL =
-  async function Chrome_getSourceHomePageURL() {
-    let chromeUserDataPath = await this._getChromeUserDataPathIfExists();
-    if (!chromeUserDataPath)
-      return "";
-    let prefsPath = OS.Path.join(chromeUserDataPath, "Preferences");
-    if (await OS.File.exists(prefsPath)) {
-      try {
-        let json = await OS.File.read(prefsPath, {encoding: "UTF-8"});
-        return JSON.parse(json).homepage;
-      } catch (e) {
-        Cu.reportError("Error parsing Chrome's preferences file: " + e);
-      }
-    }
-    return "";
-  };
-
 Object.defineProperty(ChromeProfileMigrator.prototype, "sourceLocked", {
   get: function Chrome_sourceLocked() {
     // There is an exclusive lock on some SQLite databases. Assume they are locked for now.
     return true;
   },
 });
 
 async function GetBookmarksResource(aProfileFolder) {
--- a/browser/components/migration/IEProfileMigrator.js
+++ b/browser/components/migration/IEProfileMigrator.js
@@ -5,17 +5,16 @@
 "use strict";
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 const Cr = Components.results;
 
 const kLoginsKey = "Software\\Microsoft\\Internet Explorer\\IntelliForms\\Storage2";
-const kMainKey = "Software\\Microsoft\\Internet Explorer\\Main";
 
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/osfile.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource:///modules/MigrationUtils.jsm");
 ChromeUtils.import("resource:///modules/MSMigrationUtils.jsm");
 
@@ -373,38 +372,13 @@ IEProfileMigrator.prototype.getLastUsedD
     // dates is an array of PRTimes, which are in microseconds - convert to milliseconds
     resolve(Math.max.apply(Math, dates) / 1000);
   }));
   return Promise.all(datePromises).then(dates => {
     return new Date(Math.max.apply(Math, dates));
   });
 };
 
-IEProfileMigrator.prototype.getSourceHomePageURL = function IE_getSourceHomePageURL() {
-  let defaultStartPage = WindowsRegistry.readRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
-                                                    kMainKey, "Default_Page_URL");
-  let startPage = WindowsRegistry.readRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
-                                             kMainKey, "Start Page");
-  // If the user didn't customize the Start Page, he is still on the default
-  // page, that may be considered the equivalent of our about:home.  There's
-  // no reason to retain it, since it is heavily targeted to IE.
-  let homepage = startPage != defaultStartPage ? startPage : "";
-
-  // IE7+ supports secondary home pages located in a REG_MULTI_SZ key.  These
-  // are in addition to the Start Page, and no empty entries are possible,
-  // thus a Start Page is always defined if any of these exists, though it
-  // may be the default one.
-  let secondaryPages = WindowsRegistry.readRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
-                                                  kMainKey, "Secondary Start Pages");
-  if (secondaryPages) {
-    if (homepage)
-      secondaryPages.unshift(homepage);
-    homepage = secondaryPages.join("|");
-  }
-
-  return homepage;
-};
-
 IEProfileMigrator.prototype.classDescription = "IE Profile Migrator";
 IEProfileMigrator.prototype.contractID = "@mozilla.org/profile/migrator;1?app=browser&type=ie";
 IEProfileMigrator.prototype.classID = Components.ID("{3d2532e3-4932-4774-b7ba-968f5899d3a4}");
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([IEProfileMigrator]);
--- a/browser/components/migration/MigrationUtils.jsm
+++ b/browser/components/migration/MigrationUtils.jsm
@@ -77,19 +77,17 @@ function getMigrationBundle() {
  * 1. Import this module.
  * 2. Create the prototype for the migrator, extending MigratorPrototype.
  *    Namely: MosaicMigrator.prototype = Object.create(MigratorPrototype);
  * 3. Set classDescription, contractID and classID for your migrator, and set
  *    NSGetFactory appropriately.
  * 4. If the migrator supports multiple profiles, override the sourceProfiles
  *    Here we default for single-profile migrator.
  * 5. Implement getResources(aProfile) (see below).
- * 6. If the migrator supports reading the home page of the source browser,
- *    override |getSourceHomePageURL| getter.
- * 7. For startup-only migrators, override |startupOnlyMigrator|.
+ * 6. For startup-only migrators, override |startupOnlyMigrator|.
  */
 this.MigratorPrototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIBrowserProfileMigrator]),
 
   /**
    * OVERRIDE IF AND ONLY IF the source supports multiple profiles.
    *
    * Returns array of profile objects from which data may be imported. The object
@@ -180,24 +178,16 @@ this.MigratorPrototype = {
    *   The migrator can call MigrationUtils.profileStartup.doStartup
    *   at any point in order to initialize the profile.
    */
   get startupOnlyMigrator() {
     return false;
   },
 
   /**
-   * OVERRIDE IF AND ONLY IF your migrator supports importing the homepage.
-   * @see nsIBrowserProfileMigrator
-   */
-  getSourceHomePageURL() {
-    return "";
-  },
-
-  /**
    * Override if the data to migrate is locked/in-use and the user should
    * probably shutdown the source browser.
    */
   get sourceLocked() {
     return false;
   },
 
   /**
--- a/browser/components/migration/SafariProfileMigrator.js
+++ b/browser/components/migration/SafariProfileMigrator.js
@@ -379,22 +379,13 @@ Object.defineProperty(SafariProfileMigra
       }
       this._mainPreferencesPropertyList = null;
       return this._mainPreferencesPropertyList;
     }
     return this._mainPreferencesPropertyList;
   },
 });
 
-SafariProfileMigrator.prototype.getSourceHomePageURL = async function SM_getSourceHomePageURL() {
-  if (this.mainPreferencesPropertyList) {
-    let dict = await new Promise(resolve => this.mainPreferencesPropertyList.read(resolve));
-    if (dict.has("HomePage"))
-      return dict.get("HomePage");
-  }
-  return "";
-};
-
 SafariProfileMigrator.prototype.classDescription = "Safari Profile Migrator";
 SafariProfileMigrator.prototype.contractID = "@mozilla.org/profile/migrator;1?app=browser&type=safari";
 SafariProfileMigrator.prototype.classID = Components.ID("{4b609ecf-60b2-4655-9df4-dc149e474da1}");
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SafariProfileMigrator]);
--- a/browser/components/migration/content/migration.js
+++ b/browser/components/migration/content/migration.js
@@ -322,17 +322,17 @@ var MigrationWizard = { /* exported Migr
     singleStart.setAttribute("label", mainStr);
     singleStart.setAttribute("value", "DEFAULT");
 
     var appName = MigrationUtils.getBrowserName(this._source);
 
     // semi-wallpaper for crash when multiple profiles exist, since we haven't initialized mSourceProfile in places
     this.spinResolve(this._migrator.getMigrateData(this._selectedProfile, this._autoMigrate));
 
-    var oldHomePageURL = this.spinResolve(this._migrator.getSourceHomePageURL());
+    var oldHomePageURL = null;
 
     if (oldHomePageURL && appName) {
       var oldHomePageLabel =
         brandBundle.getFormattedString("homePageImport", [appName]);
       var oldHomePage = document.getElementById("oldHomePage");
       oldHomePage.setAttribute("label", oldHomePageLabel);
       oldHomePage.setAttribute("value", oldHomePageURL);
       oldHomePage.removeAttribute("hidden");
--- a/browser/components/migration/nsIBrowserProfileMigrator.idl
+++ b/browser/components/migration/nsIBrowserProfileMigrator.idl
@@ -60,21 +60,15 @@ interface nsIBrowserProfileMigrator : ns
 
   /**
    * An enumeration of available profiles. If the import source does
    * not support profiles, this attribute is null.
    * @return a promise that resolves with an array of profiles or null.
    */
   jsval getSourceProfiles();
 
-  /**
-   * The import source homepage.  Returns null if not present/available
-   * @return a promise that resolves with a string or null.
-   */
-  jsval getSourceHomePageURL();
-
 
   /**
    * Whether the source browser data is locked/in-use meaning migration likely
    * won't succeed and the user should be warned.
    */
   readonly attribute boolean          sourceLocked;
 };