Bug 1432277 - Replace iOS and Android link in Prefs for signed-in users with device actions. r=eoger

MozReview-Commit-ID: 1Lwe2g1bFpw

--HG--
extra : rebase_source : 6529420b5a2e1b4438f2472313abbc7e7dcf7dc1
This commit is contained in:
Mark Hammond 2018-01-23 17:47:19 +11:00
parent 298150d827
commit 4772b1fe2e
4 changed files with 28 additions and 11 deletions

View File

@ -139,12 +139,20 @@ var gSyncPane = {
return Services.strings.createBundle("chrome://browser/locale/accounts.properties");
});
// Links for mobile devices before the user is logged in.
let url = Services.prefs.getCharPref("identity.mobilepromo.android") + "sync-preferences";
document.getElementById("fxaMobilePromo-android").setAttribute("href", url);
document.getElementById("fxaMobilePromo-android-hasFxaAccount").setAttribute("href", url);
url = Services.prefs.getCharPref("identity.mobilepromo.ios") + "sync-preferences";
document.getElementById("fxaMobilePromo-ios").setAttribute("href", url);
document.getElementById("fxaMobilePromo-ios-hasFxaAccount").setAttribute("href", url);
// Links for mobile devices shown after the user is logged in.
fxAccounts.promiseAccountsConnectDeviceURI(this._getEntryPoint()).then(connectURI => {
document.getElementById("mobilePromo-singledevice").setAttribute("href", connectURI);
});
fxAccounts.promiseAccountsManageDevicesURI(this._getEntryPoint()).then(manageURI => {
document.getElementById("mobilePromo-multidevice").setAttribute("href", manageURI);
});
document.getElementById("tosPP-small-ToS").setAttribute("href", Weave.Svc.Prefs.get("fxa.termsURL"));
document.getElementById("tosPP-small-PP").setAttribute("href", Weave.Svc.Prefs.get("fxa.privacyURL"));
@ -321,6 +329,10 @@ var gSyncPane = {
fxAccounts.promiseAccountsManageURI(this._getEntryPoint()).then(accountsManageURI => {
document.getElementById("verifiedManage").setAttribute("href", accountsManageURI);
});
// The mobile promo links - which one is shown depends on the number of devices.
let isMultiDevice = Weave.Service.clientsEngine.stats.numClients > 1;
document.getElementById("mobilePromo-singledevice").hidden = isMultiDevice;
document.getElementById("mobilePromo-multidevice").hidden = !isMultiDevice;
},
_getEntryPoint() {

View File

@ -205,15 +205,10 @@
hidden="true"/>
</hbox>
</groupbox>
<label class="fxaMobilePromo">
&mobilePromo3.start;<!-- We put these comments to avoid inserting white spaces
--><image class="androidLink"></image><label class="text-link" id="fxaMobilePromo-android-hasFxaAccount"><!--
-->&mobilePromo3.androidLink;</label><!--
-->&mobilePromo3.iOSBefore;<!--
--><image class="iOSLink"></image><label class="text-link" id="fxaMobilePromo-ios-hasFxaAccount"><!--
-->&mobilePromo3.iOSLink;</label><!--
-->&mobilePromo3.end;
</label>
<label id="mobilePromo-singledevice"
class="text-link fxaMobilePromo">&mobilepromo.singledevice;</label>
<label id="mobilePromo-multidevice"
class="text-link fxaMobilePromo">&mobilepromo.multidevice;</label>
<vbox id="tosPP-small" align="start">
<label id="tosPP-small-ToS" class="text-link">
&prefs.tosLink.label;

View File

@ -101,3 +101,6 @@ both, to better adapt this sentence to their language.
<!ENTITY mobilePromo3.iOSLink "iOS">
<!ENTITY mobilePromo3.end " to sync with your mobile device.">
<!ENTITY mobilepromo.singledevice "Connect another device">
<!ENTITY mobilepromo.multidevice "Manage devices">

View File

@ -66,6 +66,7 @@ var publicProperties = [
"promiseAccountsForceSigninURI",
"promiseAccountsManageURI",
"promiseAccountsManageDevicesURI",
"promiseAccountsConnectDeviceURI",
"promiseAccountsSignUpURI",
"promiseAccountsSignInURI",
"removeCachedOAuthToken",
@ -1485,6 +1486,12 @@ FxAccountsInternal.prototype = {
return this._formatPrefURL("identity.fxaccounts.settings.devices.uri", entrypoint);
},
// Returns a promise that resolves with the URL to use to connect a new
// device to the current user's FxA acct.
async promiseAccountsConnectDeviceURI(entrypoint) {
return this._formatPrefURL("identity.fxaccounts.remote.connectdevice.uri", entrypoint);
},
/**
* Get an OAuth token for the user
*