firefox-patches/disable-send-to-device.patch
2017-11-24 23:18:39 +01:00

586 lines
24 KiB
Diff

--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -102,13 +102,6 @@
hidden="true"
oncommand="gBrowser.openNonRemoteWindow(TabContextMenu.contextTab);"/>
#endif
- <menuseparator id="context_sendTabToDevice_separator"/>
- <menu id="context_sendTabToDevice" label="&sendTabToDevice.label;"
- accesskey="&sendTabToDevice.accesskey;">
- <menupopup id="context_sendTabToDevicePopupMenu"
- onpopupshowing="gSync.populateSendTabToDevicesMenu(event.target, TabContextMenu.contextTab.linkedBrowser.currentURI.spec, TabContextMenu.contextTab.linkedBrowser.contentTitle);"/>
- </menu>
- <menuseparator/>
<menuitem id="context_reloadAllTabs" label="&reloadAllTabs.label;" accesskey="&reloadAllTabs.accesskey;"
tbattr="tabbrowser-multiple-visible"
oncommand="gBrowser.reloadAllTabs();"/>
@@ -409,46 +402,6 @@
</hbox>
</panel>
- <panel id="pageActionPanel"
- class="cui-widget-panel"
- role="group"
- type="arrow"
- hidden="true"
- flip="slide"
- photon="true"
- position="bottomcenter topright"
- tabspecific="true"
- noautofocus="true"
- copyURL-title="&pageAction.copyLink.label;"
- emailLink-title="&emailPageCmd.label;"
- sendToDevice-title="&pageAction.sendTabToDevice.label;"
- sendToDevice-notReadyTitle="&sendToDevice.syncNotReady.label;">
- <photonpanelmultiview id="pageActionPanelMultiView"
- mainViewId="pageActionPanelMainView"
- viewCacheId="appMenu-viewCache">
- <panelview id="pageActionPanelMainView"
- context="pageActionPanelContextMenu"
- oncontextmenu="BrowserPageActions.onContextMenu(event);"
- class="PanelUI-subView">
- <vbox class="panel-subview-body"/>
- </panelview>
- </photonpanelmultiview>
- </panel>
- <panel id="pageActionFeedback"
- role="alert"
- type="arrow"
- hidden="true"
- flip="slide"
- position="bottomcenter topright"
- tabspecific="true"
- noautofocus="true"
- copyURLFeedback="&copyURLFeedback.label;"
- sendToDeviceFeedback="&sendToDeviceFeedback.label;">
- <hbox id="pageActionFeedbackAnimatableBox">
- <image id="pageActionFeedbackAnimatableImage"/>
- </hbox>
- <label id="pageActionFeedbackMessage"/>
- </panel>
<menupopup id="pageActionPanelContextMenu"
onpopupshowing="BrowserPageActions.onContextMenuShowing(event, this);">
--- a/browser/base/content/browser-context.inc
+++ b/browser/base/content/browser-context.inc
@@ -258,14 +258,6 @@
label="&savePageCmd.label;"
accesskey="&savePageCmd.accesskey2;"
oncommand="gContextMenu.savePageAs();"/>
- <menuseparator id="context-sep-sendpagetodevice" hidden="true"/>
- <menu id="context-sendpagetodevice"
- label="&sendPageToDevice.label;"
- accesskey="&sendPageToDevice.accesskey;"
- hidden="true">
- <menupopup id="context-sendpagetodevice-popup"
- onpopupshowing="(() => { let browser = gBrowser || getPanelBrowser(); gSync.populateSendTabToDevicesMenu(event.target, browser.currentURI.spec, browser.contentTitle); })()"/>
- </menu>
<menuseparator id="context-sep-viewbgimage"/>
<menuitem id="context-viewbgimage"
label="&viewBGImageCmd.label;"
--- a/browser/base/content/test/sync/browser_contextmenu_sendtab.js
+++ b/browser/base/content/test/sync/browser_contextmenu_sendtab.js
@@ -1,86 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const chrome_base = "chrome://mochitests/content/browser/browser/base/content/test/general/";
-Services.scriptloader.loadSubScript(chrome_base + "head.js", this);
-/* import-globals-from ../general/head.js */
-
-const remoteClientsFixture = [ { id: 1, name: "Foo"}, { id: 2, name: "Bar"} ];
-
-let [testTab] = gBrowser.visibleTabs;
-
-add_task(async function setup() {
- await promiseSyncReady();
- is(gBrowser.visibleTabs.length, 1, "there is one visible tab");
-});
-
-// We are not testing the devices popup contents, since it is already tested by
-// browser_contextmenu_sendpage.js and the code to populate it is the same.
-
-add_task(async function test_tab_contextmenu() {
- const sandbox = setupSendTabMocks({ syncReady: true, clientsSynced: true, remoteClients: remoteClientsFixture,
- state: UIState.STATUS_SIGNED_IN, isSendableURI: true });
-
- await updateTabContextMenu(testTab);
- is(document.getElementById("context_sendTabToDevice").hidden, false, "Send tab to device is shown");
- is(document.getElementById("context_sendTabToDevice").disabled, false, "Send tab to device is enabled");
-
- sandbox.restore();
-});
-
-add_task(async function test_tab_contextmenu_unconfigured() {
- const sandbox = setupSendTabMocks({ syncReady: true, clientsSynced: true, remoteClients: remoteClientsFixture,
- state: UIState.STATUS_NOT_CONFIGURED, isSendableURI: true });
-
- await updateTabContextMenu(testTab);
- is(document.getElementById("context_sendTabToDevice").hidden, false, "Send tab to device is shown");
- is(document.getElementById("context_sendTabToDevice").disabled, false, "Send tab to device is enabled");
-
- sandbox.restore();
-});
-
-add_task(async function test_tab_contextmenu_not_sendable() {
- const sandbox = setupSendTabMocks({ syncReady: true, clientsSynced: true, remoteClients: [{ id: 1, name: "Foo"}],
- state: UIState.STATUS_SIGNED_IN, isSendableURI: false });
-
- await updateTabContextMenu(testTab);
- is(document.getElementById("context_sendTabToDevice").hidden, false, "Send tab to device is shown");
- is(document.getElementById("context_sendTabToDevice").disabled, true, "Send tab to device is disabled");
-
- sandbox.restore();
-});
-
-add_task(async function test_tab_contextmenu_not_synced_yet() {
- const sandbox = setupSendTabMocks({ syncReady: true, clientsSynced: false, remoteClients: [],
- state: UIState.STATUS_SIGNED_IN, isSendableURI: true });
-
- await updateTabContextMenu(testTab);
- is(document.getElementById("context_sendTabToDevice").hidden, false, "Send tab to device is shown");
- is(document.getElementById("context_sendTabToDevice").disabled, true, "Send tab to device is disabled");
-
- sandbox.restore();
-});
-
-add_task(async function test_tab_contextmenu_sync_not_ready_configured() {
- const sandbox = setupSendTabMocks({ syncReady: false, clientsSynced: false, remoteClients: null,
- state: UIState.STATUS_SIGNED_IN, isSendableURI: true });
-
- await updateTabContextMenu(testTab);
- is(document.getElementById("context_sendTabToDevice").hidden, false, "Send tab to device is shown");
- is(document.getElementById("context_sendTabToDevice").disabled, true, "Send tab to device is disabled");
-
- sandbox.restore();
-});
-
-add_task(async function test_tab_contextmenu_sync_not_ready_other_state() {
- const sandbox = setupSendTabMocks({ syncReady: false, clientsSynced: false, remoteClients: null,
- state: UIState.STATUS_NOT_VERIFIED, isSendableURI: true });
-
- await updateTabContextMenu(testTab);
- is(document.getElementById("context_sendTabToDevice").hidden, false, "Send tab to device is shown");
- is(document.getElementById("context_sendTabToDevice").disabled, false, "Send tab to device is enabled");
-
- sandbox.restore();
-});
--- a/browser/base/content/browser-sync.js
+++ b/browser/base/content/browser-sync.js
@@ -283,205 +283,6 @@
});
},
- openSendToDevicePromo() {
- let url = Services.prefs.getCharPref("app.productInfo.baseURL");
- url += "send-tabs/?utm_source=" + Services.appinfo.name.toLowerCase();
- switchToTabHavingURI(url, true, { replaceQueryString: true });
- },
-
- sendTabToDevice(url, clientId, title) {
- Weave.Service.clientsEngine.sendURIToClientForDisplay(url, clientId, title).catch(e => {
- console.error("Could not send tab to device", e);
- });
- },
-
- populateSendTabToDevicesMenu(devicesPopup, url, title, createDeviceNodeFn) {
- if (!createDeviceNodeFn) {
- createDeviceNodeFn = (clientId, name, clientType) => {
- let eltName = name ? "menuitem" : "menuseparator";
- return document.createElement(eltName);
- };
- }
-
- // remove existing menu items
- for (let i = devicesPopup.childNodes.length - 1; i >= 0; --i) {
- let child = devicesPopup.childNodes[i];
- if (child.classList.contains("sync-menuitem")) {
- child.remove();
- }
- }
-
- if (gSync.syncConfiguredAndLoading) {
- // We can only be in this case in the page action menu.
- return;
- }
-
- const fragment = document.createDocumentFragment();
-
- const state = UIState.get();
- if (state.status == UIState.STATUS_SIGNED_IN && this.remoteClients.length > 0) {
- this._appendSendTabDeviceList(fragment, createDeviceNodeFn, url, title);
- } else if (state.status == UIState.STATUS_SIGNED_IN) {
- this._appendSendTabSingleDevice(fragment, createDeviceNodeFn);
- } else if (state.status == UIState.STATUS_NOT_VERIFIED ||
- state.status == UIState.STATUS_LOGIN_FAILED) {
- this._appendSendTabVerify(fragment, createDeviceNodeFn);
- } else /* status is STATUS_NOT_CONFIGURED */ {
- this._appendSendTabUnconfigured(fragment, createDeviceNodeFn);
- }
-
- devicesPopup.appendChild(fragment);
- },
-
- _appendSendTabDeviceList(fragment, createDeviceNodeFn, url, title) {
- const onTargetDeviceCommand = (event) => {
- let clients = event.target.getAttribute("clientId") ?
- [event.target.getAttribute("clientId")] :
- this.remoteClients.map(client => client.id);
-
- clients.forEach(clientId => this.sendTabToDevice(url, clientId, title));
- }
-
- function addTargetDevice(clientId, name, clientType) {
- const targetDevice = createDeviceNodeFn(clientId, name, clientType);
- targetDevice.addEventListener("command", onTargetDeviceCommand, true);
- targetDevice.classList.add("sync-menuitem", "sendtab-target");
- targetDevice.setAttribute("clientId", clientId);
- targetDevice.setAttribute("clientType", clientType);
- targetDevice.setAttribute("label", name);
- fragment.appendChild(targetDevice);
- }
-
- const clients = this.remoteClients;
- for (let client of clients) {
- const type = client.formfactor && client.formfactor.includes("tablet") ?
- "tablet" : client.type;
- addTargetDevice(client.id, client.name, type);
- }
-
- // "Send to All Devices" menu item
- if (clients.length > 1) {
- const separator = createDeviceNodeFn();
- separator.classList.add("sync-menuitem");
- fragment.appendChild(separator);
- const allDevicesLabel = this.fxaStrings.GetStringFromName("sendToAllDevices.menuitem");
- addTargetDevice("", allDevicesLabel, "");
- }
- },
-
- _appendSendTabSingleDevice(fragment, createDeviceNodeFn) {
- const noDevices = this.fxaStrings.GetStringFromName("sendTabToDevice.singledevice.status");
- const learnMore = this.fxaStrings.GetStringFromName("sendTabToDevice.singledevice");
- this._appendSendTabInfoItems(fragment, createDeviceNodeFn, noDevices, learnMore, () => {
- this.openSendToDevicePromo();
- });
- },
-
- _appendSendTabVerify(fragment, createDeviceNodeFn) {
- const notVerified = this.fxaStrings.GetStringFromName("sendTabToDevice.verify.status");
- const verifyAccount = this.fxaStrings.GetStringFromName("sendTabToDevice.verify");
- this._appendSendTabInfoItems(fragment, createDeviceNodeFn, notVerified, verifyAccount, () => {
- this.openPrefs("sendtab");
- });
- },
-
- _appendSendTabUnconfigured(fragment, createDeviceNodeFn) {
- const notConnected = this.fxaStrings.GetStringFromName("sendTabToDevice.unconfigured.status");
- const learnMore = this.fxaStrings.GetStringFromName("sendTabToDevice.unconfigured");
- this._appendSendTabInfoItems(fragment, createDeviceNodeFn, notConnected, learnMore, () => {
- this.openSendToDevicePromo();
- });
-
- // Now add a 'sign in to sync' item above the 'learn more' item.
- const signInToSync = this.fxaStrings.GetStringFromName("sendTabToDevice.signintosync");
- let signInItem = createDeviceNodeFn(null, signInToSync, null);
- signInItem.classList.add("sync-menuitem");
- signInItem.setAttribute("label", signInToSync);
- // Show an icon if opened in the page action panel:
- if (signInItem.classList.contains("subviewbutton")) {
- signInItem.classList.add("subviewbutton-iconic", "signintosync");
- }
- signInItem.addEventListener("command", () => {
- this.openPrefs("sendtab");
- });
- fragment.insertBefore(signInItem, fragment.lastChild);
- },
-
- _appendSendTabInfoItems(fragment, createDeviceNodeFn, statusLabel, actionLabel, actionCommand) {
- const status = createDeviceNodeFn(null, statusLabel, null);
- status.setAttribute("label", statusLabel);
- status.setAttribute("disabled", true);
- status.classList.add("sync-menuitem");
- fragment.appendChild(status);
-
- const separator = createDeviceNodeFn(null, null, null);
- separator.classList.add("sync-menuitem");
- fragment.appendChild(separator);
-
- const actionItem = createDeviceNodeFn(null, actionLabel, null);
- actionItem.addEventListener("command", actionCommand, true);
- actionItem.classList.add("sync-menuitem");
- actionItem.setAttribute("label", actionLabel);
- fragment.appendChild(actionItem);
- },
-
- isSendableURI(aURISpec) {
- if (!aURISpec) {
- return false;
- }
- // Disallow sending tabs with more than 65535 characters.
- if (aURISpec.length > 65535) {
- return false;
- }
- try {
- // Filter out un-sendable URIs -- things like local files, object urls, etc.
- const unsendableRegexp = new RegExp(
- Services.prefs.getCharPref("services.sync.engine.tabs.filteredUrls"), "i");
- return !unsendableRegexp.test(aURISpec);
- } catch (e) {
- // The preference has been removed, or is an invalid regexp, so we log an
- // error and treat it as a valid URI -- and the more problematic case is
- // the length, which we've already addressed.
- Cu.reportError(`Failed to build url filter regexp for send tab: ${e}`);
- return true;
- }
- },
-
- // "Send Tab to Device" menu item
- updateTabContextMenu(aPopupMenu, aTargetTab) {
- const enabled = !this.syncConfiguredAndLoading &&
- this.isSendableURI(aTargetTab.linkedBrowser.currentURI.spec);
-
- document.getElementById("context_sendTabToDevice").disabled = !enabled;
- },
-
- // "Send Page to Device" and "Send Link to Device" menu items
- updateContentContextMenu(contextMenu) {
- // showSendLink and showSendPage are mutually exclusive
- const showSendLink = contextMenu.onSaveableLink || contextMenu.onPlainTextLink;
- const showSendPage = !showSendLink
- && !(contextMenu.isContentSelected ||
- contextMenu.onImage || contextMenu.onCanvas ||
- contextMenu.onVideo || contextMenu.onAudio ||
- contextMenu.onLink || contextMenu.onTextInput);
-
- ["context-sendpagetodevice", "context-sep-sendpagetodevice"]
- .forEach(id => contextMenu.showItem(id, showSendPage));
- ["context-sendlinktodevice", "context-sep-sendlinktodevice"]
- .forEach(id => contextMenu.showItem(id, showSendLink));
-
- if (!showSendLink && !showSendPage) {
- return;
- }
-
- const targetURI = showSendLink ? contextMenu.linkURL :
- contextMenu.browser.currentURI.spec;
- const enabled = !this.syncConfiguredAndLoading && this.isSendableURI(targetURI);
- contextMenu.setItemAttr(showSendPage ? "context-sendpagetodevice" :
- "context-sendlinktodevice",
- "disabled", !enabled || null);
- },
-
// Functions called by observers
onActivityStart() {
clearTimeout(this._syncAnimationTimer);
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -973,8 +973,6 @@
SessionStoreInternal._resetLocalTabRestoringState(tab);
SessionStoreInternal.restoreNextTab();
- this._sendTabRestoredNotification(tab, data.isRemotenessUpdate);
-
Services.obs.notifyObservers(null, "sessionstore-one-or-no-tab-restored");
break;
case "SessionStore:crashedTabRevived":
@@ -4608,22 +4606,6 @@
},
/**
- * Dispatch the SSTabRestored event for the given tab.
- * @param aTab
- * The tab which has been restored
- * @param aIsRemotenessUpdate
- * True if this tab was restored due to flip from running from
- * out-of-main-process to in-main-process or vice-versa.
- */
- _sendTabRestoredNotification(aTab, aIsRemotenessUpdate) {
- let event = aTab.ownerDocument.createEvent("CustomEvent");
- event.initCustomEvent("SSTabRestored", true, false, {
- isRemotenessUpdate: aIsRemotenessUpdate,
- });
- aTab.dispatchEvent(event);
- },
-
- /**
* @param aWindow
* Window reference
* @returns whether this window's data is still cached in _statesToRestore
--- a/browser/locales/en-US/chrome/browser/accounts.properties
+++ b/browser/locales/en-US/chrome/browser/accounts.properties
@@ -35,33 +35,6 @@
deviceDisconnectedNotification.title = Sync Disconnected
deviceDisconnectedNotification.body = This computer has been successfully disconnected from Firefox Sync.
-# LOCALIZATION NOTE (sendToAllDevices.menuitem)
-# Displayed in the Send Tab/Page/Link to Device context menu when right clicking a tab, a page or a link.
-sendToAllDevices.menuitem = Send to All Devices
-
-# LOCALIZATION NOTE (sendTabToDevice.unconfigured, sendTabToDevice.unconfigured.status)
-# Displayed in the Send Tabs context menu when right clicking a tab, a page or a link
-# and the Sync account is unconfigured. Redirects to a marketing page.
-sendTabToDevice.unconfigured.status = Not Connected to Sync
-sendTabToDevice.unconfigured = Learn About Sending Tabs…
-
-# LOCALIZATION NOTE (sendTabToDevice.signintosync)
-# Displayed in the Send Tabs context menu and the page action panel when sync is not
-# configured. Allows users to immediately sign into sync via the preferences.
-sendTabToDevice.signintosync = Sign in to Sync…
-
-# LOCALIZATION NOTE (sendTabToDevice.singledevice, sendTabToDevice.singledevice.status)
-# Displayed in the Send Tabs context menu when right clicking a tab, a page or a link
-# and the Sync account has only 1 device. Redirects to a marketing page.
-sendTabToDevice.singledevice.status = No Devices Connected
-sendTabToDevice.singledevice = Learn About Sending Tabs…
-
-# LOCALIZATION NOTE (sendTabToDevice.verify, sendTabToDevice.verify.status)
-# Displayed in the Send Tabs context menu when right clicking a tab, a page or a link
-# and the Sync account is unverified. Redirects to the Sync preferences page.
-sendTabToDevice.verify.status = Account Not Verified
-sendTabToDevice.verify = Verify Your Account…
-
# LOCALIZATION NOTE (tabArrivingNotification.title, tabArrivingNotificationWithDevice.title,
# multipleTabsArrivingNotification.title, unnamedTabsArrivingNotification2.body,
# unnamedTabsArrivingNotificationMultiple2.body, unnamedTabsArrivingNotificationNoDevice.body)
--- a/browser/base/content/test/general/browser_contextmenu.js
+++ b/browser/base/content/test/general/browser_contextmenu.js
@@ -44,8 +44,6 @@
...(hasPocket ? ["context-savelinktopocket", true] : []),
"context-copylink", true,
"context-searchselect", true,
- "---", null,
- "context-sendlinktodevice", true, [], null,
]
);
@@ -97,8 +95,6 @@
"context-savepage", true,
...(hasPocket ? ["context-pocket", true] : []),
"---", null,
- "context-sendpagetodevice", true, [], null,
- "---", null,
"context-viewbgimage", false,
"context-selectall", true,
"---", null,
@@ -125,8 +121,6 @@
...(hasPocket ? ["context-savelinktopocket", true] : []),
"context-copylink", true,
"context-searchselect", true,
- "---", null,
- "context-sendlinktodevice", true, [], null,
]
);
});
@@ -268,8 +262,6 @@
"context-savepage", true,
...(hasPocket ? ["context-pocket", true] : []),
"---", null,
- "context-sendpagetodevice", true, [], null,
- "---", null,
"context-viewbgimage", false,
"context-selectall", true,
"frame", null,
@@ -572,8 +564,6 @@
"context-savepage", true,
...(hasPocket ? ["context-pocket", true] : []),
"---", null,
- "context-sendpagetodevice", true, [], null,
- "---", null,
"context-viewbgimage", false,
"context-selectall", true,
"---", null,
@@ -606,8 +596,6 @@
"context-savepage", true,
...(hasPocket ? ["context-pocket", true] : []),
"---", null,
- "context-sendpagetodevice", true, [], null,
- "---", null,
"context-viewbgimage", false,
"context-selectall", true,
"---", null,
@@ -655,8 +643,6 @@
"context-savepage", true,
...(hasPocket ? ["context-pocket", true] : []),
"---", null,
- "context-sendpagetodevice", true, [], null,
- "---", null,
"context-viewbgimage", false,
"context-selectall", true,
"---", null,
@@ -704,7 +690,6 @@
"---", null,
"context-searchselect", true,
"---", null,
- "context-sendlinktodevice", true, [], null,
"context-viewpartialsource-selection", true
],
{
@@ -746,8 +731,6 @@
"context-sendimage", true,
"context-setDesktopBackground", true,
"context-viewimageinfo", true,
- "---", null,
- "context-sendlinktodevice", true, [], null,
]
);
});
@@ -840,8 +823,6 @@
"context-savepage", true,
...(hasPocket ? ["context-pocket", true] : []),
"---", null,
- "context-sendpagetodevice", true, [], null,
- "---", null,
"context-viewbgimage", false,
"context-selectall", true,
"---", null,
@@ -887,8 +868,6 @@
"context-savepage", true,
...(hasPocket ? ["context-pocket", true] : []),
"---", null,
- "context-sendpagetodevice", true, [], null,
- "---", null,
"context-viewbgimage", false,
"context-selectall", true,
"frame", null,
@@ -940,8 +919,6 @@
...(hasPocket ? ["context-savelinktopocket", true] : []),
"context-copylink", true,
"context-searchselect", true,
- "---", null,
- "context-sendlinktodevice", true, [], null,
]
);
@@ -959,8 +936,6 @@
...(hasPocket ? ["context-savelinktopocket", true] : []),
"context-copylink", true,
"context-searchselect", true,
- "---", null,
- "context-sendlinktodevice", true, [], null,
]
);
@@ -978,8 +953,6 @@
...(hasPocket ? ["context-savelinktopocket", true] : []),
"context-copylink", true,
"context-searchselect", true,
- "---", null,
- "context-sendlinktodevice", true, [], null,
]
);
});
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -738,7 +738,6 @@
},
initSyncItems() {
- gSync.updateContentContextMenu(this);
},
openPasswordManager() {