commit 0568bb05a16da0210f4d5bd32782d66eb09a3901 Author: Mike Perry mikeperry-git@fscked.org Date: Fri Jul 1 13:53:12 2011 -0700
Bug #2361: Make about window work again on FF4+.
Also make the links work, finally. --- src/chrome/content/about.xul | 69 +++++++++++++++++++++++++-------- src/chrome/content/popup.xul | 2 +- src/chrome/content/torbutton.js | 42 -------------------- src/chrome/content/torbutton_util.js | 20 ++++++++++ src/chrome/locale/en/torbutton.dtd | 7 +++ 5 files changed, 80 insertions(+), 60 deletions(-)
diff --git a/src/chrome/content/about.xul b/src/chrome/content/about.xul index e5d18b6..2323e53 100644 --- a/src/chrome/content/about.xul +++ b/src/chrome/content/about.xul @@ -4,22 +4,57 @@ <!DOCTYPE overlay SYSTEM "chrome://torbutton/locale/torbutton.dtd">
<dialog id="torbutton-about" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - xmlns:html="http://www.w3.org/1999/xhtml" - title="&torbutton.about.title;" - buttons="accept" - persist="screenX screenY" - onload="torbutton_about_init();"> + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + xmlns:html="http://www.w3.org/1999/xhtml" + buttons="accept" + title="&torbutton.about.title;" + width="500" + height="400" + align="center" + onload="torbutton_about_init();">
- <script type="application/x-javascript" src="torbutton.js" /> - <stringbundleset id="extensionsSet"> - <stringbundle id="extensionsStrings" src="chrome://mozapps/locale/extensions/extensions.properties"/> - </stringbundleset> - <label value="Torbutton" style="font-weight: bold;"/> - <label id="torbuttonVersion"/> - <label value="Scott Squires & Mike Perry"/> - <label value="https://torbutton.torproject.org/dev/" - class="url" - style="color: blue; text-decoration: underline;" - onclick="window.open('https://torbutton.torproject.org/dev/%27);%22/%3E + <script type="application/x-javascript" src="torbutton_util.js" /> + + <vbox> + <label style="text-align:center; color: blue; cursor:hand; text-decoration: underline;font-weight:bold; font-size:22px;" + value="&torbutton.button.label;" + onmouseover="event.target.style.cursor='pointer'" + onmouseout="event.target.style.cursor='default'" + onclick="Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow('navigator:browser').open('https://www.torproject.org/torbutton/%27)%22/%3E + <label style="text-align:center; font-size:18px; margin-top: 10px; margin-bottom:20px;">&torbutton.about.summary;</label> + + <groupbox> + <caption label="&torbutton.about.version;" /> + <label id="torbuttonVersion"/> + </groupbox> + + <groupbox> + <caption label="&torbutton.about.maintainer;" /> + <label>Mike Perry</label> + </groupbox> + + <groupbox> + <caption label="&torbutton.about.code;" /> + <label>arno, Collin Jackson, Kory Kirk, Edward Pastuszenski, and Scott Squires</label> + </groupbox> + +<!-- + Hrmm.. It is probably wrong to give the impression that these people do + continual review. Right now, no one does that :(. These two used to, but + we haven't heard much from them lately. + <groupbox> + <caption label="&torbutton.about.security_review;" /> + <label>Gregory Fleischer, Kyle Williams, and many others.</label> + </groupbox> +--> + + <label style="font-weight:bold; margin-top:50px;"> + &torbutton.about.donate;<label id="donate link" + value="&torbutton.about.make_donation;" + style="color: blue; cursor:hand; text-decoration:underline; font-style:bold" + onmouseover="event.target.style.cursor='pointer'" + onmouseout="event.target.style.cursor='default'" + onclick="Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow('navigator:browser').open('https://www.torproject.org/donate/donate.html.en%27)%22/%3E + </label> + </vbox> </dialog> diff --git a/src/chrome/content/popup.xul b/src/chrome/content/popup.xul index bd6fc35..2297ccf 100644 --- a/src/chrome/content/popup.xul +++ b/src/chrome/content/popup.xul @@ -30,7 +30,7 @@ label="&torbutton.context_menu.about;" accesskey="&torbutton.context_menu.about.key;" insertafter="context-stop" - oncommand="torbutton_open_about_dialog()"/> + oncommand="window.open('chrome://torbutton/content/about.xul', '', 'chrome,centerscreen');"/> </menupopup>
</overlay> diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js index 4a70b66..8c905d1 100644 --- a/src/chrome/content/torbutton.js +++ b/src/chrome/content/torbutton.js @@ -1741,48 +1741,6 @@ function torbutton_open_prefs_dialog() { torbutton_log(2, 'opened preferences window'); }
-function torbutton_open_about_dialog() { - var extensionManager = Components.classes["@mozilla.org/extensions/manager;1"] - .getService(Components.interfaces.nsIExtensionManager); - var database = '@mozilla.org/rdf/datasource;1?name=composite-datasource'; - var extension_id = ''; - database = Components.classes[database] - .getService(Components.interfaces.nsIRDFCompositeDataSource); - database.AddDataSource(extensionManager.datasource); - - if (torbutton_gecko_compare("1.8") <= 0) - { - // Firefox 1.5 -- use built-in about box - extension_id = "urn:mozilla:item:{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}"; - window.openDialog("chrome://mozapps/content/extensions/about.xul","","chrome",extension_id,database); - } else { - // Firefox 1.0 -- home page link is broken in built-in about box, use our own - extension_id = "urn:mozilla:extension:{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}"; - window.openDialog("chrome://torbutton/content/about.xul","","chrome",extension_id,database); - } -} - -function torbutton_about_init() { - var extensionID = window.arguments[0]; - var extensionDB = window.arguments[1]; - - var oBundle = Components.classes["@mozilla.org/intl/stringbundle;1"] - .getService(Components.interfaces.nsIStringBundleService); - var extensionsStrings = document.getElementById("extensionsStrings"); - - var rdfs = Components.classes["@mozilla.org/rdf/rdf-service;1"] - .getService(Components.interfaces.nsIRDFService); - var extension = rdfs.GetResource(extensionID); - - var versionArc = rdfs.GetResource("http://www.mozilla.org/2004/em-rdf#version"); - var version = extensionDB.GetTarget(extension, versionArc, true); - version = version.QueryInterface(Components.interfaces.nsIRDFLiteral).Value; - - var extensionVersion = document.getElementById("torbuttonVersion"); - - extensionVersion.setAttribute("value", extensionsStrings.getFormattedString("aboutWindowVersionString", [version])); -} - function torbutton_gecko_compare(aVersion) { var ioService = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); diff --git a/src/chrome/content/torbutton_util.js b/src/chrome/content/torbutton_util.js index 808c826..b93162e 100644 --- a/src/chrome/content/torbutton_util.js +++ b/src/chrome/content/torbutton_util.js @@ -224,3 +224,23 @@ function torbutton_get_stringbundle() return o_stringbundle; }
+function torbutton_about_init() { + try { + // Firefox 4 and later; Mozilla 2 and later + Components.utils.import("resource://gre/modules/AddonManager.jsm"); + AddonManager.getAddonByID("{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}",function(addon) { + var extensionVersion = document.getElementById("torbuttonVersion"); + extensionVersion.setAttribute("value", addon.version); + }); + } catch (ex) { + // Firefox 3.6 and before; Mozilla 1.9.2 and before + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + var addon = em.getItemForID("{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}"); + var extensionVersion = document.getElementById("torbuttonVersion"); + extensionVersion.setAttribute("value", addon.version); + } + +} + + diff --git a/src/chrome/locale/en/torbutton.dtd b/src/chrome/locale/en/torbutton.dtd index 998eb76..0da56d5 100644 --- a/src/chrome/locale/en/torbutton.dtd +++ b/src/chrome/locale/en/torbutton.dtd @@ -16,6 +16,13 @@ <!ENTITY torbutton.prefs.proxy.host.socks "SOCKS Host:"> <!ENTITY torbutton.prefs.proxy.port "Port:"> <!ENTITY torbutton.about.title "About Torbutton"> +<!ENTITY torbutton.about.version "Version:"> +<!ENTITY torbutton.about.summary "Protects the privacy of your Tor browsing."> +<!ENTITY torbutton.about.code "Code Contributors:"> +<!ENTITY torbutton.about.maintainer "Maintainer:"> +<!ENTITY torbutton.about.security_review "Security Review:"> +<!ENTITY torbutton.about.donate "If you like using Tor, you might consider"> +<!ENTITY torbutton.about.make_donation "making a donation."> <!ENTITY torbutton.pref_connection.notice "Disable Torbutton to change these settings."> <!ENTITY torbutton.pref_connection.more_info "More information"> <!ENTITY torbutton.pref_connection_more_info.title "Help">