Bug 1422365 - Introduce nsIClearDataService - part 13 - auth tokens, r=johannh
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 01 Jun 2018 14:30:01 +0200
changeset 420847 9be5e7c20ed3f42b4b324d06e9e43b6303955b74
parent 420846 22de53cb87c4a41098bd7a3b2569bf05f1f753cd
child 420848 ebdf4bc31e581e48bb2fa009694c9fa410efcbd5
push id103898
push useramarchesini@mozilla.com
push dateFri, 01 Jun 2018 12:31:55 +0000
treeherdermozilla-inbound@ee1e13b50338 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1422365
milestone62.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 1422365 - Introduce nsIClearDataService - part 13 - auth tokens, r=johannh
browser/modules/Sanitizer.jsm
toolkit/components/cleardata/ClearDataService.js
toolkit/components/cleardata/nsIClearDataService.idl
--- a/browser/modules/Sanitizer.jsm
+++ b/browser/modules/Sanitizer.jsm
@@ -416,23 +416,19 @@ var Sanitizer = {
         TelemetryStopwatch.finish("FX_SANITIZE_DOWNLOADS", refObj);
       }
     },
 
     sessions: {
       async clear(range) {
         let refObj = {};
         TelemetryStopwatch.start("FX_SANITIZE_SESSIONS", refObj);
+        await clearData(range, Ci.nsIClearDataService.CLEAR_AUTH_TOKENS);
 
         try {
-          // clear all auth tokens
-          let sdr = Cc["@mozilla.org/security/sdr;1"]
-                      .getService(Ci.nsISecretDecoderRing);
-          sdr.logoutAndTeardown();
-
           // clear FTP and plain HTTP auth sessions
           Services.obs.notifyObservers(null, "net:clear-active-logins");
         } finally {
           TelemetryStopwatch.finish("FX_SANITIZE_SESSIONS", refObj);
         }
       }
     },
 
--- a/toolkit/components/cleardata/ClearDataService.js
+++ b/toolkit/components/cleardata/ClearDataService.js
@@ -458,16 +458,27 @@ const SessionHistoryCleaner = {
   deleteAll() {
     return new Promise(aResolve => {
       Services.obs.notifyObservers(null, "browser:purge-session-history");
       aResolve();
     });
   },
 };
 
+const AuthTokensCleaner = {
+  deleteAll() {
+    return new Promise(aResolve => {
+      let sdr = Cc["@mozilla.org/security/sdr;1"]
+                  .getService(Ci.nsISecretDecoderRing);
+      sdr.logoutAndTeardown();
+      aResolve();
+    });
+  },
+};
+
 // Here the map of Flags-Cleaner.
 const FLAGS_MAP = [
  { flag: Ci.nsIClearDataService.CLEAR_COOKIES,
    cleaner: CookieCleaner },
 
  { flag: Ci.nsIClearDataService.CLEAR_NETWORK_CACHE,
    cleaner: NetworkCacheCleaner },
 
@@ -498,16 +509,19 @@ const FLAGS_MAP = [
  { flag: Ci.nsIClearDataService.CLEAR_DOM_PUSH_NOTIFICATIONS,
    cleaner: PushNotificationsCleaner, },
 
  { flag: Ci.nsIClearDataService.CLEAR_HISTORY,
    cleaner: HistoryCleaner, },
 
  { flag: Ci.nsIClearDataService.CLEAR_SESSION_HISTORY,
    cleaner: SessionHistoryCleaner, },
+
+ { flag: Ci.nsIClearDataService.CLEAR_AUTH_TOKENS,
+   cleaner: AuthTokensCleaner, },
 ];
 
 this.ClearDataService = function() {};
 
 ClearDataService.prototype = Object.freeze({
   classID: Components.ID("{0c06583d-7dd8-4293-b1a5-912205f779aa}"),
   QueryInterface: ChromeUtils.generateQI([Ci.nsIClearDataService]),
   _xpcom_factory: XPCOMUtils.generateSingletonFactory(ClearDataService),
--- a/toolkit/components/cleardata/nsIClearDataService.idl
+++ b/toolkit/components/cleardata/nsIClearDataService.idl
@@ -143,24 +143,28 @@ interface nsIClearDataService : nsISuppo
    */
   const uint32_t CLEAR_HISTORY = 1 << 11;
 
   /**
    * Session history
    */
   const uint32_t CLEAR_SESSION_HISTORY = 1 << 12;
 
+  /**
+   * Auth tokens
+   */
+  const uint32_t CLEAR_AUTH_TOKENS = 1 << 13;
+
   /* TODO
   const uint32_t CLEAR_EME = 1 << 4;
   const uint32_t CLEAR_PERMISSIONS = 1 << 7;
   const uint32_t CLEAR_CONTENT_PREFERENCES = 1 << 9;
   const uint32_t CLEAR_HSTS = 1 << 12;
   const uint32_t CLEAR_HPKP = 1 << 13;
   const uint32_t CLEAR_FORMDATA = 1 << 16;
-  const uint32_t CLEAR_AUTH_TOKENS = 1 << 17;
   const uint32_t CLEAR_LOGINS = 1 << 18;
   */
 
   /**
    * Use this value to delete all the data.
    */
   const uint32_t CLEAR_ALL = 0xFFFF;