www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit aae77c60158c930c66e032733d44cd79da1f95df
parent beefefd01627bd803c4717b344ee10a9df2bfca7
Author: Simon Kornblith <simon@simonster.com>
Date:   Thu, 25 Aug 2011 07:35:22 +0000

Add-on discovery support for Zotero Standalone, part 1


Diffstat:
Achrome/content/zotero/standalone/extensionsOverlay.js | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Achrome/content/zotero/standalone/extensionsOverlay.xul | 8++++++++
Mchrome/content/zotero/standalone/standalone.js | 28++++++++++++++++++++++++++--
Mchrome/content/zotero/standalone/standalone.xul | 2+-
Mchrome/locale/en-US/zotero/zotero.properties | 2++
5 files changed, 115 insertions(+), 3 deletions(-)

diff --git a/chrome/content/zotero/standalone/extensionsOverlay.js b/chrome/content/zotero/standalone/extensionsOverlay.js @@ -0,0 +1,77 @@ +/* + ***** BEGIN LICENSE BLOCK ***** + + Copyright © 2011 Center for History and New Media + George Mason University, Fairfax, Virginia, USA + http://zotero.org + + This file is part of Zotero. + + Zotero is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Zotero is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with Zotero. If not, see <http://www.gnu.org/licenses/>. + + The Original Code is the Extension Manager UI. + + The Initial Developer of the Original Code is the Mozilla Foundation. + Portions created by the Initial Developer are Copyright (C) 2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Blair McBride <bmcbride@mozilla.com> + Simon Kornblith <simon@zotero.org</a> + + ***** END LICENSE BLOCK ***** +*/ + +gDiscoverView.onLocationChange = function(aWebProgress, aRequest, aLocation) { + // Ignore the about:blank load + if (aLocation.spec == "about:blank") + return; + + // When using the real session history the inner-frame will update the + // session history automatically, if using the fake history though it must + // be manually updated + if (gHistory == FakeHistory) { + var docshell = aWebProgress.QueryInterface(Ci.nsIDocShell); + + var state = { + view: "addons://discover/", + url: aLocation.spec + }; + + var replaceHistory = Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY << 16; + if (docshell.loadType & replaceHistory) + gHistory.replaceState(state); + else + gHistory.pushState(state); + gViewController.lastHistoryIndex = gHistory.index; + } + + gViewController.updateCommands(); + + // In Zotero, we override the behavior below to allow pages on other sites + + /*// If the hostname is the same as the new location's host and either the + // default scheme is insecure or the new location is secure then continue + // with the load + if (aLocation.host == this.homepageURL.host && + (!this.homepageURL.schemeIs("https") || aLocation.schemeIs("https"))) + return; + + // Canceling the request will send an error to onStateChange which will show + // the error page + aRequest.cancel(Components.results.NS_BINDING_ABORTED);*/ +} + +// Don't care about http/https +gDiscoverView.onSecurityChange = function() {}; +\ No newline at end of file diff --git a/chrome/content/zotero/standalone/extensionsOverlay.xul b/chrome/content/zotero/standalone/extensionsOverlay.xul @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<overlay id="zotero-addons" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + + <page id="addons-page"> + <script type="application/javascript" src="chrome://zotero/content/standalone/extensionsOverlay.js"/> + </page> +</overlay> diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js @@ -28,8 +28,7 @@ Components.utils.import("resource://gre/modules/Services.jsm"); /** * This object contains the various functions for the interface */ -var ZoteroStandalone = new function() -{ +const ZoteroStandalone = new function() { /** * Run when standalone window first opens */ @@ -65,6 +64,12 @@ var ZoteroStandalone = new function() handlerInfo.alwaysAskBeforeHandling = false; hs.store(handlerInfo); } + + // Add add-on listeners (not yet hooked up)Services.obs.addObserver(gXPInstallObserver, "addon-install-disabled", false); + Services.obs.addObserver(gXPInstallObserver, "addon-install-started", false); + Services.obs.addObserver(gXPInstallObserver, "addon-install-blocked", false); + Services.obs.addObserver(gXPInstallObserver, "addon-install-failed", false); + Services.obs.addObserver(gXPInstallObserver, "addon-install-complete", false); } /** @@ -171,5 +176,24 @@ function toOpenWindowByType(inType, uri, features) } } +const gXPInstallObserver = { + observe: function (aSubject, aTopic, aData) { + var installInfo = aSubject.QueryInterface(Components.interfaces.amIWebInstallInfo); + var win = installInfo.originatingWindow; + switch (aTopic) { + case "addon-install-disabled": + case "addon-install-blocked": + case "addon-install-failed": + var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + promptService.alert(win, Zotero.getString("standalone.addonInstallationFailed.title"), + Zotero.getString("standalone.addonInstallationFailed.body", installInfo.installs[0].name)); + break; + /*case "addon-install-started": + case "addon-install-complete":*/ + } + } +}; + window.addEventListener("load", function(e) { ZoteroStandalone.onLoad(e); }, false); window.addEventListener("unload", function(e) { ZoteroStandalone.onUnload(e); }, false); \ No newline at end of file diff --git a/chrome/content/zotero/standalone/standalone.xul b/chrome/content/zotero/standalone/standalone.xul @@ -170,7 +170,7 @@ command="cmd_zotero_rtfScan"/> <menuseparator/> <menuitem id="menu_addons" label="&addons.label;" - oncommand="ZoteroStandalone.openInViewer('about:addons')"/> + oncommand="ZoteroStandalone.openInViewer('chrome://mozapps/content/extensions/extensions.xul')"/> </menupopup> </menu> diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties @@ -738,6 +738,8 @@ locate.libraryLookup.tooltip = Look up this item using the selected OpenURL res locate.manageLocateEngines = Manage Lookup Engines… standalone.corruptInstallation = Your Zotero Standalone installation appears to be corrupted due to a failed auto-update. While Zotero may continue to function, to avoid potential bugs, please download the latest version of Zotero Standalone from http://zotero.org/support/standalone as soon as possible. +standalone.addonInstallationFailed.title = Add-on Installation Failed +standalone.addonInstallationFailed.body = The add-on "%S" could not be installed. It may be incompatible with this version of Zotero Standalone. connector.error.title = Zotero Connector Error connector.standaloneOpen = Your database cannot be accessed because Zotero Standalone is currently open. Please view your items in Zotero Standalone. \ No newline at end of file