Bug 965064 - Part 2: back out FirefoxAccountsHelper. r=nalexander
authorRichard Newman <rnewman@mozilla.com>
Tue, 28 Jan 2014 16:51:19 -0800
changeset 165645 77baf0b8fb9ed5a42685d0900546a9e511fa4687
parent 165644 17789e0d6218b0b713d19ba35b24d3af8ec47109
child 165646 5c97f95f439a61cba24f6fe585c8cad386873bc2
push id1018
push userrnewman@mozilla.com
push dateWed, 29 Jan 2014 16:05:43 +0000
treeherderservices-central@77baf0b8fb9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs965064
milestone29.0a1
Bug 965064 - Part 2: back out FirefoxAccountsHelper. r=nalexander
mobile/android/base/BrowserApp.java
mobile/android/base/FirefoxAccountsHelper.java
mobile/android/base/moz.build
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -174,18 +174,16 @@ abstract public class BrowserApp extends
     private boolean mDynamicToolbarCanScroll = false;
 
     private Integer mPrefObserverId;
 
     private SharedPreferencesHelper mSharedPreferencesHelper;
 
     private OrderedBroadcastHelper mOrderedBroadcastHelper;
 
-    private FirefoxAccountsHelper mFirefoxAccountsHelper;
-
     private BrowserHealthReporter mBrowserHealthReporter;
 
     // The tab to be selected on editing mode exit.
     private Integer mTargetTabForEditingMode = null;
 
     // The animator used to toggle HomePager visibility has a race where if the HomePager is shown
     // (starting the animation), the HomePager is hidden, and the HomePager animation completes,
     // both the web content and the HomePager will be hidden. This flag is used to prevent the
@@ -541,17 +539,16 @@ abstract public class BrowserApp extends
         registerEventListener("Telemetry:Gather");
         registerEventListener("Settings:Show");
         registerEventListener("Updater:Launch");
 
         Distribution.init(this);
         JavaAddonManager.getInstance().init(getApplicationContext());
         mSharedPreferencesHelper = new SharedPreferencesHelper(getApplicationContext());
         mOrderedBroadcastHelper = new OrderedBroadcastHelper(getApplicationContext());
