[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torbutton/master] Bug 3944: Use ComplexValue for the TBB homepage.



commit cb1f30d3c80e2efa93cfa5b15dcf7a8ebe013f27
Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date:   Sat Feb 9 18:19:09 2013 -0800

    Bug 3944: Use ComplexValue for the TBB homepage.
    
    Required for FF17 anyways.
---
 src/chrome/content/torbutton.js |   39 ++++++++++++++-------------------------
 1 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 82b9150..06e668c 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -729,18 +729,27 @@ function torbutton_do_async_versioncheck() {
             for (var v in version_list) {
               if (version_list[v] == my_version) {
                 torbutton_log(3, "Version check passed.");
-                var homepage = m_tb_prefs.getCharPref("browser.startup.homepage");
+                var homepage = m_tb_prefs.getComplexValue("browser.startup.homepage",
+                       Components.interfaces.nsIPrefLocalizedString).data;
                 if (homepage.indexOf("https://check.torproject.org/";) == 0) {
-                  m_tb_prefs.setCharPref("browser.startup.homepage",
-                      "https://check.torproject.org/?lang="+locale+"&small=1&uptodate=1";);
+                  var str = Components.classes["@mozilla.org/supports-string;1"]
+                                    .createInstance(Components.interfaces.nsISupportsString);
+                  str.data = "https://check.torproject.org/?lang="+locale+"&small=1&uptodate=1";;
+                  m_tb_prefs.setComplexValue("browser.startup.homepage",
+                                             Components.interfaces.nsISupportsString,
+                                             str);
                 }
                 return;
               }
             }
             torbutton_log(5, "Your Tor Browser is out of date.");
             // Not up to date
-            m_tb_prefs.setCharPref("browser.startup.homepage",
-                "https://check.torproject.org/?lang="+locale+"&small=1&uptodate=0";);
+            var str = Components.classes["@mozilla.org/supports-string;1"]
+                              .createInstance(Components.interfaces.nsISupportsString);
+            str.data = "https://check.torproject.org/?lang="+locale+"&small=1&uptodate=0";;
+            m_tb_prefs.setComplexValue("browser.startup.homepage",
+                                       Components.interfaces.nsISupportsString,
+                                       str);
             return;
           } catch(e) {
             torbutton_log(5, "Version check failed! JSON parsing error: "+e);
@@ -1702,26 +1711,6 @@ function torbutton_disable_all_js() {
     }
 }
 
-// Bug 1506 P0: This has been deprecated in favor of an async check
-function torbutton_do_versioncheck() {
-  if (m_tb_tbb && m_tb_prefs.getBoolPref("extensions.torbutton.versioncheck_enabled")) {
-    var is_updated = torbutton_check_version();
-    var locale = m_tb_prefs.getCharPref("general.useragent.locale");
-    if (is_updated == 0) {
-      // In an ideal world, we'd just check for hasUserValue, but we can't do
-      // that, because we set browser.startup.homepage to have a user value already...
-      m_tb_prefs.setCharPref("browser.startup.homepage",
-              "https://check.torproject.org/?lang="+locale+"&small=1&uptodate=0";);
-    } else if (is_updated == 1) {
-      var homepage = m_tb_prefs.getCharPref("browser.startup.homepage");
-      if (homepage.indexOf("https://check.torproject.org/";) == 0) {
-        m_tb_prefs.setCharPref("browser.startup.homepage",
-                  "https://check.torproject.org/?lang="+locale+"&small=1&uptodate=1";);
-      }
-    }
-  }
-}
-
 // Bug 1506 P2: We may want to replace this with a XUl solution.
 // See #6096.
 function torbutton_reload_homepage() {



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits