diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 426d38b23a16..fdb2541f7603 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -237,6 +237,8 @@ pref("browser.startup.homepage", "about:home"); // Whether we should skip the homepage when opening the first-run page pref("browser.startup.firstrunSkipsHomepage", true); +pref("browser.dedicatedprofile.welcome.accounts.endpoint", "https://accounts.firefox.com/"); + // Show an about:blank window as early as possible for quick startup feedback. // Held to nightly on Linux due to bug 1450626. // Disabled on Mac because the bouncing dock icon already provides feedback. diff --git a/browser/base/content/newInstallPage.js b/browser/base/content/newInstallPage.js index 1ac36daa9fa6..11b78470e3db 100644 --- a/browser/base/content/newInstallPage.js +++ b/browser/base/content/newInstallPage.js @@ -4,9 +4,10 @@ const PARAMS = new URL(location).searchParams; const ENTRYPOINT = "new-install-page"; -const SOURCE = `new-install-page-${RPMGetUpdateChannel()}`; +const SOURCE = `new-install-page-${PARAMS.get("channel")}`; const CAMPAIGN = "dedicated-profiles"; const ENDPOINT = PARAMS.get("endpoint"); +const CONTEXT = "fx_desktop_v3"; function appendAccountsParams(url) { url.searchParams.set("entrypoint", ENTRYPOINT); @@ -23,8 +24,7 @@ function appendParams(url, params) { } async function requestFlowMetrics() { - let requestURL = new URL(await endpoint); - requestURL.pathname = "metrics-flow"; + let requestURL = new URL(`${ENDPOINT}metrics-flow`); appendParams(requestURL, { "form_type": "email", }); @@ -47,9 +47,11 @@ async function submitForm(event) { let { flowId, flowBeginTime } = await metrics; - let requestURL = new URL(await endpoint); + let requestURL = new URL(ENDPOINT); appendParams(requestURL, { + "service": "sync", "action": "email", + "context": CONTEXT, "utm_campaign": CAMPAIGN, "email": input.value, "flow_id": flowId, @@ -59,8 +61,6 @@ async function submitForm(event) { window.open(requestURL, "_blank", "noopener"); } -const endpoint = RPMGetFxAccountsEndpoint(ENTRYPOINT); - // This must come before the CSP is set or it will be blocked. const metrics = requestFlowMetrics(); diff --git a/browser/components/nsBrowserContentHandler.js b/browser/components/nsBrowserContentHandler.js index ecb08a61cd2f..6bc7f651fdd1 100644 --- a/browser/components/nsBrowserContentHandler.js +++ b/browser/components/nsBrowserContentHandler.js @@ -15,7 +15,6 @@ XPCOMUtils.defineLazyModuleGetters(this, { SessionStartup: "resource:///modules/sessionstore/SessionStartup.jsm", ShellService: "resource:///modules/ShellService.jsm", UpdatePing: "resource://gre/modules/UpdatePing.jsm", - RemotePages: "resource://gre/modules/remotepagemanager/RemotePageManagerParent.jsm", }); XPCOMUtils.defineLazyServiceGetter(this, "WindowsUIUtils", "@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils"); @@ -24,8 +23,6 @@ XPCOMUtils.defineLazyGetter(this, "gSystemPrincipal", () => Services.scriptSecurityManager.getSystemPrincipal()); XPCOMUtils.defineLazyGlobalGetters(this, [URL]); -const NEWINSTALL_PAGE = "about:newinstall"; - function shouldLoadURI(aURI) { if (aURI && !aURI.schemeIs("chrome")) return true; @@ -63,14 +60,12 @@ function resolveURIInternal(aCmdLine, aArgument) { return uri; } -let gRemoteInstallPage = null; - function getNewInstallPage() { - if (!gRemoteInstallPage) { - gRemoteInstallPage = new RemotePages(NEWINSTALL_PAGE); - } - - return NEWINSTALL_PAGE; + let url = new URL("about:newinstall"); + let endpoint = Services.prefs.getCharPref("browser.dedicatedprofile.welcome.accounts.endpoint"); + url.searchParams.set("endpoint", endpoint); + url.searchParams.set("channel", AppConstants.MOZ_UPDATE_CHANNEL); + return url.toString(); } var gFirstWindow = false; diff --git a/toolkit/components/remotepagemanager/MessagePort.jsm b/toolkit/components/remotepagemanager/MessagePort.jsm index da72b1549856..a9350ac9fe4b 100644 --- a/toolkit/components/remotepagemanager/MessagePort.jsm +++ b/toolkit/components/remotepagemanager/MessagePort.jsm @@ -11,10 +11,6 @@ ChromeUtils.defineModuleGetter(this, "AsyncPrefs", "resource://gre/modules/AsyncPrefs.jsm"); ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm"); -ChromeUtils.defineModuleGetter(this, "PromiseUtils", - "resource://gre/modules/PromiseUtils.jsm"); -ChromeUtils.defineModuleGetter(this, "UpdateUtils", - "resource://gre/modules/UpdateUtils.jsm"); /* * Used for all kinds of permissions checks which requires explicit @@ -35,10 +31,6 @@ let RPMAccessManager = { "app.support.baseURL"], "isWindowPrivate": ["yes"], }, - "about:newinstall": { - "getUpdateChannel": ["yes"], - "getFxAccountsEndpoint": ["yes"], - }, }, checkAllowAccess(aPrincipal, aFeature, aValue) { @@ -134,107 +126,18 @@ class MessagePort { this.destroyed = false; this.listener = new MessageListener(); - // This is a sparse array of pending requests. The id of each request is - // simply its index in the array. The next id is the current length of the - // array (which includes the count of missing indexes). - this.requests = []; - this.message = this.message.bind(this); - this.receiveRequest = this.receiveRequest.bind(this); - this.receiveResponse = this.receiveResponse.bind(this); - this.addMessageListeners(); - } - - addMessageListeners() { this.messageManager.addMessageListener("RemotePage:Message", this.message); - this.messageManager.addMessageListener("RemotePage:Request", this.receiveRequest); - this.messageManager.addMessageListener("RemotePage:Response", this.receiveResponse); - } - - removeMessageListeners() { - this.messageManager.removeMessageListener("RemotePage:Message", this.message); - this.messageManager.removeMessageListener("RemotePage:Request", this.receiveRequest); - this.messageManager.removeMessageListener("RemotePage:Response", this.receiveResponse); } // Called when the message manager used to connect to the other process has // changed, i.e. when a tab is detached. swapMessageManager(messageManager) { - this.removeMessageListeners(); + this.messageManager.removeMessageListener("RemotePage:Message", this.message); + this.messageManager = messageManager; - this.addMessageListeners(); - } - // Sends a request to the other process and returns a promise that completes - // once the other process has responded to the request or some error occurs. - sendRequest(name, data = null) { - if (this.destroyed) { - return this.window.Promise.reject(new Error("Message port has been destroyed")); - } - - let deferred = PromiseUtils.defer(); - this.requests.push(deferred); - - this.messageManager.sendAsyncMessage("RemotePage:Request", { - portID: this.portID, - requestID: this.requests.length - 1, - name, - data, - }); - - return this.wrapPromise(deferred.promise); - } - - // Handles an IPC message to perform a request of some kind. - async receiveRequest({ data: messagedata }) { - if (this.destroyed || (messagedata.portID != this.portID)) { - return; - } - - let data = { - portID: this.portID, - requestID: messagedata.requestID, - }; - - try { - data.resolve = await this.handleRequest(messagedata.name, messagedata.data); - } catch (e) { - data.reject = e; - } - - this.messageManager.sendAsyncMessage("RemotePage:Response", data); - } - - // Handles an IPC message with the response of a request. - receiveResponse({ data: messagedata }) { - if (this.destroyed || (messagedata.portID != this.portID)) { - return; - } - - let deferred = this.requests[messagedata.requestID]; - if (!deferred) { - Cu.reportError("Received a response to an unknown request."); - return; - } - - delete this.requests[messagedata.requestID]; - - if ("resolve" in messagedata) { - deferred.resolve(messagedata.resolve); - } else if ("reject" in messagedata) { - deferred.reject(messagedata.reject); - } else { - deferred.reject(new Error("Internal RPM error.")); - } - } - - // Handles an IPC message containing any message. - message({ data: messagedata }) { - if (this.destroyed || (messagedata.portID != this.portID)) { - return; - } - - this.handleMessage(messagedata); + this.messageManager.addMessageListener("RemotePage:Message", this.message); } /* Adds a listener for messages. Many callbacks can be registered for the @@ -281,24 +184,12 @@ class MessagePort { destroy() { try { // This can fail in the child process if the tab has already been closed - this.removeMessageListeners(); + this.messageManager.removeMessageListener("RemotePage:Message", this.message); } catch (e) { } - - for (let deferred of this.requests) { - if (deferred) { - deferred.reject(new Error("Message port has been destroyed")); - } - } - this.messageManager = null; this.destroyed = true; this.portID = null; this.listener = null; - this.requests = []; - } - - wrapPromise(promise) { - return new this.window.Promise((resolve, reject) => promise.then(resolve, reject)); } getBoolPref(aPref) { @@ -310,7 +201,11 @@ class MessagePort { } setBoolPref(aPref, aVal) { - return this.wrapPromise(AsyncPrefs.set(aPref, aVal)); + return new this.window.Promise(function(resolve) { + AsyncPrefs.set(aPref, aVal).then(function() { + resolve(); + }); + }); } getFormatURLPref(aFormatURL) { @@ -328,21 +223,4 @@ class MessagePort { } return PrivateBrowsingUtils.isContentWindowPrivate(this.window); } - - getUpdateChannel() { - let principal = this.window.document.nodePrincipal; - if (!RPMAccessManager.checkAllowAccess(principal, "getUpdateChannel", "yes")) { - throw new Error("RPMAccessManager does not allow access to getUpdateChannel"); - } - return UpdateUtils.UpdateChannel; - } - - getFxAccountsEndpoint(aEntrypoint) { - let principal = this.window.document.nodePrincipal; - if (!RPMAccessManager.checkAllowAccess(principal, "getFxAccountsEndpoint", "yes")) { - throw new Error("RPMAccessManager does not allow access to getFxAccountsEndpoint"); - } - - return this.sendRequest("FxAccountsEndpoint", aEntrypoint); - } } diff --git a/toolkit/components/remotepagemanager/RemotePageManagerChild.jsm b/toolkit/components/remotepagemanager/RemotePageManagerChild.jsm index f6abd1714e5d..517d802ea27b 100644 --- a/toolkit/components/remotepagemanager/RemotePageManagerChild.jsm +++ b/toolkit/components/remotepagemanager/RemotePageManagerChild.jsm @@ -41,12 +41,6 @@ class ChildMessagePort extends MessagePort { Cu.exportFunction(this.isWindowPrivate.bind(this), window, { defineAs: "RPMIsWindowPrivate", }); - Cu.exportFunction(this.getUpdateChannel.bind(this), window, { - defineAs: "RPMGetUpdateChannel", - }); - Cu.exportFunction(this.getFxAccountsEndpoint.bind(this), window, { - defineAs: "RPMGetFxAccountsEndpoint", - }); // Send a message for load events let loadListener = () => { @@ -73,13 +67,13 @@ class ChildMessagePort extends MessagePort { }); } - // Called when the content process is requesting some data. - async handleRequest(name, data) { - throw new Error(`Unknown request ${name}.`); - } + // Called when a message is received from the message manager. This could + // have come from any port in the message manager so verify the port ID. + message({ data: messagedata }) { + if (this.destroyed || (messagedata.portID != this.portID)) { + return; + } - // Called when a message is received from the message manager. - handleMessage(messagedata) { let message = { name: messagedata.name, data: messagedata.data, diff --git a/toolkit/components/remotepagemanager/RemotePageManagerParent.jsm b/toolkit/components/remotepagemanager/RemotePageManagerParent.jsm index f18a31a2d296..57a6f0208b42 100644 --- a/toolkit/components/remotepagemanager/RemotePageManagerParent.jsm +++ b/toolkit/components/remotepagemanager/RemotePageManagerParent.jsm @@ -21,8 +21,6 @@ var EXPORTED_SYMBOLS = ["RemotePages", "RemotePageManager"]; const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); const {MessageListener, MessagePort} = ChromeUtils.import("resource://gre/modules/remotepagemanager/MessagePort.jsm"); -ChromeUtils.defineModuleGetter(this, "FxAccounts", - "resource://gre/modules/FxAccounts.jsm"); /** * Creates a RemotePages object which listens for new remote pages of some @@ -236,17 +234,13 @@ class ChromeMessagePort extends MessagePort { this.destroy(); } - // Called when the content process is requesting some data. - async handleRequest(name, data) { - if (name == "FxAccountsEndpoint") { - return FxAccounts.config.promiseEmailFirstURI(data); + // Called when a message is received from the message manager. This could + // have come from any port in the message manager so verify the port ID. + message({ data: messagedata }) { + if (this.destroyed || (messagedata.portID != this.portID)) { + return; } - throw new Error(`Unknown request ${name}.`); - } - - // Called when a message is received from the message manager. - handleMessage(messagedata) { let message = { target: this.publicPort, name: messagedata.name,