-        mFirefoxAccountsHelper = new FirefoxAccountsHelper(getApplicationContext());
         mBrowserHealthReporter = new BrowserHealthReporter();
 
         if (AppConstants.MOZ_ANDROID_BEAM && Build.VERSION.SDK_INT >= 14) {
             NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
             if (nfc != null) {
                 nfc.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
                     @Override
                     public NdefMessage createNdefMessage(NfcEvent event) {
@@ -838,21 +835,16 @@ abstract public class BrowserApp extends
             mSharedPreferencesHelper = null;
         }
 
         if (mOrderedBroadcastHelper != null) {
             mOrderedBroadcastHelper.uninit();
             mOrderedBroadcastHelper = null;
         }
 
-        if (mFirefoxAccountsHelper != null) {
-            mFirefoxAccountsHelper.uninit();
-            mFirefoxAccountsHelper = null;
-        }
-
         if (mBrowserHealthReporter != null) {
             mBrowserHealthReporter.uninit();
             mBrowserHealthReporter = null;
         }
 
         unregisterEventListener("CharEncoding:Data");
         unregisterEventListener("CharEncoding:State");
         unregisterEventListener("Feedback:LastUrl");
deleted file mode 100644
--- a/mobile/android/base/FirefoxAccountsHelper.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-package org.mozilla.gecko;
-
-import org.mozilla.gecko.util.EventDispatcher;
-import org.mozilla.gecko.util.GeckoEventListener;
-
-import org.mozilla.gecko.fxa.authenticator.FxAccountAuthenticator;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import android.accounts.Account;
-import android.content.Context;
-
-import android.util.Log;
-
-/**
- * Helper class to manage Firefox Accounts.
- *
- * Listens for messages starting "FxAccount:" from Javascript, and creates a new
- * Android account object in response to "FxAccount:{Verified,Login}".
- *
- * "FxAccount:Create" is ignored: it corresponds to a user creating a Firefox
- * Account on the server; but they have not yet completed an email verification
- * loop.  The provided data will not include the users keys.
- *
- * "FxAccount:Verified" corresponds to a user signing up: creating a Firefox
- * Account on the server, and then completing an email verification loop while
- * still in the about:accounts window.
- *
- * "FxAccount:Login" corresponds to a user signing in to an existing verified
- * Firefox Account.
- */
-public final class FirefoxAccountsHelper
-             implements GeckoEventListener
-{
-    public static final String LOGTAG = "FxAcctsHelper";
-
-    // For extra debugging.  Not final so it can be changed by an add-on.
-    public static boolean LOG_PERSONAL_INFORMATION = false;
-
-    public static final String EVENT_CREATE   = "FxAccount:Create";
-    public static final String EVENT_LOGIN    = "FxAccount:Login";
-    public static final String EVENT_VERIFIED = "FxAccount:Verified";
-
-    protected final Context mContext;
-
-    public FirefoxAccountsHelper(Context context) {
-        mContext = context;
-
-        EventDispatcher dispatcher = GeckoAppShell.getEventDispatcher();
-        if (dispatcher == null) {
-            Log.e(LOGTAG, "Gecko event dispatcher must not be null", new RuntimeException());
-            return;
-        }
-        dispatcher.registerEventListener(EVENT_CREATE, this);
-        dispatcher.registerEventListener(EVENT_LOGIN, this);
-        dispatcher.registerEventListener(EVENT_VERIFIED, this);
-    }
-
-    public synchronized void uninit() {
-        EventDispatcher dispatcher = GeckoAppShell.getEventDispatcher();
-        if (dispatcher == null) {
-            Log.e(LOGTAG, "Gecko event dispatcher must not be null", new RuntimeException());
-            return;
-        }
-        dispatcher.unregisterEventListener(EVENT_CREATE, this);
-        dispatcher.unregisterEventListener(EVENT_LOGIN, this);
-        dispatcher.unregisterEventListener(EVENT_VERIFIED, this);
-    }
-
-    @Override
-    public void handleMessage(String event, JSONObject message) {
-        Log.i(LOGTAG, "FirefoxAccountsHelper got event " + event);
-        if (!(EVENT_CREATE.equals(event) ||
-              EVENT_LOGIN.equals(event) ||
-              EVENT_VERIFIED.equals(event))) {
-            Log.e(LOGTAG, "FirefoxAccountsHelper got unexpected event " + event);
-            return;
-        }
-
-        if (EVENT_CREATE.equals(event)) {
-            Log.i(LOGTAG, "FirefoxAccountsHelper ignoring event " + event);
-            return;
-        }
-
-        try {
-            final JSONObject data = message.getJSONObject("data");
-            if (data == null) {
-                Log.e(LOGTAG, "data must not be null");
-                return;
-            }
-
-            if (LOG_PERSONAL_INFORMATION) {
-                Log.w(LOGTAG, "data: " + data.toString());
-            }
-
-            String email = data.optString("email");
-            String uid = data.optString("uid");
-            String sessionToken = data.optString("sessionToken");
-            String kA = data.optString("kA");
-            String kB = data.optString("kB");
-
-            if (LOG_PERSONAL_INFORMATION) {
-                Log.w(LOGTAG, "email: " + email);
-                Log.w(LOGTAG, "uid: " + uid);
-                Log.w(LOGTAG, "sessionToken: " + sessionToken);
-                Log.w(LOGTAG, "kA: " + kA);
-                Log.w(LOGTAG, "kB: " + kB);
-            }
-
-            Account account = FxAccountAuthenticator.addAccount(mContext, email, uid, sessionToken, kA, kB);
-            if (account == null) {
-                Log.e(LOGTAG, "Got null adding FxAccount.");
-                return;
-            }
-        } catch (Exception e) {
-            Log.e(LOGTAG, "Got exception in handleMessage handling event " + event, e);
-            return;
-        }
-    }
-}
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -132,17 +132,16 @@ gbjar.sources += [
     'favicons/decoders/IconDirectoryEntry.java',
     'favicons/decoders/LoadFaviconResult.java',
     'favicons/Favicons.java',
     'favicons/LoadFaviconTask.java',
     'favicons/OnFaviconLoadedListener.java',
     'FilePickerResultHandler.java',
     'FilePickerResultHandlerSync.java',
     'FindInPageBar.java',
-    'FirefoxAccountsHelper.java',
     'FormAssistPopup.java',
     'GeckoAccessibility.java',
     'GeckoActivity.java',
     'GeckoActivityStatus.java',
     'GeckoApp.java',
     'GeckoApplication.java',
     'GeckoAppShell.java',
     'GeckoBatteryManager.java',