Bug 924900 - Remove unused auto-sync setup code. r=jimm
authorBrian R. Bondy <netzen@gmail.com>
Wed, 20 Nov 2013 13:45:08 -0500
changeset 158068 325f2f06ca0b60dc8f2d2867ed6da0a58cd364ae
parent 158067 594ae98c4fddece56d517b829b00c7527869ab28
child 158069 f1bab224b379f2009eaf7ce3fd7ad884dd077a63
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjimm
bugs924900
milestone28.0a1
Bug 924900 - Remove unused auto-sync setup code. r=jimm
browser/base/content/sync/setup.js
browser/base/content/sync/setup.xul
browser/locales/en-US/chrome/browser/syncSetup.dtd
widget/nsIWinMetroUtils.idl
widget/windows/winrt/nsWinMetroUtils.cpp
--- a/browser/base/content/sync/setup.js
+++ b/browser/base/content/sync/setup.js
@@ -467,23 +467,16 @@ var gSyncSetup = {
                                                 challenge, response);
 
         if (error == null) {
           Weave.Service.identity.account = email;
           Weave.Service.identity.basicPassword = password;
           Weave.Service.identity.syncKey = Weave.Utils.generatePassphrase();
           this._handleNoScript(false);
           Weave.Svc.Prefs.set("firstSync", "newAccount");
-#ifdef XP_WIN
-#ifdef MOZ_METRO
-          if (document.getElementById("metroSetupCheckbox").checked) {
-            Services.metro.storeSyncInfo(email, password, Weave.Service.identity.syncKey);
-          }
-#endif
-#endif
           this.wizardFinish();
           return false;
         }
 
         image.setAttribute("status", "error");
         label.value = Weave.Utils.getErrorString(error);
         return false;
       case EXISTING_ACCOUNT_LOGIN_PAGE:
--- a/browser/base/content/sync/setup.xul
+++ b/browser/base/content/sync/setup.xul
@@ -167,30 +167,16 @@
         </row>
         <row id="serverFeedbackRow" align="center" hidden="true">
           <spacer/>
           <hbox>
             <image class="statusIcon"/>
             <label class="status" value=" "/>
           </hbox>
         </row>
-#ifdef XP_WIN
-#ifdef MOZ_METRO
-        <row id="metroRow" align="center">
-          <spacer/>
-          <hbox align="center">
-            <checkbox label="&setup.setupMetro.label;"
-                      accesskey="&setup.setupMetro.accesskey;"
-                      control="weavePasswordConfirm"
-                      id="metroSetupCheckbox"
-                      checked="true"/>
-          </hbox>
-        </row>
-#endif
-#endif
         <row id="TOSRow" align="center">
           <spacer/>
           <hbox align="center">
             <checkbox id="tos"
                       accesskey="&setup.tosAgree1.accesskey;"
                       oncommand="this.focus(); gSyncSetup.checkFields();"/>
             <description id="tosDesc"
                          flex="1"
--- a/browser/locales/en-US/chrome/browser/syncSetup.dtd
+++ b/browser/locales/en-US/chrome/browser/syncSetup.dtd
@@ -28,18 +28,16 @@
 <!-- New Account Page 1: Basic Account Info -->
 <!ENTITY setup.newAccountDetailsPage.title.label "Account Details">
 <!ENTITY setup.emailAddress.label     "Email Address">
 <!ENTITY setup.emailAddress.accesskey "E">
 <!ENTITY setup.choosePassword.label      "Choose a Password">
 <!ENTITY setup.choosePassword.accesskey  "P">
 <!ENTITY setup.confirmPassword.label     "Confirm Password">
 <!ENTITY setup.confirmPassword.accesskey "m">
-<!ENTITY setup.setupMetro.label     "Sync with Windows 8 style &brandShortName;">
-<!ENTITY setup.setupMetro.accesskey "S">
 
 <!-- LOCALIZATION NOTE: tosAgree1, tosLink, tosAgree2, ppLink, tosAgree3 are
      joined with implicit white space, so spaces in the strings aren't necessary -->
 <!ENTITY setup.tosAgree1.label      "I agree to the">
 <!ENTITY setup.tosAgree1.accesskey  "a">
 <!ENTITY setup.tosLink.label        "Terms of Service">
 <!ENTITY setup.tosAgree2.label      "and the">
 <!ENTITY setup.ppLink.label         "Privacy Policy">
--- a/widget/nsIWinMetroUtils.idl
+++ b/widget/nsIWinMetroUtils.idl
@@ -7,17 +7,17 @@
 
 /**
  * Integration with the "Metro"/"Modern" UI environment in Windows 8.
  *
  * Note: browser/metro/base/content/browser-scripts.js contains a stub
  * implementation of this interface for non-Windows systems, for testing and
  * development purposes only.
  */
