diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 801ccf845f7..08a817ea162 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1293,3 +1293,7 @@ pref("geo.wifi.uri", "https://www.googleapis.com/geolocation/v1/geolocate?key=%G // Necko IPC security checks only needed for app isolation for cookies/cache/etc: // currently irrelevant for desktop e10s pref("network.disable.ipc.security", true); + +// The URL where remote content that composes the UI for Firefox Accounts should +// be fetched. +pref("firefox.accounts.remoteUrl", "http://accounts.dev.lcip.org/flow"); diff --git a/browser/base/content/aboutaccounts/aboutaccounts.css b/browser/base/content/aboutaccounts/aboutaccounts.css new file mode 100644 index 00000000000..cf2bfa7b7c1 --- /dev/null +++ b/browser/base/content/aboutaccounts/aboutaccounts.css @@ -0,0 +1,21 @@ +* { + margin: 0; + padding: 0; +} + +html, body { + height: 100%; +} + +#content { + width: 100%; + height: 100%; + border: 0; + display: flex; +} + +#remote { + width: 100%; + height: 100%; + border: 0; +} diff --git a/browser/base/content/aboutaccounts/aboutaccounts.js b/browser/base/content/aboutaccounts/aboutaccounts.js new file mode 100644 index 00000000000..500616771f5 --- /dev/null +++ b/browser/base/content/aboutaccounts/aboutaccounts.js @@ -0,0 +1,89 @@ +/* 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/. */ + +"use strict"; + +const {classes: Cc, interfaces: Ci, utils: Cu} = Components; + +Cu.import("resource://gre/modules/Services.jsm"); + +function log(msg) { + //dump("FXA: " + msg + "\n"); +}; + +let wrapper = { + iframe: null, + + init: function () { + let iframe = document.getElementById("remote"); + this.iframe = iframe; + iframe.addEventListener("load", this); + iframe.src = this._getAccountsURI(); + }, + + handleEvent: function (evt) { + switch (evt.type) { + case "load": + this.iframe.contentWindow.addEventListener("FirefoxAccountsCommand", this); + this.iframe.removeEventListener("load", this); + break; + case "FirefoxAccountsCommand": + this.handleRemoteCommand(evt); + break; + } + }, + + onLogin: function (data) { + log("Received: 'login'. Data:" + JSON.stringify(data)); + this.injectData("message", { status: "login" }); + }, + + onCreate: function (data) { + log("Received: 'create'. Data:" + JSON.stringify(data)); + this.injectData("message", { status: "create" }); + }, + + onVerified: function (data) { + log("Received: 'verified'. Data:" + JSON.stringify(data)); + this.injectData("message", { status: "verified" }); + }, + + _getAccountsURI: function () { + return Services.urlFormatter.formatURLPref("firefox.accounts.remoteUrl"); + }, + + handleRemoteCommand: function (evt) { + log('command: ' + evt.detail.command); + let data = evt.detail.data; + + switch (evt.detail.command) { + case "create": + this.onCreate(data); + break; + case "login": + this.onLogin(data); + break; + case "verified": + this.onVerified(data); + break; + default: + log("Unexpected remote command received: " + evt.detail.command + ". Ignoring command."); + break; + } + }, + + injectData: function (type, content) { + let authUrl = this._getAccountsURI(); + + let data = { + type: type, + content: content + }; + + this.iframe.contentWindow.postMessage(data, authUrl); + }, +}; + +wrapper.init(); + diff --git a/browser/base/content/aboutaccounts/aboutaccounts.xhtml b/browser/base/content/aboutaccounts/aboutaccounts.xhtml new file mode 100644 index 00000000000..839ab0e141e --- /dev/null +++ b/browser/base/content/aboutaccounts/aboutaccounts.xhtml @@ -0,0 +1,28 @@ + + + + %htmlDTD; + + %brandDTD; + + %aboutAccountsDTD; +]> + + + + &aboutAccounts.pageTitle; + + + + +