summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/WebCoreSupport/WebCookieJar.cpp9
-rw-r--r--WebKit/android/WebCoreSupport/WebCookieJar.h5
-rw-r--r--WebKit/android/jni/CookieManager.cpp6
3 files changed, 17 insertions, 3 deletions
diff --git a/WebKit/android/WebCoreSupport/WebCookieJar.cpp b/WebKit/android/WebCoreSupport/WebCookieJar.cpp
index 6a81ff1..afa87c2 100644
--- a/WebKit/android/WebCoreSupport/WebCookieJar.cpp
+++ b/WebKit/android/WebCoreSupport/WebCookieJar.cpp
@@ -95,8 +95,8 @@ WebCookieJar::WebCookieJar(const std::string& databaseFilePath)
net::CookieMonster::EnableFileScheme();
FilePath cookiePath(databaseFilePath.c_str());
- scoped_refptr<SQLitePersistentCookieStore> cookieDb = new SQLitePersistentCookieStore(cookiePath);
- m_cookieStore = new net::CookieMonster(cookieDb.get(), 0);
+ m_cookieDb = new SQLitePersistentCookieStore(cookiePath);
+ m_cookieStore = new net::CookieMonster(m_cookieDb.get(), 0);
}
bool WebCookieJar::allowCookies()
@@ -111,6 +111,11 @@ void WebCookieJar::setAllowCookies(bool allow)
m_allowCookies = allow;
}
+int WebCookieJar::getNumCookiesInDatabase()
+{
+ return m_cookieDb ? m_cookieDb->GetCookieCount() : 0;
+}
+
// From CookiePolicy in chromium
int WebCookieJar::CanGetCookies(const GURL&, const GURL&, net::CompletionCallback*)
{
diff --git a/WebKit/android/WebCoreSupport/WebCookieJar.h b/WebKit/android/WebCoreSupport/WebCookieJar.h
index 1372064..2f32e1a 100644
--- a/WebKit/android/WebCoreSupport/WebCookieJar.h
+++ b/WebKit/android/WebCoreSupport/WebCookieJar.h
@@ -54,9 +54,14 @@ public:
net::CookieStore* cookieStore() { return m_cookieStore.get(); }
net::CookiePolicy* cookiePolicy() { return this; }
+ // Get the number of cookies that have actually been saved to flash.
+ // (This is used to implement CookieManager.hasCookies() in the Java framework.)
+ int getNumCookiesInDatabase();
+
private:
WebCookieJar(const std::string& databaseFilePath);
+ scoped_refptr<SQLitePersistentCookieStore> m_cookieDb;
scoped_refptr<net::CookieStore> m_cookieStore;
bool m_allowCookies;
WTF::Mutex m_allowCookiesMutex;
diff --git a/WebKit/android/jni/CookieManager.cpp b/WebKit/android/jni/CookieManager.cpp
index 5532f6a..0ba767c 100644
--- a/WebKit/android/jni/CookieManager.cpp
+++ b/WebKit/android/jni/CookieManager.cpp
@@ -83,7 +83,7 @@ static jstring getCookie(JNIEnv* env, jobject, jstring url)
static bool hasCookies(JNIEnv*, jobject)
{
#if USE(CHROME_NETWORK_STACK)
- return !WebCookieJar::get(false)->cookieStore()->GetCookieMonster()->GetAllCookies().empty();
+ return WebCookieJar::get(false)->getNumCookiesInDatabase() > 0;
#else
// The Android HTTP stack is implemented Java-side.
ASSERT_NOT_REACHED();
@@ -101,6 +101,10 @@ static void removeAllCookie(JNIEnv*, jobject)
// TODO: Consider adding an optimisation to not create the context if it
// doesn't already exist.
WebCookieJar::get(true)->cookieStore()->GetCookieMonster()->DeleteAllCreatedAfter(Time(), true);
+
+ // The Java code removes cookies directly from the backing database, so we do the same,
+ // but with a NULL callback so it's asynchronous.
+ WebCookieJar::get(true)->cookieStore()->GetCookieMonster()->FlushStore(NULL);
#endif
}