// -*- indent-tabs-mode: nil; js-indent-level: 2 -*- /* 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/. */ /** * Wrap a remote fxa-content-server. * * An about:accounts tab loads and displays an fxa-content-server page, * depending on the current Android Account status and an optional 'action' * parameter. * * We show a spinner while the remote iframe is loading. We expect the * WebChannel message listening to the fxa-content-server to send this tab's * 's messageManager a LOADED message when the remote iframe provides * the WebChannel LOADED message. See the messageManager registration and the * |loadedDeferred| promise. This loosely couples the WebChannel implementation * and about:accounts! (We need this coupling in order to distinguish * WebChannel LOADED messages produced by multiple about:accounts tabs.) * * We capture error conditions by accessing the inner nsIWebNavigation of the * iframe directly. */ "use strict"; var {classes: Cc, interfaces: Ci, utils: Cu} = Components; /*global Components */ Cu.import("resource://gre/modules/Accounts.jsm"); /*global Accounts */ Cu.import("resource://gre/modules/PromiseUtils.jsm"); /*global PromiseUtils */ Cu.import("resource://gre/modules/Services.jsm"); /*global Services */ Cu.import("resource://gre/modules/XPCOMUtils.jsm"); /*global XPCOMUtils */ const ACTION_URL_PARAM = "action"; const COMMAND_LOADED = "fxaccounts:loaded"; const log = Cu.import("resource://gre/modules/AndroidLog.jsm", {}).AndroidLog.bind("FxAccounts"); XPCOMUtils.defineLazyServiceGetter(this, "ParentalControls", "@mozilla.org/parental-controls-service;1", "nsIParentalControlsService"); // Shows the toplevel element with |id| to be shown - all other top-level // elements are hidden. // If |id| is 'spinner', then 'remote' is also shown, with opacity 0. function show(id) { let allTop = document.querySelectorAll(".toplevel"); for (let elt of allTop) { if (elt.getAttribute("id") == id) { elt.style.display = 'block'; } else { elt.style.display = 'none'; } } if (id == 'spinner') { document.getElementById('remote').style.display = 'block'; document.getElementById('remote').style.opacity = 0; } } // Each time we try to load the remote