From ca11d95460f208be4bf721b4426743d1f84e44a2 Mon Sep 17 00:00:00 2001 From: Edouard Oger Date: Wed, 17 May 2017 11:39:22 -0400 Subject: [PATCH] Bug 1365273 - Remove about:sync-tabs. r=markh MozReview-Commit-ID: HFsc4xf8N3a --HG-- extra : rebase_source : 841763ceb5a2ce3630e2f0f3625f7d3d20569135 --- .../content/sync/aboutSyncTabs-bindings.xml | 48 --- browser/base/content/sync/aboutSyncTabs.css | 11 - browser/base/content/sync/aboutSyncTabs.js | 305 ------------------ browser/base/content/sync/aboutSyncTabs.xul | 68 ---- browser/base/jar.mn | 4 - browser/components/about/AboutRedirector.cpp | 2 - browser/components/build/nsModule.cpp | 1 - .../en-US/chrome/browser/aboutSyncTabs.dtd | 20 -- browser/locales/jar.mn | 1 - browser/themes/linux/aboutSyncTabs.css | 105 ------ browser/themes/linux/jar.mn | 1 - browser/themes/osx/aboutSyncTabs.css | 105 ------ browser/themes/osx/jar.mn | 1 - browser/themes/windows/aboutSyncTabs.css | 105 ------ browser/themes/windows/jar.mn | 1 - netwerk/base/nsNetUtil.cpp | 3 +- 16 files changed, 1 insertion(+), 780 deletions(-) delete mode 100644 browser/base/content/sync/aboutSyncTabs-bindings.xml delete mode 100644 browser/base/content/sync/aboutSyncTabs.css delete mode 100644 browser/base/content/sync/aboutSyncTabs.js delete mode 100644 browser/base/content/sync/aboutSyncTabs.xul delete mode 100644 browser/locales/en-US/chrome/browser/aboutSyncTabs.dtd delete mode 100644 browser/themes/linux/aboutSyncTabs.css delete mode 100644 browser/themes/osx/aboutSyncTabs.css delete mode 100644 browser/themes/windows/aboutSyncTabs.css diff --git a/browser/base/content/sync/aboutSyncTabs-bindings.xml b/browser/base/content/sync/aboutSyncTabs-bindings.xml deleted file mode 100644 index 60cf18607423..000000000000 --- a/browser/base/content/sync/aboutSyncTabs-bindings.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/browser/base/content/sync/aboutSyncTabs.css b/browser/base/content/sync/aboutSyncTabs.css deleted file mode 100644 index 5a353175b1ef..000000000000 --- a/browser/base/content/sync/aboutSyncTabs.css +++ /dev/null @@ -1,11 +0,0 @@ -/* 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/. */ - -richlistitem[type="tab"] { - -moz-binding: url(chrome://browser/content/sync/aboutSyncTabs-bindings.xml#tab-listing); -} - -richlistitem[type="client"] { - -moz-binding: url(chrome://browser/content/sync/aboutSyncTabs-bindings.xml#client-listing); -} diff --git a/browser/base/content/sync/aboutSyncTabs.js b/browser/base/content/sync/aboutSyncTabs.js deleted file mode 100644 index fb9e5c57cb32..000000000000 --- a/browser/base/content/sync/aboutSyncTabs.js +++ /dev/null @@ -1,305 +0,0 @@ -/* 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/. */ - -/* import-globals-from ../utilityOverlay.js */ - -var Cu = Components.utils; - -Cu.import("resource://services-common/utils.js"); -Cu.import("resource://services-sync/main.js"); -Cu.import("resource:///modules/PlacesUIUtils.jsm"); -Cu.import("resource://gre/modules/AppConstants.jsm"); -Cu.import("resource://gre/modules/PlacesUtils.jsm", this); -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "Promise", - "resource://gre/modules/Promise.jsm"); - -var RemoteTabViewer = { - _tabsList: null, - - init() { - Services.obs.addObserver(this, "weave:service:login:finish"); - Services.obs.addObserver(this, "weave:engine:sync:finish"); - - this._tabsList = document.getElementById("tabsList"); - - this.buildList(true); - }, - - uninit() { - Services.obs.removeObserver(this, "weave:service:login:finish"); - Services.obs.removeObserver(this, "weave:engine:sync:finish"); - }, - - createItem(attrs) { - let item = document.createElement("richlistitem"); - - // Copy the attributes from the argument into the item. - for (let attr in attrs) { - item.setAttribute(attr, attrs[attr]); - } - - if (attrs["type"] == "tab") { - item.label = attrs.title != "" ? attrs.title : attrs.url; - } - - return item; - }, - - filterTabs(event) { - let val = event.target.value.toLowerCase(); - let numTabs = this._tabsList.getRowCount(); - let clientTabs = 0; - let currentClient = null; - - for (let i = 0; i < numTabs; i++) { - let item = this._tabsList.getItemAtIndex(i); - let hide = false; - if (item.getAttribute("type") == "tab") { - if (!item.getAttribute("url").toLowerCase().includes(val) && - !item.getAttribute("title").toLowerCase().includes(val)) { - hide = true; - } else { - clientTabs++; - } - } else if (item.getAttribute("type") == "client") { - if (currentClient) { - if (clientTabs == 0) { - currentClient.hidden = true; - } - } - currentClient = item; - clientTabs = 0; - } - item.hidden = hide; - } - if (clientTabs == 0) { - currentClient.hidden = true; - } - }, - - openSelected() { - let items = this._tabsList.selectedItems; - let urls = []; - for (let i = 0; i < items.length; i++) { - if (items[i].getAttribute("type") == "tab") { - urls.push(items[i].getAttribute("url")); - let index = this._tabsList.getIndexOfItem(items[i]); - this._tabsList.removeItemAt(index); - } - } - if (urls.length) { - getTopWin().gBrowser.loadTabs(urls); - this._tabsList.clearSelection(); - } - }, - - bookmarkSingleTab() { - let item = this._tabsList.selectedItems[0]; - let uri = Weave.Utils.makeURI(item.getAttribute("url")); - let title = item.getAttribute("title"); - PlacesUIUtils.showBookmarkDialog({ action: "add" - , type: "bookmark" - , uri - , title - , hiddenRows: [ "description" - , "location" - , "loadInSidebar" - , "keyword" ] - }, window.top); - }, - - bookmarkSelectedTabs() { - let items = this._tabsList.selectedItems; - let URIs = []; - for (let i = 0; i < items.length; i++) { - if (items[i].getAttribute("type") == "tab") { - let uri = Weave.Utils.makeURI(items[i].getAttribute("url")); - if (!uri) { - continue; - } - - URIs.push(uri); - } - } - if (URIs.length) { - PlacesUIUtils.showBookmarkDialog({ action: "add" - , type: "folder" - , URIList: URIs - , hiddenRows: [ "description" ] - }, window.top); - } - }, - - getIcon(iconUri, defaultIcon) { - try { - let iconURI = Weave.Utils.makeURI(iconUri); - return PlacesUtils.favicons.getFaviconLinkForIcon(iconURI).spec; - } catch (ex) { - // Do nothing. - } - - // Just give the provided default icon or the system's default. - return defaultIcon || PlacesUtils.favicons.defaultFavicon.spec; - }, - - _waitingForBuildList: false, - - _buildListRequested: false, - - buildList(forceSync) { - if (this._waitingForBuildList) { - this._buildListRequested = true; - return; - } - - this._waitingForBuildList = true; - this._buildListRequested = false; - - this._clearTabList(); - - if (Weave.Service.isLoggedIn) { - this._refetchTabs(forceSync); - this._generateWeaveTabList(); - } else { - // XXXzpao We should say something about not being logged in & not having data - // or tell the appropriate condition. (bug 583344) - } - - this._waitingForBuildList = false; - if (this._buildListRequested) { - CommonUtils.nextTick(this.buildList, this); - } - }, - - _clearTabList() { - let list = this._tabsList; - - // Clear out existing richlistitems. - let count = list.getRowCount(); - if (count > 0) { - for (let i = count - 1; i >= 0; i--) { - list.removeItemAt(i); - } - } - }, - - _generateWeaveTabList() { - let engine = Weave.Service.engineManager.get("tabs"); - let list = this._tabsList; - - let seenURLs = new Set(); - let localURLs = engine.getOpenURLs(); - - for (let [, client] of Object.entries(engine.getAllClients())) { - // Create the client node, but don't add it in-case we don't show any tabs - let appendClient = true; - - client.tabs.forEach(function({title, urlHistory, icon}) { - let url = urlHistory[0]; - if (!url || localURLs.has(url) || seenURLs.has(url)) { - return; - } - seenURLs.add(url); - - if (appendClient) { - let attrs = { - type: "client", - clientName: client.clientName, - class: Weave.Service.clientsEngine.isMobile(client.id) ? "mobile" : "desktop" - }; - let clientEnt = this.createItem(attrs); - list.appendChild(clientEnt); - appendClient = false; - clientEnt.disabled = true; - } - let attrs = { - type: "tab", - title: title || url, - url, - icon: this.getIcon(icon), - } - let tab = this.createItem(attrs); - list.appendChild(tab); - }, this); - } - }, - - adjustContextMenu(event) { - let mode = "all"; - switch (this._tabsList.selectedItems.length) { - case 0: - break; - case 1: - mode = "single" - break; - default: - mode = "multiple"; - break; - } - - let menu = document.getElementById("tabListContext"); - let el = menu.firstChild; - while (el) { - let showFor = el.getAttribute("showFor"); - if (showFor) { - el.hidden = showFor != mode && showFor != "all"; - } - - el = el.nextSibling; - } - }, - - _refetchTabs(force) { - if (!force) { - // Don't bother refetching tabs if we already did so recently - let lastFetch = Services.prefs.getIntPref("services.sync.lastTabFetch", 0); - - let now = Math.floor(Date.now() / 1000); - if (now - lastFetch < 30) { - return false; - } - } - - // Ask Sync to just do the tabs engine if it can. - Weave.Service.sync(["tabs"]); - Services.prefs.setIntPref("services.sync.lastTabFetch", - Math.floor(Date.now() / 1000)); - - return true; - }, - - observe(subject, topic, data) { - switch (topic) { - case "weave:service:login:finish": - // A login has finished, which means that a Sync is about to start and - // we will eventually get to the "tabs" engine - but try and force the - // tab engine to sync first by passing |true| for the forceSync param. - this.buildList(true); - break; - case "weave:engine:sync:finish": - if (data == "tabs") { - // The tabs engine just finished, so re-build the list without - // forcing a new sync of the tabs engine. - this.buildList(false); - } - break; - } - }, - - handleClick(event) { - if (event.target.getAttribute("type") != "tab") { - return; - } - - if (event.button == 1) { - let url = event.target.getAttribute("url"); - openUILink(url, event); - let index = this._tabsList.getIndexOfItem(event.target); - this._tabsList.removeItemAt(index); - } - } -} diff --git a/browser/base/content/sync/aboutSyncTabs.xul b/browser/base/content/sync/aboutSyncTabs.xul deleted file mode 100644 index 4247fd7e6475..000000000000 --- a/browser/base/content/sync/aboutSyncTabs.xul +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - %aboutSyncTabsDTD; -]> - - -