blob: e33e9c577650450610fbc45a1b93519f10207e4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/* 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.content.Intent;
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.sync.setup.activities.ActivityUtils;
/**
* Activity which shows the status activity or passes through to web flow.
*/
public abstract class FxAccountWebFlowActivity extends FxAccountAbstractActivity {
protected static final String LOG_TAG = FxAccountWebFlowActivity.class.getSimpleName();
protected static final String ABOUT_ACCOUNTS = "about:accounts";
public static final String EXTRA_ENDPOINT = "entrypoint";
protected static final String[] EXTRAS_TO_PASSTHROUGH = new String[] {
EXTRA_ENDPOINT,
};
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;
}
final StringBuilder sb = new StringBuilder();
sb.append(ABOUT_ACCOUNTS);
sb.append("?action=");
sb.append(action);
sb.append(extras);
// Pass through a set of known string values from intent extras to about:accounts.
final Intent intent = getIntent();
if (intent != null) {
for (String key : EXTRAS_TO_PASSTHROUGH) {
final String value = intent.getStringExtra(key);
if (value != null) {
sb.append("&");
sb.append(key);
sb.append("=");
sb.append(value);
}
}
}
ActivityUtils.openURLInFennec(getApplicationContext(), sb.toString());
return true;
}
@Override
public void onResume() {
super.onResume();
// We are always redirected.
this.finish();
}
}
|