Bug 1204937 - Part 4: Add "pass-through to web" versions of native account activities. r=sebastian

This always loads about:accounts with an 'action' query parameter.
This indirection allows Gecko to manage the fxa-content-server pref
independently of Java.
This commit is contained in:
Nick Alexander 2015-09-01 13:18:48 -07:00
parent 300fd24d79
commit 0b3e2cfe3b
7 changed files with 151 additions and 0 deletions

View File

@ -853,16 +853,21 @@ sync_java_files = [
'fxa/activities/FxAccountAbstractSetupActivity.java',
'fxa/activities/FxAccountAbstractUpdateCredentialsActivity.java',
'fxa/activities/FxAccountConfirmAccountActivity.java',
'fxa/activities/FxAccountConfirmAccountActivityWeb.java',
'fxa/activities/FxAccountCreateAccountActivity.java',
'fxa/activities/FxAccountCreateAccountNotAllowedActivity.java',
'fxa/activities/FxAccountFinishMigratingActivity.java',
'fxa/activities/FxAccountFinishMigratingActivityWeb.java',
'fxa/activities/FxAccountGetStartedActivity.java',
'fxa/activities/FxAccountGetStartedActivityWeb.java',
'fxa/activities/FxAccountMigrationFinishedActivity.java',
'fxa/activities/FxAccountSignInActivity.java',
'fxa/activities/FxAccountStatusActivity.java',
'fxa/activities/FxAccountStatusFragment.java',
'fxa/activities/FxAccountUpdateCredentialsActivity.java',
'fxa/activities/FxAccountUpdateCredentialsActivityWeb.java',
'fxa/activities/FxAccountVerifiedAccountActivity.java',
'fxa/activities/FxAccountWebFlowActivity.java',
'fxa/activities/PicassoPreferenceIconTarget.java',
'fxa/authenticator/AccountPickler.java',
'fxa/authenticator/AndroidFxAccount.java',

View File

@ -0,0 +1,11 @@
/* 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.fxa.activities;
public class FxAccountConfirmAccountActivityWeb extends FxAccountWebFlowActivity {
public FxAccountConfirmAccountActivityWeb() {
super(CANNOT_RESUME_WHEN_NO_ACCOUNTS_EXIST, "settings");
}
}

View File

@ -0,0 +1,11 @@
/* 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.fxa.activities;
public class FxAccountFinishMigratingActivityWeb extends FxAccountWebFlowActivity {
public FxAccountFinishMigratingActivityWeb() {
super(CANNOT_RESUME_WHEN_NO_ACCOUNTS_EXIST, "signin", "migration=sync11");
}
}

View File

@ -0,0 +1,11 @@
/* 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.fxa.activities;
public class FxAccountGetStartedActivityWeb extends FxAccountWebFlowActivity {
public FxAccountGetStartedActivityWeb() {
super(CANNOT_RESUME_WHEN_ACCOUNTS_EXIST, "signin");
}
}

View File

@ -0,0 +1,11 @@
/* 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.fxa.activities;
public class FxAccountUpdateCredentialsActivityWeb extends FxAccountWebFlowActivity {
public FxAccountUpdateCredentialsActivityWeb() {
super(CANNOT_RESUME_WHEN_NO_ACCOUNTS_EXIST, "force_auth");
}
}

View File

@ -0,0 +1,64 @@
/* 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.fxa.activities;
import android.os.Bundle;
import org.mozilla.gecko.Locales;
import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
import org.mozilla.gecko.sync.setup.activities.ActivityUtils;
/**
* Activity which shows the status activity or passes through to web flow.
*/
public class FxAccountWebFlowActivity extends FxAccountAbstractActivity {
protected static final String LOG_TAG = FxAccountWebFlowActivity.class.getSimpleName();
protected static final String ABOUT_ACCOUNTS = "about:accounts";
private final String action;
private final String extras;
public FxAccountWebFlowActivity(int resume, String action) {
this(resume, action, null);
}
public FxAccountWebFlowActivity(int resume, String action, String extras) {
super(resume);
this.action = action;
this.extras = (extras != null) ? ("&" + extras) : "";
}
/**
* {@inheritDoc}
*/
@Override
public void onCreate(Bundle icicle) {
Logger.setThreadLogTag(FxAccountConstants.GLOBAL_LOG_TAG);
Logger.debug(LOG_TAG, "onCreate(" + icicle + ")");
Locales.initializeLocale(getApplicationContext());
super.onCreate(icicle);
}
protected boolean redirectIfAppropriate() {
final boolean redirected = super.redirectIfAppropriate();
if (redirected) {
return true;
}
ActivityUtils.openURLInFennec(getApplicationContext(),
ABOUT_ACCOUNTS + "?action=" + action + extras);
return true;
}
@Override
public void onResume() {
super.onResume();
// We are always redirected.
this.finish();
}
}

View File

@ -133,3 +133,41 @@
<data android:scheme="package"/>
</intent-filter>
</receiver>
#ifndef MOZ_ANDROID_NATIVE_ACCOUNT_UI
<activity
android:exported="false"
android:name="org.mozilla.gecko.fxa.activities.FxAccountGetStartedActivityWeb">
<intent-filter>
<action android:name="@ANDROID_PACKAGE_NAME@.ACTION_FXA_GET_STARTED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:exported="false"
android:name="org.mozilla.gecko.fxa.activities.FxAccountUpdateCredentialsActivityWeb">
<intent-filter>
<action android:name="@ANDROID_PACKAGE_NAME@.ACTION_FXA_UPDATE_CREDENTIALS"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:exported="false"
android:name="org.mozilla.gecko.fxa.activities.FxAccountFinishMigratingActivityWeb">
<intent-filter>
<action android:name="@ANDROID_PACKAGE_NAME@.ACTION_FXA_FINISH_MIGRATING"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:exported="false"
android:name="org.mozilla.gecko.fxa.activities.FxAccountConfirmAccountActivityWeb">
<intent-filter>
<action android:name="@ANDROID_PACKAGE_NAME@.ACTION_FXA_CONFIRM_ACCOUNT"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
#endif