Bug 777639 - Part 2: Move sanitize.js to Sanitizer.jsm. r=mfinkle
authorBrian Nicholson <bnicholson@mozilla.com>
Tue, 05 Feb 2013 16:08:02 -0800
changeset 120949 997812c6023df5fb91e8cd965d0c4c03df17a8cb
parent 120948 2ffeac43b95e356c3d655ae347033829f3f8f7c5
child 120950 9ba2e7dc2951a006fefa09c0be442cebecaf40c0
push id22499
push userbnicholson@mozilla.com
push dateWed, 06 Feb 2013 00:09:07 +0000
treeherdermozilla-inbound@27d51d9f7495 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs777639
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 777639 - Part 2: Move sanitize.js to Sanitizer.jsm. r=mfinkle
content/media/MediaStreamGraph.cpp
dom/telephony/Makefile.in
dom/telephony/nsIDOMNavigatorTelephony.idl
mobile/android/chrome/content/browser.js
mobile/android/chrome/content/browser.xul
mobile/android/chrome/content/sanitize.js
mobile/android/chrome/jar.mn
mobile/android/modules/Makefile.in
mobile/android/modules/Sanitizer.jsm
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -43,16 +43,21 @@ XPCOMUtils.defineLazyGetter(this, "SafeB
 });
 #endif
 
 XPCOMUtils.defineLazyGetter(this, "PrivateBrowsingUtils", function() {
   Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
   return PrivateBrowsingUtils;
 });
 
+XPCOMUtils.defineLazyGetter(this, "Sanitizer", function() {
+  Cu.import("resource://gre/modules/Sanitizer.jsm");
+  return Sanitizer;
+});
+
 // Lazily-loaded browser scripts:
 [
   ["HelperApps", "chrome://browser/content/HelperApps.js"],
   ["SelectHelper", "chrome://browser/content/SelectHelper.js"],
   ["InputWidgetHelper", "chrome://browser/content/InputWidgetHelper.js"],
   ["AboutReader", "chrome://browser/content/aboutReader.js"],
   ["WebAppRT", "chrome://browser/content/WebAppRT.js"],
 ].forEach(function (aScript) {
@@ -997,36 +1002,35 @@ var BrowserApp = {
     } else {
       let pref = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(Ci.nsIPrefLocalizedString);
       pref.data = json.value;
       Services.prefs.setComplexValue(json.name, Ci.nsISupportsString, pref);
     }
   },
 
   sanitize: function (aItems) {
-    let sanitizer = new Sanitizer();
     let json = JSON.parse(aItems);
     let success = true;
 
     for (let key in json) {
       if (!json[key])
         continue;
 
       try {
         switch (key) {
           case "history_downloads":
-            sanitizer.clearItem("history");
-            sanitizer.clearItem("downloads");
+            Sanitizer.clearItem("history");
+            Sanitizer.clearItem("downloads");
             break;
           case "cookies_sessions":
-            sanitizer.clearItem("cookies");
-            sanitizer.clearItem("sessions");
+            Sanitizer.clearItem("cookies");
+            Sanitizer.clearItem("sessions");
             break;
           default:
-            sanitizer.clearItem(key);
+            Sanitizer.clearItem(key);
         }
       } catch (e) {
         dump("sanitize error: " + e);
         success = false;
       }
     }
 
     sendMessageToJava({
--- a/mobile/android/chrome/content/browser.xul
+++ b/mobile/android/chrome/content/browser.xul
@@ -7,13 +7,12 @@
 <window id="main-window"
         onload="BrowserApp.startup();"
         windowtype="navigator:browser"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script type="application/javascript" src="chrome://browser/content/browser.js"/>
   <script type="application/javascript" src="chrome://browser/content/downloads.js"/>
   <script type="application/javascript" src="chrome://browser/content/exceptions.js"/>
-  <script type="application/javascript" src="chrome://browser/content/sanitize.js"/>
 
   <deck id="browsers" flex="1"/>
 
 </window>
--- a/mobile/android/chrome/jar.mn
+++ b/mobile/android/chrome/jar.mn
@@ -27,17 +27,16 @@ chrome.jar:
   content/aboutApps.js                 (content/aboutApps.js)
   content/blockedSite.xhtml            (content/blockedSite.xhtml)
   content/languages.properties         (content/languages.properties)
   content/browser.xul                  (content/browser.xul)
 * content/browser.js                   (content/browser.js)
   content/bindings/checkbox.xml        (content/bindings/checkbox.xml)
   content/bindings/menulist.xml        (content/bindings/menulist.xml)
   content/bindings/settings.xml        (content/bindings/settings.xml)
-  content/sanitize.js                  (content/sanitize.js)
   content/exceptions.js                (content/exceptions.js)
   content/downloads.js                 (content/downloads.js)
   content/netError.xhtml               (content/netError.xhtml)
   content/SelectHelper.js              (content/SelectHelper.js)
   content/HelperApps.js                (content/HelperApps.js)
   content/dbg-browser-actors.js        (content/dbg-browser-actors.js)
 * content/WebAppRT.js                  (content/WebAppRT.js)
   content/InputWidgetHelper.js         (content/InputWidgetHelper.js)
--- a/mobile/android/modules/Makefile.in
+++ b/mobile/android/modules/Makefile.in
@@ -10,15 +10,16 @@ VPATH      = @srcdir@
 include $(DEPTH)/config/autoconf.mk
 
 EXTRA_JS_MODULES = \
   LightweightThemeConsumer.jsm \
   LocaleRepository.jsm \
   linuxTypes.jsm \
   video.jsm \
   JNI.jsm \
+  Sanitizer.jsm \
   $(NULL)
 
 EXTRA_PP_JS_MODULES = \
   contacts.jsm \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
rename from mobile/android/chrome/content/sanitize.js
rename to mobile/android/modules/Sanitizer.jsm
--- a/mobile/android/chrome/content/sanitize.js
+++ b/mobile/android/modules/Sanitizer.jsm
@@ -1,16 +1,32 @@
 // -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+let Cc = Components.classes;
+let Ci = Components.interfaces;
+
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+function dump(a) {
+  Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage(a);
+}
+
+function sendMessageToJava(aMessage) {
+  return Cc["@mozilla.org/android/bridge;1"]
+           .getService(Ci.nsIAndroidBridge)
+           .handleGeckoMessage(JSON.stringify(aMessage));
+}
+
+this.EXPORTED_SYMBOLS = ["Sanitizer"];
+
 function Sanitizer() {}
 Sanitizer.prototype = {
-  // warning to the caller: this one may raise an exception (e.g. bug #265028)
   clearItem: function (aItemName)
   {
     if (this.items[aItemName].canClear)
       this.items[aItemName].clear();
   },
 
   items: {
     cache: {
@@ -169,21 +185,20 @@ Sanitizer.prototype = {
     sessions: {
       clear: function ()
       {
         // clear all auth tokens
         var sdr = Cc["@mozilla.org/security/sdr;1"].getService(Ci.nsISecretDecoderRing);
         sdr.logoutAndTeardown();
 
         // clear FTP and plain HTTP auth sessions
-        var os = Components.classes["@mozilla.org/observer-service;1"]
-                           .getService(Components.interfaces.nsIObserverService);
-        os.notifyObservers(null, "net:clear-active-logins", null);
+        Services.obs.notifyObservers(null, "net:clear-active-logins", null);
       },
 
       get canClear()
       {
         return true;
       }
     }
   }
 };
 
+this.Sanitizer = new Sanitizer();