From ac6c6be1ca6f0719db7c7518f620ddde1b733ee0 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 30 Nov 2018 12:06:57 -0500 Subject: Issue #889 - Clean up the Pale Moon tree - Part 1d: Move sync to components --- .../base/content/sync/aboutSyncTabs-bindings.xml | 46 - .../palemoon/base/content/sync/aboutSyncTabs.css | 11 - .../palemoon/base/content/sync/aboutSyncTabs.js | 313 ------ .../palemoon/base/content/sync/aboutSyncTabs.xul | 68 -- .../palemoon/base/content/sync/addDevice.js | 157 --- .../palemoon/base/content/sync/addDevice.xul | 129 --- .../palemoon/base/content/sync/genericChange.js | 234 ----- .../palemoon/base/content/sync/genericChange.xul | 123 --- application/palemoon/base/content/sync/key.xhtml | 54 - .../palemoon/base/content/sync/notification.xml | 129 --- application/palemoon/base/content/sync/progress.js | 71 -- .../palemoon/base/content/sync/progress.xhtml | 55 - application/palemoon/base/content/sync/quota.js | 279 ----- application/palemoon/base/content/sync/quota.xul | 65 -- application/palemoon/base/content/sync/setup.js | 1071 -------------------- application/palemoon/base/content/sync/setup.xul | 491 --------- application/palemoon/base/content/sync/utils.js | 218 ---- application/palemoon/base/jar.mn | 19 - application/palemoon/components/moz.build | 3 + .../components/sync/aboutSyncTabs-bindings.xml | 46 + .../palemoon/components/sync/aboutSyncTabs.css | 11 + .../palemoon/components/sync/aboutSyncTabs.js | 313 ++++++ .../palemoon/components/sync/aboutSyncTabs.xul | 68 ++ application/palemoon/components/sync/addDevice.js | 157 +++ application/palemoon/components/sync/addDevice.xul | 129 +++ .../palemoon/components/sync/genericChange.js | 234 +++++ .../palemoon/components/sync/genericChange.xul | 123 +++ application/palemoon/components/sync/jar.mn | 22 + application/palemoon/components/sync/key.xhtml | 54 + application/palemoon/components/sync/moz.build | 8 + .../palemoon/components/sync/notification.xml | 129 +++ application/palemoon/components/sync/progress.js | 71 ++ .../palemoon/components/sync/progress.xhtml | 55 + application/palemoon/components/sync/quota.js | 279 +++++ application/palemoon/components/sync/quota.xul | 65 ++ application/palemoon/components/sync/setup.js | 1071 ++++++++++++++++++++ application/palemoon/components/sync/setup.xul | 491 +++++++++ application/palemoon/components/sync/utils.js | 218 ++++ 38 files changed, 3547 insertions(+), 3533 deletions(-) delete mode 100644 application/palemoon/base/content/sync/aboutSyncTabs-bindings.xml delete mode 100644 application/palemoon/base/content/sync/aboutSyncTabs.css delete mode 100644 application/palemoon/base/content/sync/aboutSyncTabs.js delete mode 100644 application/palemoon/base/content/sync/aboutSyncTabs.xul delete mode 100644 application/palemoon/base/content/sync/addDevice.js delete mode 100644 application/palemoon/base/content/sync/addDevice.xul delete mode 100644 application/palemoon/base/content/sync/genericChange.js delete mode 100644 application/palemoon/base/content/sync/genericChange.xul delete mode 100644 application/palemoon/base/content/sync/key.xhtml delete mode 100644 application/palemoon/base/content/sync/notification.xml delete mode 100644 application/palemoon/base/content/sync/progress.js delete mode 100644 application/palemoon/base/content/sync/progress.xhtml delete mode 100644 application/palemoon/base/content/sync/quota.js delete mode 100644 application/palemoon/base/content/sync/quota.xul delete mode 100644 application/palemoon/base/content/sync/setup.js delete mode 100644 application/palemoon/base/content/sync/setup.xul delete mode 100644 application/palemoon/base/content/sync/utils.js create mode 100644 application/palemoon/components/sync/aboutSyncTabs-bindings.xml create mode 100644 application/palemoon/components/sync/aboutSyncTabs.css create mode 100644 application/palemoon/components/sync/aboutSyncTabs.js create mode 100644 application/palemoon/components/sync/aboutSyncTabs.xul create mode 100644 application/palemoon/components/sync/addDevice.js create mode 100644 application/palemoon/components/sync/addDevice.xul create mode 100644 application/palemoon/components/sync/genericChange.js create mode 100644 application/palemoon/components/sync/genericChange.xul create mode 100644 application/palemoon/components/sync/jar.mn create mode 100644 application/palemoon/components/sync/key.xhtml create mode 100644 application/palemoon/components/sync/moz.build create mode 100644 application/palemoon/components/sync/notification.xml create mode 100644 application/palemoon/components/sync/progress.js create mode 100644 application/palemoon/components/sync/progress.xhtml create mode 100644 application/palemoon/components/sync/quota.js create mode 100644 application/palemoon/components/sync/quota.xul create mode 100644 application/palemoon/components/sync/setup.js create mode 100644 application/palemoon/components/sync/setup.xul create mode 100644 application/palemoon/components/sync/utils.js (limited to 'application/palemoon') diff --git a/application/palemoon/base/content/sync/aboutSyncTabs-bindings.xml b/application/palemoon/base/content/sync/aboutSyncTabs-bindings.xml deleted file mode 100644 index e6108209a..000000000 --- a/application/palemoon/base/content/sync/aboutSyncTabs-bindings.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/application/palemoon/base/content/sync/aboutSyncTabs.css b/application/palemoon/base/content/sync/aboutSyncTabs.css deleted file mode 100644 index 5a353175b..000000000 --- a/application/palemoon/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/application/palemoon/base/content/sync/aboutSyncTabs.js b/application/palemoon/base/content/sync/aboutSyncTabs.js deleted file mode 100644 index 410494b5b..000000000 --- a/application/palemoon/base/content/sync/aboutSyncTabs.js +++ /dev/null @@ -1,313 +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/. */ - -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/PlacesUtils.jsm", this); -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -var RemoteTabViewer = { - _tabsList: null, - - init: function () { - Services.obs.addObserver(this, "weave:service:login:finish", false); - Services.obs.addObserver(this, "weave:engine:sync:finish", false); - - this._tabsList = document.getElementById("tabsList"); - - this.buildList(true); - }, - - uninit: function () { - Services.obs.removeObserver(this, "weave:service:login:finish"); - Services.obs.removeObserver(this, "weave:engine:sync:finish"); - }, - - createItem: function(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: function(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: function() { - 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: function() { - 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: uri - , title: title - , hiddenRows: [ "description" - , "location" - , "loadInSidebar" - , "keyword" ] - }, window.top); - }, - - bookmarkSelectedTabs: function() { - 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: function (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: function (force) { - if (this._waitingForBuildList) { - this._buildListRequested = true; - return; - } - - this._waitingForBuildList = true; - this._buildListRequested = false; - - this._clearTabList(); - - if (Weave.Service.isLoggedIn && this._refetchTabs(force)) { - this._generateWeaveTabList(); - } else { - //XXXzpao We should say something about not being logged in & not having data - // or tell the appropriate condition. (bug 583344) - } - - function complete() { - this._waitingForBuildList = false; - if (this._buildListRequested) { - CommonUtils.nextTick(this.buildList, this); - } - } - - complete(); - }, - - _clearTabList: function () { - 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: function () { - let engine = Weave.Service.engineManager.get("tabs"); - let list = this._tabsList; - - let seenURLs = new Set(); - let localURLs = engine.getOpenURLs(); - - for (let [guid, client] in Iterator(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: url, - icon: this.getIcon(icon), - } - let tab = this.createItem(attrs); - list.appendChild(tab); - }, this); - } - }, - - adjustContextMenu: function(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: function(force) { - if (!force) { - // Don't bother refetching tabs if we already did so recently - let lastFetch = 0; - try { - lastFetch = Services.prefs.getIntPref("services.sync.lastTabFetch"); - } - catch (e) { - /* Just use the default value of 0 */ - } - - let now = Math.floor(Date.now() / 1000); - if (now - lastFetch < 30) { - return false; - } - } - - // if Clients hasn't synced yet this session, we need to sync it as well. - if (Weave.Service.clientsEngine.lastSync == 0) { - Weave.Service.clientsEngine.sync(); - } - - // Force a sync only for the tabs engine - let engine = Weave.Service.engineManager.get("tabs"); - engine.lastModified = null; - engine.sync(); - Services.prefs.setIntPref("services.sync.lastTabFetch", - Math.floor(Date.now() / 1000)); - - return true; - }, - - observe: function(subject, topic, data) { - switch (topic) { - case "weave:service:login:finish": - this.buildList(true); - break; - case "weave:engine:sync:finish": - if (subject == "tabs") { - this.buildList(false); - } - break; - } - }, - - handleClick: function(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/application/palemoon/base/content/sync/aboutSyncTabs.xul b/application/palemoon/base/content/sync/aboutSyncTabs.xul deleted file mode 100644 index a4aa0032f..000000000 --- a/application/palemoon/base/content/sync/aboutSyncTabs.xul +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - %aboutSyncTabsDTD; -]> - - -