OSDN Git Service

Clean the private cookies when we create the first or remove the last context
authorKristian Monsen <kristianm@google.com>
Mon, 13 Dec 2010 15:59:46 +0000 (15:59 +0000)
committerKristian Monsen <kristianm@google.com>
Mon, 13 Dec 2010 16:45:13 +0000 (16:45 +0000)
Bug 3243891

Change-Id: Ia67ae91bd5ca13c896e45bf4dcc79debd77051db

WebKit/android/WebCoreSupport/WebRequestContext.cpp

index 1d5a35e..59b5512 100644 (file)
@@ -51,6 +51,15 @@ WebRequestContext::WebRequestContext(bool isPrivateBrowsing)
     // Initialize chromium logging, needs to be done before any chromium code is called.
     initChromium();
 
+    if (m_isPrivateBrowsing) {
+        MutexLocker lock(numPrivateBrowsingInstancesMutex);
+        // Delete the old files if this is the first private browsing instance
+        // They are probably leftovers from a power cycle
+        if (!numPrivateBrowsingInstances)
+            cleanupPrivateBrowsingFiles();
+        numPrivateBrowsingInstances++;
+    }
+
     WebCache* cache = WebCache::get(m_isPrivateBrowsing);
     host_resolver_ = cache->hostResolver();
     http_transaction_factory_ = cache->cache();
@@ -61,11 +70,6 @@ WebRequestContext::WebRequestContext(bool isPrivateBrowsing)
 
     // Also hardcoded in FrameLoader.java
     accept_charset_ = "utf-8, iso-8859-1, utf-16, *;q=0.7";
-
-    if (m_isPrivateBrowsing) {
-        MutexLocker lock(numPrivateBrowsingInstancesMutex);
-        numPrivateBrowsingInstances++;
-    }
 }
 
 WebRequestContext::~WebRequestContext()
@@ -73,6 +77,10 @@ WebRequestContext::~WebRequestContext()
     if (m_isPrivateBrowsing) {
         MutexLocker lock(numPrivateBrowsingInstancesMutex);
         numPrivateBrowsingInstances--;
+
+        // This is the last private browsing context, delete the cookies
+        if (!numPrivateBrowsingInstances)
+            cleanupPrivateBrowsingFiles();
     }
 }