Commit 8a5dc8c5 authored by Arthur Edelstein's avatar Arthur Edelstein Committed by Georg Koppen
Browse files

Bug 20614: Add links to Tor Browser User Manual

parent 15496115
...@@ -241,7 +241,14 @@ window.addEventListener("pageshow", function() { ...@@ -241,7 +241,14 @@ window.addEventListener("pageshow", function() {
<div class="bubble"> <div class="bubble">
<h1>&aboutTor.whatnextQuestion.label;</h1> <h1>&aboutTor.whatnextQuestion.label;</h1>
<p>&aboutTor.whatnextAnswer.label;</p> <p>&aboutTor.whatnextAnswer.label;</p>
<a class="tips" href="&aboutTor.whatnext.link;">&aboutTor.whatnext.label;</a> <ul>
<li class="showForManual">
<a href="&aboutTor.torbrowser_user_manual.link;">
&aboutTor.torbrowser_user_manual.label;
</a>
</li>
<li><a href="&aboutTor.whatnext.link;">&aboutTor.whatnext.label;</a></li>
</ul>
</div> </div>
<div class="bubble"> <div class="bubble">
......
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- Mode: HTML -*- --> <?xml version="1.0" encoding="UTF-8"?> <!-- -*- Mode: HTML -*- -->
<!-- Bug 18905: Hide unused help menu items --> <!DOCTYPE overlay SYSTEM "chrome://torbutton/locale/torbutton.dtd">
<overlay id="torbutton-menu-overlay" <overlay id="torbutton-menu-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<menupopup id="menu_HelpPopup"> <menupopup id="menu_HelpPopup">
<!-- Bug 18905: Hide unused help menu items -->
<menuitem id="menu_openHelp" removeelement="true"/> <menuitem id="menu_openHelp" removeelement="true"/>
<menuitem id="menu_openTour" removeelement="true"/> <menuitem id="menu_openTour" removeelement="true"/>
<menuitem id="healthReport" removeelement="true"/> <menuitem id="healthReport" removeelement="true"/>
...@@ -14,5 +16,12 @@ ...@@ -14,5 +16,12 @@
<!-- dummy elements to avoid 'getElementById' errors --> <!-- dummy elements to avoid 'getElementById' errors -->
<box id="menu_HelpPopup_reportPhishingtoolmenu"/> <box id="menu_HelpPopup_reportPhishingtoolmenu"/>
<box id="menu_HelpPopup_reportPhishingErrortoolmenu"/> <box id="menu_HelpPopup_reportPhishingErrortoolmenu"/>
<!-- Add Tor Browser manual link -->
<menuitem name="torBrowserUserManual"
id="torBrowserUserManual"
position="1"
label="&torbutton.torbrowser_user_manual.label;"
accesskey="&torbutton.torbrowser_user_manual.accesskey;"
oncommand="torbutton_open_torbrowser_user_manual()" />
</menupopup> </menupopup>
</overlay> </overlay>
...@@ -12,6 +12,7 @@ let { Services } = Cu.import("resource://gre/modules/Services.jsm", {}); ...@@ -12,6 +12,7 @@ let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
let { showDialog } = Cu.import("resource://torbutton/modules/utils.js", {}); let { showDialog } = Cu.import("resource://torbutton/modules/utils.js", {});
let { unescapeTorString } = Cu.import("resource://torbutton/modules/utils.js", {}); let { unescapeTorString } = Cu.import("resource://torbutton/modules/utils.js", {});
let SecurityPrefs = Cu.import("resource://torbutton/modules/security-prefs.js", {}); let SecurityPrefs = Cu.import("resource://torbutton/modules/security-prefs.js", {});
let { bindPrefAndInit } = Cu.import("resource://torbutton/modules/utils.js", {});
const k_tb_last_browser_version_pref = "extensions.torbutton.lastBrowserVersion"; const k_tb_last_browser_version_pref = "extensions.torbutton.lastBrowserVersion";
const k_tb_browser_update_needed_pref = "extensions.torbutton.updateNeeded"; const k_tb_browser_update_needed_pref = "extensions.torbutton.updateNeeded";
...@@ -200,7 +201,7 @@ var torbutton_tor_check_observer = { ...@@ -200,7 +201,7 @@ var torbutton_tor_check_observer = {
// Update all open about:tor pages. If the user does not have an // Update all open about:tor pages. If the user does not have an
// about:tor page open in the front most window, open one. // about:tor page open in the front most window, open one.
if (torbutton_update_all_abouttor_pages(undefined, false) < 1) { if (torbutton_update_all_abouttor_pages(undefined, undefined, false) < 1) {
var wm = Cc["@mozilla.org/appshell/window-mediator;1"] var wm = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator); .getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser"); var win = wm.getMostRecentWindow("navigator:browser");
...@@ -360,7 +361,7 @@ function torbutton_init() { ...@@ -360,7 +361,7 @@ function torbutton_init() {
// Detect toolbar customization and update arrow on about:tor pages. // Detect toolbar customization and update arrow on about:tor pages.
window.addEventListener("aftercustomization", function() { window.addEventListener("aftercustomization", function() {
torbutton_update_all_abouttor_pages(undefined, undefined); torbutton_update_all_abouttor_pages(undefined, undefined, undefined);
}, false); }, false);
//setting up context menu //setting up context menu
...@@ -399,6 +400,8 @@ function torbutton_init() { ...@@ -399,6 +400,8 @@ function torbutton_init() {
quantizeBrowserSize(window, 100, 100); quantizeBrowserSize(window, 100, 100);
torbutton_init_user_manual_links();
torbutton_log(3, 'init completed'); torbutton_log(3, 'init completed');
} }
...@@ -565,7 +568,7 @@ function torbutton_notify_if_update_needed() { ...@@ -565,7 +568,7 @@ function torbutton_notify_if_update_needed() {
setOrClearAttribute(btn, "tbUpdateNeeded", updateNeeded); setOrClearAttribute(btn, "tbUpdateNeeded", updateNeeded);
// Update all open about:tor pages. // Update all open about:tor pages.
torbutton_update_all_abouttor_pages(updateNeeded, undefined); torbutton_update_all_abouttor_pages(updateNeeded, undefined, undefined);
// Make the "check for update" menu item bold if an update is needed. // Make the "check for update" menu item bold if an update is needed.
var item = document.getElementById("torbutton-checkForUpdate"); var item = document.getElementById("torbutton-checkForUpdate");
...@@ -594,9 +597,11 @@ function torbutton_check_for_update() { ...@@ -594,9 +597,11 @@ function torbutton_check_for_update() {
// Pass undefined for a parameter to have this function determine it. // Pass undefined for a parameter to have this function determine it.
// Returns a count of open pages that were updated, // Returns a count of open pages that were updated,
function torbutton_update_all_abouttor_pages(aUpdateNeeded, aTorIsOn) { function torbutton_update_all_abouttor_pages(aUpdateNeeded, aShowManual, aTorIsOn) {
if (aUpdateNeeded === undefined) if (aUpdateNeeded === undefined)
aUpdateNeeded = torbutton_update_is_needed(); aUpdateNeeded = torbutton_update_is_needed();
if (aShowManual === undefined)
aShowManual = torbutton_show_torbrowser_manual();
if (aTorIsOn === undefined) if (aTorIsOn === undefined)
aTorIsOn = torbutton_tor_check_ok(); aTorIsOn = torbutton_tor_check_ok();
...@@ -607,7 +612,7 @@ function torbutton_update_all_abouttor_pages(aUpdateNeeded, aTorIsOn) { ...@@ -607,7 +612,7 @@ function torbutton_update_all_abouttor_pages(aUpdateNeeded, aTorIsOn) {
for (var tab = tabs[0]; tab != null; tab = tab.nextSibling) { for (var tab = tabs[0]; tab != null; tab = tab.nextSibling) {
try { try {
let doc = tabBrowser.getBrowserForTab(tab).contentDocument; let doc = tabBrowser.getBrowserForTab(tab).contentDocument;
if (torbutton_update_abouttor_doc(doc, aTorIsOn, aUpdateNeeded)) if (torbutton_update_abouttor_doc(doc, aTorIsOn, aShowManual, aUpdateNeeded))
++count; ++count;
} catch(e) {} } catch(e) {}
} }
...@@ -617,7 +622,7 @@ function torbutton_update_all_abouttor_pages(aUpdateNeeded, aTorIsOn) { ...@@ -617,7 +622,7 @@ function torbutton_update_all_abouttor_pages(aUpdateNeeded, aTorIsOn) {
} }
// Returns true if aDoc is an about:tor page. // Returns true if aDoc is an about:tor page.
function torbutton_update_abouttor_doc(aDoc, aTorOn, aUpdateNeeded) { function torbutton_update_abouttor_doc(aDoc, aTorOn, aShowManual, aUpdateNeeded) {
var isAboutTor = torbutton_is_abouttor_doc(aDoc); var isAboutTor = torbutton_is_abouttor_doc(aDoc);
if (isAboutTor) { if (isAboutTor) {
if (aTorOn) if (aTorOn)
...@@ -625,6 +630,11 @@ function torbutton_update_abouttor_doc(aDoc, aTorOn, aUpdateNeeded) { ...@@ -625,6 +630,11 @@ function torbutton_update_abouttor_doc(aDoc, aTorOn, aUpdateNeeded) {
else else
aDoc.body.removeAttribute("toron"); aDoc.body.removeAttribute("toron");
if (aShowManual)
aDoc.body.setAttribute("showmanual", "yes");
else
aDoc.body.removeAttribute("showmanual");
if (aUpdateNeeded) if (aUpdateNeeded)
aDoc.body.setAttribute("torNeedsUpdate", "yes"); aDoc.body.setAttribute("torNeedsUpdate", "yes");
else else
...@@ -739,8 +749,9 @@ function torbutton_on_abouttor_load(aDoc) { ...@@ -739,8 +749,9 @@ function torbutton_on_abouttor_load(aDoc) {
// Show correct Tor on/off and "update needed" status. // Show correct Tor on/off and "update needed" status.
let torOn = torbutton_tor_check_ok(); let torOn = torbutton_tor_check_ok();
let showManual = torbutton_show_torbrowser_manual();
let needsUpdate = torbutton_update_is_needed(); let needsUpdate = torbutton_update_is_needed();
torbutton_update_abouttor_doc(aDoc, torOn, needsUpdate); torbutton_update_abouttor_doc(aDoc, torOn, showManual, needsUpdate);
aDoc.defaultView.addEventListener("resize", aDoc.defaultView.addEventListener("resize",
function() { torbutton_update_abouttor_arrow(aDoc); }, function() { torbutton_update_abouttor_arrow(aDoc); },
...@@ -2437,5 +2448,26 @@ function torbutton_update_noscript_button() ...@@ -2437,5 +2448,26 @@ function torbutton_update_noscript_button()
}, 0); }, 0);
} }
// Opens the Tor Browser User Manual in a new tab
function torbutton_open_torbrowser_user_manual() {
gBrowser.selectedTab = gBrowser.addTab("https://tb-manual.torproject.org");
}
// Returns true if we should show the tor browser manual.
function torbutton_show_torbrowser_manual() {
let locale = torbutton_get_general_useragent_locale();
return locale.startsWith("en");
}
// Makes sure the tem in the Help Menu and the link in about:tor
// for the Tor Browser User Manual are only visible when
// torbutton_show_torbrowser_manual() returns true.
function torbutton_init_user_manual_links() {
let menuitem = document.getElementById("torBrowserUserManual");
bindPrefAndInit("general.useragent.locale", val => {
menuitem.hidden = !torbutton_show_torbrowser_manual();
torbutton_update_all_abouttor_pages(undefined, undefined, undefined);
});
}
//vim:set ts=4 //vim:set ts=4
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
<!ENTITY aboutTor.whatnextAnswer.label "Tor is NOT all you need to browse anonymously! You may need to change some of your browsing habits to ensure your identity stays safe."> <!ENTITY aboutTor.whatnextAnswer.label "Tor is NOT all you need to browse anonymously! You may need to change some of your browsing habits to ensure your identity stays safe.">
<!ENTITY aboutTor.whatnext.label "Tips On Staying Anonymous »"> <!ENTITY aboutTor.whatnext.label "Tips On Staying Anonymous »">
<!ENTITY aboutTor.whatnext.link "https://www.torproject.org/download/download.html.en#warning"> <!ENTITY aboutTor.whatnext.link "https://www.torproject.org/download/download.html.en#warning">
<!ENTITY aboutTor.torbrowser_user_manual.label "Tor Browser User Manual »">
<!ENTITY aboutTor.torbrowser_user_manual.link "https://tb-manual.torproject.org">
<!ENTITY aboutTor.helpInfo1.label "You Can Help!"> <!ENTITY aboutTor.helpInfo1.label "You Can Help!">
<!ENTITY aboutTor.helpInfo2.label "There are many ways you can help make the Tor Network faster and stronger:"> <!ENTITY aboutTor.helpInfo2.label "There are many ways you can help make the Tor Network faster and stronger:">
<!ENTITY aboutTor.helpInfo3.label "Run a Tor Relay Node »"> <!ENTITY aboutTor.helpInfo3.label "Run a Tor Relay Node »">
......
...@@ -59,3 +59,5 @@ ...@@ -59,3 +59,5 @@
<!ENTITY torbutton.prefs.sec_webfonts_desc "Some fonts and icons may display incorrectly."> <!ENTITY torbutton.prefs.sec_webfonts_desc "Some fonts and icons may display incorrectly.">
<!ENTITY torbutton.prefs.sec_webfonts_desc_tooltip "Website-provided font files are blocked."> <!ENTITY torbutton.prefs.sec_webfonts_desc_tooltip "Website-provided font files are blocked.">
<!ENTITY torbutton.circuit_display.title "Tor circuit for this site"> <!ENTITY torbutton.circuit_display.title "Tor circuit for this site">
<!ENTITY torbutton.torbrowser_user_manual.label "Tor Browser User Manual">
<!ENTITY torbutton.torbrowser_user_manual.accesskey "M">
...@@ -132,6 +132,10 @@ body[toron] .top h1 { ...@@ -132,6 +132,10 @@ body[toron] .top h1 {
color: #600060; color: #600060;
} }
body:not([showmanual]) .showForManual {
display: none;
}
div.hideIfTorIsUpToDate, div.hideIfTorIsUpToDate,
body .top div.hideIfTorIsUpToDate h1 { body .top div.hideIfTorIsUpToDate h1 {
color: black; color: black;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment