[or-cvs] [torbutton/master 17/47] Add UI for Google query redirect.

mikeperry at torproject.org mikeperry at torproject.org
Thu Sep 30 16:20:14 UTC 2010


Author: Mike Perry <mikeperry-git at fscked.org>
Date: Tue, 30 Mar 2010 02:52:32 -0700
Subject: Add UI for Google query redirect.
Commit: f90e26d003f2a0a135876c24c6776817686e334e

---
 src/chrome/content/preferences.js  |   36 ++++++++++++++++++++++++++++++++++--
 src/chrome/content/preferences.xul |   17 ++++++++++++++++-
 src/chrome/locale/en/torbutton.dtd |    1 +
 3 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/src/chrome/content/preferences.js b/src/chrome/content/preferences.js
index 4eee822..c8a0a65 100644
--- a/src/chrome/content/preferences.js
+++ b/src/chrome/content/preferences.js
@@ -93,6 +93,8 @@ function torbutton_prefs_set_field_attributes(doc)
         doc.getElementById('torbutton_socksPort').value    = o_customprefs.getIntPref('socks_port');
         */
     }
+
+    doc.getElementById('torbutton_searchEngine').disabled = !doc.getElementById('torbutton_noCaptcha').checked;
 }
 
 function torbutton_prefs_init(doc) {
@@ -269,6 +271,24 @@ function torbutton_prefs_init(doc) {
     doc.getElementById('torbutton_blockNonTorFileNet').checked = o_torprefs.getBoolPref('block_nontor_file_net');
 
     doc.getElementById('torbutton_lockedMode').checked = o_torprefs.getBoolPref('locked_mode');
+
+    switch(o_torprefs.getIntPref('google_redir_url')) {
+        case 1:
+            doc.getElementById("torbutton_searchEngine").selectedItem =
+                doc.getElementById('torbutton_engine1');
+            break;
+        case 2:
+            doc.getElementById("torbutton_searchEngine").selectedItem =
+                doc.getElementById('torbutton_engine2');
+            break;
+        case 3:
+            doc.getElementById("torbutton_searchEngine").selectedItem =
+                doc.getElementById('torbutton_engine3');
+            break;
+    }
+    doc.getElementById('torbutton_noCaptcha').checked = o_torprefs.getBoolPref('dodge_google_captcha');
+    doc.getElementById('torbutton_searchEngine').disabled = !o_torprefs.getBoolPref('dodge_google_captcha');
+
     /*
     doc.getElementById('torbutton_jarCerts').checked = o_torprefs.getBoolPref('jar_certs');
     doc.getElementById('torbutton_jarCACerts').checked = o_torprefs.getBoolPref('jar_ca_certs');
@@ -442,12 +462,24 @@ function torbutton_prefs_save(doc) {
     o_torprefs.setBoolPref('close_tor', doc.getElementById('torbutton_closeTor').checked);
     o_torprefs.setBoolPref('close_nontor', doc.getElementById('torbutton_closeNonTor').checked);
     o_torprefs.setBoolPref('no_updates', doc.getElementById('torbutton_noUpdates').checked);
-    
+
     o_torprefs.setBoolPref('set_uagent', doc.getElementById('torbutton_setUagent').checked);
     o_torprefs.setBoolPref('disable_referer', doc.getElementById('torbutton_noReferer').checked);
     o_torprefs.setBoolPref('spoof_english', doc.getElementById('torbutton_spoofEnglish').checked);
-    
+
     o_torprefs.setBoolPref('locked_mode', doc.getElementById('torbutton_lockedMode').checked);
+    o_torprefs.setBoolPref('dodge_google_captcha', doc.getElementById('torbutton_noCaptcha').checked);
+
+    if(doc.getElementById('torbutton_searchEngine').selectedItem ==
+            doc.getElementById('torbutton_engine1')) {
+        o_torprefs.setIntPref('google_redir_url', 1);
+    } else if(doc.getElementById('torbutton_searchEngine').selectedItem ==
+            doc.getElementById('torbutton_engine2')) {
+        o_torprefs.setIntPref('google_redir_url', 2);
+    } else {
+        o_torprefs.setIntPref('google_redir_url', 3);
+    }
+
     /*
     o_torprefs.setBoolPref('jar_certs', doc.getElementById('torbutton_jarCerts').checked);
     o_torprefs.setBoolPref('jar_ca_certs',
diff --git a/src/chrome/content/preferences.xul b/src/chrome/content/preferences.xul
index ba86bc3..ff1605a 100644
--- a/src/chrome/content/preferences.xul
+++ b/src/chrome/content/preferences.xul
@@ -338,7 +338,22 @@
 -->
           <checkbox id="torbutton_noReferer" label="&torbutton.prefs.disable_referer;" 
                    oncommand="torbutton_prefs_set_field_attributes(document)"/>
-           </vbox>
+          <spacer/>
+          <checkbox id="torbutton_noCaptcha" label="&torbutton.prefs.dodge_google_captcha;"
+                   oncommand="torbutton_prefs_set_field_attributes(document)"/>
+          <hbox class="indent" align="center">
+             <label value="&torbutton.prefs.search_engine;" control="torbutton_searchEngine"/>
+             <radiogroup align="center" orient="horizontal" id="torbutton_searchEngine">
+              <radio id="torbutton_engine1" label="&torbutton.prefs.engine1;"
+                   oncommand="torbutton_prefs_set_field_attributes(document)"/>
+              <radio id="torbutton_engine2" label="&torbutton.prefs.engine2;"
+                   oncommand="torbutton_prefs_set_field_attributes(document)"/>
+              <radio id="torbutton_engine3" label="&torbutton.prefs.engine3;"
+                   oncommand="torbutton_prefs_set_field_attributes(document)"/>
+             </radiogroup>
+            </hbox>
+
+            </vbox>
           </tabpanel>
          </tabpanels>
         </tabbox>
diff --git a/src/chrome/locale/en/torbutton.dtd b/src/chrome/locale/en/torbutton.dtd
index 6f0caa9..230cace 100644
--- a/src/chrome/locale/en/torbutton.dtd
+++ b/src/chrome/locale/en/torbutton.dtd
@@ -99,6 +99,7 @@
 <!ENTITY torbutton.prefs.dtd_crucial "(crucial)">
 <!ENTITY torbutton.prefs.update_torbutton_via_tor "Redirect Torbutton updates through Tor">
 <!ENTITY torbutton.prefs.dodge_google_captcha "Automatically use an alternate search engine when presented with a Google Captcha">
+<!ENTITY torbutton.prefs.search_engine "Search engine:">
 <!ENTITY torbutton.prefs.engine1 "ixquick.com">
 <!ENTITY torbutton.prefs.engine2 "Bing.com">
 <!ENTITY torbutton.prefs.engine3 "scroogle.org">
-- 
1.7.1




More information about the tor-commits mailing list