From bcaf18313e17a9a64f3bd963d447002cd54a710b Mon Sep 17 00:00:00 2001 From: Allison Naaktgeboren Date: Wed, 19 Oct 2011 14:29:24 -0700 Subject: [PATCH] Bug 675822 - Part 1: Sync desktop status page with upload progress bar. r=philikon --- browser/base/content/browser.js | 2 +- browser/base/content/syncProgress.js | 72 +++++++++++++++ browser/base/content/syncProgress.xhtml | 86 ++++++++++++++++++ browser/base/jar.mn | 2 + .../en-US/chrome/browser/syncProgress.dtd | 11 +++ browser/locales/jar.mn | 1 + browser/themes/gnomestripe/browser/jar.mn | 2 + .../themes/gnomestripe/browser/sync-128.png | Bin 0 -> 20229 bytes .../gnomestripe/browser/syncProgress.css | 79 ++++++++++++++++ browser/themes/pinstripe/browser/jar.mn | 2 + browser/themes/pinstripe/browser/sync-128.png | Bin 0 -> 20229 bytes .../themes/pinstripe/browser/syncProgress.css | 79 ++++++++++++++++ browser/themes/winstripe/browser/jar.mn | 4 + browser/themes/winstripe/browser/sync-128.png | Bin 0 -> 20229 bytes .../themes/winstripe/browser/syncProgress.css | 79 ++++++++++++++++ 15 files changed, 418 insertions(+), 1 deletion(-) create mode 100644 browser/base/content/syncProgress.js create mode 100644 browser/base/content/syncProgress.xhtml create mode 100644 browser/locales/en-US/chrome/browser/syncProgress.dtd create mode 100644 browser/themes/gnomestripe/browser/sync-128.png create mode 100644 browser/themes/gnomestripe/browser/syncProgress.css create mode 100644 browser/themes/pinstripe/browser/sync-128.png create mode 100644 browser/themes/pinstripe/browser/syncProgress.css create mode 100644 browser/themes/winstripe/browser/sync-128.png create mode 100644 browser/themes/winstripe/browser/syncProgress.css diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 58f5674ecd6a..c59faea73cd9 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -4158,7 +4158,7 @@ var XULBrowserWindow = { startTime: 0, statusText: "", isBusy: false, - inContentWhitelist: ["about:addons", "about:permissions"], + inContentWhitelist: ["about:addons", "about:permissions", "chrome://browser/content/syncProgress.xhtml"], QueryInterface: function (aIID) { if (aIID.equals(Ci.nsIWebProgressListener) || diff --git a/browser/base/content/syncProgress.js b/browser/base/content/syncProgress.js new file mode 100644 index 000000000000..3a89f54f844f --- /dev/null +++ b/browser/base/content/syncProgress.js @@ -0,0 +1,72 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Firefox Sync. + * + * The Initial Developer of the Original Code is the Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Allison Naaktgeboren (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://services-sync/main.js"); + +let gProgressBar; +let gCounter = 0; + +function onLoad(event) { + Services.obs.addObserver(increaseProgressBar, "weave:engine:sync:finish", false); + Services.obs.addObserver(increaseProgressBar, "weave:engine:sync:error", false); + gProgressBar = document.getElementById('uploadProgressBar'); + + if (Services.prefs.getPrefType("services.sync.firstSync") != Ci.nsIPrefBranch.PREF_INVALID) { + gProgressBar.max = Weave.Engines.getEnabled().length; + gProgressBar.style.display = "inline"; + } + else { + gProgressBar.style.display = "none"; + } +} + +function onUnload(event) { + Services.obs.removeObserver(increaseProgressBar, "weave:engine:sync:finish"); + Services.obs.removeObserver(increaseProgressBar, "weave:engine:sync:error"); +} + +function increaseProgressBar(){ + gCounter += 1; + gProgressBar.setAttribute("value", gCounter); +} + +function closeTab() { + window.close(); +} diff --git a/browser/base/content/syncProgress.xhtml b/browser/base/content/syncProgress.xhtml new file mode 100644 index 000000000000..897b0287aac2 --- /dev/null +++ b/browser/base/content/syncProgress.xhtml @@ -0,0 +1,86 @@ + +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License +# Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is Firefox Sync. +# +# The Initial Developer of the Original Code is the Mozilla Foundation. +# Portions created by the Initial Developer are Copyright (C) 2011 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Allison Naaktgeboren (original author) +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + + + %htmlDTD; + + %syncProgressDTD; + + %syncSetupDTD; +]> + + + + &syncProgress.pageTitle; + + + + + +