Bug 795203 - B2g: clear private data: cookies. r=mconnor,jduell
authorJason Duell <jduell.mcbugs@gmail.com>
Fri, 28 Sep 2012 17:03:00 -0700
changeset 109626 29cb1f0d796c6e996c466f0b907cdb1cfc9c7d65
parent 109625 7a0094bcd18650b5cedcc24f1a6e05ee502016e1
child 109627 5c1ee495765f22815ffcd7503ae87a1f1041a3e2
push id23636
push usergsharp@mozilla.com
push dateMon, 08 Oct 2012 08:08:19 +0000
treeherdermozilla-central@24cf40690042 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconnor, jduell
bugs795203
milestone18.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 795203 - B2g: clear private data: cookies. r=mconnor,jduell
layout/build/nsLayoutStatics.cpp
netwerk/cookie/nsCookieService.cpp
netwerk/cookie/nsCookieService.h
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -252,17 +252,17 @@ nsLayoutStatics::Initialize()
 
   nsWindowMemoryReporter::Init();
 
   nsSVGUtils::Init();
 
   InitProcessPriorityManager();
 
   nsPermissionManager::AppUninstallObserverInit();
-  nsCookieService::AppUninstallObserverInit();
+  nsCookieService::AppClearDataObserverInit();
   nsApplicationCacheService::AppClearDataObserverInit();
 
   nsDOMStorageBaseDB::Init();
 
   return NS_OK;
 }
 
 void
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -540,42 +540,40 @@ public:
     return NS_OK;
   }
 };
 
 NS_IMPL_ISUPPORTS1(CloseCookieDBListener, mozIStorageCompletionCallback)
 
 namespace {
 
-class AppUninstallObserver MOZ_FINAL : public nsIObserver {
+class AppClearDataObserver MOZ_FINAL : public nsIObserver {
 public:
   NS_DECL_ISUPPORTS
 
   // nsIObserver implementation.
   NS_IMETHODIMP
   Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *data)
   {
-    MOZ_ASSERT(!nsCRT::strcmp(aTopic, "webapps-uninstall"));
-
-    nsCOMPtr<nsIAppsService> appsService = do_GetService("@mozilla.org/AppsService;1");
-    nsCOMPtr<mozIApplication> app;
-
-    appsService->GetAppFromObserverMessage(nsAutoString(data), getter_AddRefs(app));
-    NS_ENSURE_TRUE(app, NS_ERROR_UNEXPECTED);
-
-    uint32_t appId;
-    app->GetLocalId(&appId);
-    MOZ_ASSERT(appId != NECKO_NO_APP_ID);
-
-    nsCOMPtr<nsICookieManager2> cookieManager = do_GetService(NS_COOKIEMANAGER_CONTRACTID);
-    return cookieManager->RemoveCookiesForApp(appId, false);
+    MOZ_ASSERT(!nsCRT::strcmp(aTopic, TOPIC_WEB_APP_CLEAR_DATA));
+
+    uint32_t appId = NECKO_UNKNOWN_APP_ID;
+    bool browserOnly = false;
+    nsresult rv = NS_GetAppInfoFromClearDataNotification(aSubject, &appId,
+                                                         &browserOnly);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    nsCOMPtr<nsICookieManager2> cookieManager
+      = do_GetService(NS_COOKIEMANAGER_CONTRACTID);
+    MOZ_ASSERT(cookieManager);
+    return cookieManager->RemoveCookiesForApp(appId, browserOnly);
   }
 };
 
-NS_IMPL_ISUPPORTS1(AppUninstallObserver, nsIObserver)
+NS_IMPL_ISUPPORTS1(AppClearDataObserver, nsIObserver)
 
 } // anonymous namespace
 
 /******************************************************************************
  * nsCookieService impl:
  * singleton instance ctor/dtor methods
  ******************************************************************************/
 
@@ -611,20 +609,22 @@ nsCookieService::GetSingleton()
       NS_RELEASE(gCookieService);
     }
   }
 
   return gCookieService;
 }
 
 /* static */ void
-nsCookieService::AppUninstallObserverInit()
+nsCookieService::AppClearDataObserverInit()
 {
   nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
-  observerService->AddObserver(new AppUninstallObserver(), "webapps-uninstall", /* holdsWeak= */ false);
+  nsCOMPtr<AppClearDataObserver> obs = new AppClearDataObserver();
+  observerService->AddObserver(obs, TOPIC_WEB_APP_CLEAR_DATA,
+                               /* holdsWeak= */ false);
 }
 
 /******************************************************************************
  * nsCookieService impl:
  * public methods
  ******************************************************************************/
 
 NS_IMPL_ISUPPORTS5(nsCookieService,
--- a/netwerk/cookie/nsCookieService.h
+++ b/netwerk/cookie/nsCookieService.h
@@ -240,17 +240,17 @@ class nsCookieService : public nsICookie
     nsresult                      Init();
 
   /**
    * Start watching the observer service for messages indicating that an app has
    * been uninstalled.  When an app is uninstalled, we get the cookie service
    * (thus instantiating it, if necessary) and clear all the cookies for that
    * app.
    */
-  static void AppUninstallObserverInit();
+  static void AppClearDataObserverInit();
 
   protected:
     void                          PrefChanged(nsIPrefBranch *aPrefBranch);
     void                          InitDBStates();
     OpenDBResult                  TryInitDB(bool aDeleteExistingDB);
     nsresult                      CreateTable();
     void                          CloseDBStates();
     void                          CloseDefaultDBConnection();