-[scriptable, uuid(496b4450-5757-40f7-aeb9-a958ae86dbd1)]
+[scriptable, uuid(d30daa27-ce2b-4503-80cc-b162f4c24e93)]
 interface nsIWinMetroUtils : nsISupports
 {
   /**
    * Determine if the current browser is running in the metro immersive
    * environment.
    */
   readonly attribute boolean immersive;
 
@@ -80,39 +80,16 @@ interface nsIWinMetroUtils : nsISupports
    * 
    * @param aTileID An ID which may have been pinned with pinTileAsync
    *                ID must only contain valid filesystem characters
    * @return true if the tile is pinned
    */
   bool isTilePinned(in AString aTileID);
 
   /**
-   * Stores the sync info securely
-   *
-   * @param aEmail The sync account email
-   * @param aPassword The sync account password
-   * @param aKey The sync account key
-   */
-  void storeSyncInfo(in AString aEmail, in AString aPassword, in AString aKey);
-
-  /**
-   * Loads the sync info
-   *
-   * @param aEmail The sync account email
-   * @param aPassword The sync account password
-   * @param aKey The sync account key
-   */
-  void loadSyncInfo(out AString aEmail, out AString aPassword, out AString aKey);
-
-  /**
-   * Clears the stored sync info if any.
-   */
-  void clearSyncInfo();
-
-  /**
    * Soft keyboard attributes. Used in unison with shown/hidden observer
    * events sent via FrameworkView.
    *
    * keyboardVisible - returns true if the soft keyboard is currently
    * displayed, false otherwise.
    * keyboardX, keyboardY, keyboardWidth, keyboardHeight - occlude rect
    * of the keyboard when displayed in device independent pixels.
    */
--- a/widget/windows/winrt/nsWinMetroUtils.cpp
+++ b/widget/windows/winrt/nsWinMetroUtils.cpp
@@ -3,24 +3,22 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsWinMetroUtils.h"
 #include "MetroUtils.h"
 #include "nsXULAppAPI.h"
 #include "FrameworkView.h"
 #include "MetroApp.h"
-#include "nsIWindowsRegKey.h"
 #include "ToastNotificationHandler.h"
 
 #include <shldisp.h>
 #include <shellapi.h>
 #include <windows.ui.viewmanagement.h>
 #include <windows.ui.startscreen.h>
-#include <Wincrypt.h>
 
 using namespace ABI::Windows::Foundation;
 using namespace ABI::Windows::UI::StartScreen;
 using namespace ABI::Windows::UI::ViewManagement;
 using namespace Microsoft::WRL;
 using namespace Microsoft::WRL::Wrappers;
 using namespace mozilla::widget::winrt;
 
@@ -30,21 +28,16 @@ namespace winrt {
 extern ComPtr<MetroApp> sMetroApp;
 extern nsTArray<nsString>* sSettingsArray;
 extern ComPtr<FrameworkView> sFrameworkView;
 } } }
 
 namespace mozilla {
 namespace widget {
 
-static LPCWSTR sSyncEmailField = L"sync-e";
-static LPCWSTR sSyncPasswordField = L"sync-p";
-static LPCWSTR sSyncKeyField = L"sync-k";
-static LPCSTR sRegPath = "Software\\Mozilla\\Firefox";
-
 NS_IMPL_ISUPPORTS1(nsWinMetroUtils, nsIWinMetroUtils)
 
 nsWinMetroUtils::nsWinMetroUtils()
 {
 }
 
 nsWinMetroUtils::~nsWinMetroUtils()
 {
@@ -172,157 +165,16 @@ nsWinMetroUtils::IsTilePinned(const nsAS
   AssertRetHRESULT(hr, NS_ERROR_FAILURE);
   boolean result = false;
   tileStatics->Exists(tileIdStr.Get(), &result);
   *aIsPinned = result;
   return NS_OK;
 }
 
 /**
-  * Stores the sync info securely in Windows
-  *
-  * @param aEmail The sync account email
-  * @param aPassword The sync account password
-  * @param aKey The sync account key
-  */
-NS_IMETHODIMP
-nsWinMetroUtils::StoreSyncInfo(const nsAString &aEmail,
-                               const nsAString &aPassword,
-                               const nsAString &aKey)
-{
-  DATA_BLOB emailIn = {
-    (aEmail.Length() + 1) * 2,
-    (BYTE *)aEmail.BeginReading()},
-  passwordIn = {
-    (aPassword.Length() + 1) * 2,
-    (BYTE *)aPassword.BeginReading()},
-  keyIn = {
-    (aKey.Length() + 1) * 2,
-    (BYTE *)aKey.BeginReading()};
-  DATA_BLOB emailOut = { 0, nullptr }, passwordOut = {0, nullptr }, keyOut = { 0, nullptr };
-  bool succeeded = CryptProtectData(&emailIn, nullptr, nullptr, nullptr,
-                                    nullptr, 0, &emailOut) &&
-                   CryptProtectData(&passwordIn, nullptr, nullptr, nullptr,
-                                    nullptr, 0, &passwordOut) &&
-                   CryptProtectData(&keyIn, nullptr, nullptr, nullptr,
-                                    nullptr, 0, &keyOut);
-
-  if (succeeded) {
-    nsresult rv;
-    nsCOMPtr<nsIWindowsRegKey> regKey
-      (do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv));
-    NS_ENSURE_SUCCESS(rv, rv);
-    regKey->Create(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
-                  NS_ConvertUTF8toUTF16(sRegPath),
-                  nsIWindowsRegKey::ACCESS_SET_VALUE);
-
-    if (NS_FAILED(regKey->WriteBinaryValue(nsDependentString(sSyncEmailField),
-                                           nsAutoCString((const char *)emailOut.pbData,
-                                                         emailOut.cbData)))) {
-      succeeded = false;
-    }
-
-    if (succeeded &&
-        NS_FAILED(regKey->WriteBinaryValue(nsDependentString(sSyncPasswordField),
-                                           nsAutoCString((const char *)passwordOut.pbData,
-                                                         passwordOut.cbData)))) {
-      succeeded = false;
-    }
-
-    if (succeeded &&
-        NS_FAILED(regKey->WriteBinaryValue(nsDependentString(sSyncKeyField),
-                                           nsAutoCString((const char *)keyOut.pbData,
-                                                         keyOut.cbData)))) {
-      succeeded = false;
-    }
-    regKey->Close();
-  }
-
-  LocalFree(emailOut.pbData);
-  LocalFree(passwordOut.pbData);
-  LocalFree(keyOut.pbData);
-
-  return succeeded ? NS_OK : NS_ERROR_FAILURE;
-}
-
-/**
-  * Loads the sync info securely in Windows
-  *
-  * @param aEmail The sync account email
-  * @param aPassword The sync account password
-  * @param aKey The sync account key
-  */
-NS_IMETHODIMP
-nsWinMetroUtils::LoadSyncInfo(nsAString &aEmail, nsAString &aPassword,
-                              nsAString &aKey)
-{
-  nsresult rv;
-  nsCOMPtr<nsIWindowsRegKey> regKey
-    (do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
-  regKey->Create(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
-                 NS_ConvertUTF8toUTF16(sRegPath),
-                 nsIWindowsRegKey::ACCESS_QUERY_VALUE);
-
-  nsAutoCString email, password, key;
-  if (NS_FAILED(regKey->ReadBinaryValue(nsDependentString(sSyncEmailField), email)) ||
-      NS_FAILED(regKey->ReadBinaryValue(nsDependentString(sSyncPasswordField), password)) ||
-      NS_FAILED(regKey->ReadBinaryValue(nsDependentString(sSyncKeyField), key))) {
-    return NS_ERROR_FAILURE;
-  }
-  regKey->Close();
-
-  DATA_BLOB emailIn = { email.Length(), (BYTE*)email.BeginReading() },
-            passwordIn = { password.Length(), (BYTE*)password.BeginReading() },
-            keyIn = { key.Length(), (BYTE*)key.BeginReading() };
-  DATA_BLOB emailOut = { 0, nullptr }, passwordOut = { 0, nullptr }, keyOut = { 0, nullptr };
-  bool succeeded = CryptUnprotectData(&emailIn, nullptr, nullptr, nullptr,
-                                      nullptr, 0, &emailOut) &&
-                   CryptUnprotectData(&passwordIn, nullptr, nullptr, nullptr,
-                                      nullptr, 0, &passwordOut) &&
-                   CryptUnprotectData(&keyIn, nullptr, nullptr, nullptr,
-                                      nullptr, 0, &keyOut);
-  if (succeeded) {
-    aEmail = reinterpret_cast<wchar_t*>(emailOut.pbData);
-    aPassword = reinterpret_cast<wchar_t*>(passwordOut.pbData);
-    aKey = reinterpret_cast<wchar_t*>(keyOut.pbData);
-  }
-
-  LocalFree(emailOut.pbData);
-  LocalFree(passwordOut.pbData);
-  LocalFree(keyOut.pbData);
-
-  return succeeded ? NS_OK : NS_ERROR_FAILURE;
-}
-
-/**
-  * Clears the stored sync info if any.
-  */
-NS_IMETHODIMP
-nsWinMetroUtils::ClearSyncInfo()
-{
-  nsresult rv;
-  nsCOMPtr<nsIWindowsRegKey> regKey
-    (do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
-  regKey->Create(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
-                 NS_ConvertUTF8toUTF16(sRegPath),
-                 nsIWindowsRegKey::ACCESS_WRITE);
-  nsresult rv1 = regKey->RemoveValue(nsDependentString(sSyncEmailField));
-  nsresult rv2 = regKey->RemoveValue(nsDependentString(sSyncPasswordField));
-  nsresult rv3 = regKey->RemoveValue(nsDependentString(sSyncKeyField));
-  regKey->Close();
-
-  if (NS_FAILED(rv1) || NS_FAILED(rv2) || NS_FAILED(rv3)) {
-      return NS_ERROR_FAILURE;
-  }
-  return NS_OK;
-}
-
-/**
  * Launches the specified application with the specified arguments and
  * switches to Desktop mode if in metro mode.
 */
 NS_IMETHODIMP
 nsWinMetroUtils::LaunchInDesktop(const nsAString &aPath, const nsAString &aArguments)
 {
   SHELLEXECUTEINFOW sinfo;
   memset(&sinfo, 0, sizeof(SHELLEXECUTEINFOW));