summaryrefslogtreecommitdiffstats
path: root/WebKit/android/WebCoreSupport
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/WebCoreSupport')
-rw-r--r--WebKit/android/WebCoreSupport/ChromiumIncludes.h1
-rw-r--r--WebKit/android/WebCoreSupport/PlatformBridge.cpp5
-rw-r--r--WebKit/android/WebCoreSupport/WebRequestContext.cpp26
-rw-r--r--WebKit/android/WebCoreSupport/WebRequestContext.h13
4 files changed, 43 insertions, 2 deletions
diff --git a/WebKit/android/WebCoreSupport/ChromiumIncludes.h b/WebKit/android/WebCoreSupport/ChromiumIncludes.h
index ad93179..377aa22 100644
--- a/WebKit/android/WebCoreSupport/ChromiumIncludes.h
+++ b/WebKit/android/WebCoreSupport/ChromiumIncludes.h
@@ -57,6 +57,7 @@
#include <chrome/browser/net/sqlite_persistent_cookie_store.h>
#include <net/base/auth.h>
#include <net/base/cookie_monster.h>
+#include <net/base/cookie_policy.h>
#include <net/base/data_url.h>
#include <net/base/host_resolver.h>
#include <net/base/io_buffer.h>
diff --git a/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp
index 03a7912..092676b 100644
--- a/WebKit/android/WebCoreSupport/PlatformBridge.cpp
+++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp
@@ -101,11 +101,16 @@ String PlatformBridge::cookies(const Document* document, const KURL& url)
bool PlatformBridge::cookiesEnabled(const Document* document)
{
+#if USE(CHROME_NETWORK_STACK)
+ bool isPrivateBrowsing = document->settings() && document->settings()->privateBrowsingEnabled();
+ return WebRequestContext::get(isPrivateBrowsing)->allowCookies();
+#else
CookieClient* client = JavaSharedClient::GetCookieClient();
if (!client)
return false;
return client->cookiesEnabled();
+#endif
}
NPObject* PlatformBridge::pluginScriptableObject(Widget* widget)
diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.cpp b/WebKit/android/WebCoreSupport/WebRequestContext.cpp
index 2ff3ae8..aa5311f 100644
--- a/WebKit/android/WebCoreSupport/WebRequestContext.cpp
+++ b/WebKit/android/WebCoreSupport/WebRequestContext.cpp
@@ -37,7 +37,6 @@
#include <sys/stat.h>
#include <unistd.h>
#include <wtf/text/CString.h>
-#include <wtf/Threading.h>
namespace {
// TODO: The userAgent should not be a static, as it can be set per WebView.
@@ -65,6 +64,7 @@ static scoped_refptr<WebRequestContext> privateBrowsingContext(0);
static WTF::Mutex privateBrowsingContextMutex;
WebRequestContext::WebRequestContext()
+ : m_allowCookies(true)
{
// Also hardcoded in FrameLoader.java
accept_charset_ = "utf-8, iso-8859-1, utf-16, *;q=0.7";
@@ -163,6 +163,7 @@ WebRequestContext* WebRequestContext::getContextForPath(const char* cookieFilena
net::CookieMonster::EnableFileScheme();
context->cookie_store_ = new net::CookieMonster(cookieDb.get(), 0);
+ context->cookie_policy_ = context;
return context;
}
@@ -238,4 +239,27 @@ bool WebRequestContext::cleanupPrivateBrowsingFiles(const std::string& databaseD
return false;
}
+int WebRequestContext::CanGetCookies(const GURL&, const GURL&, net::CompletionCallback*)
+{
+ MutexLocker lock(m_allowCookiesMutex);
+ return m_allowCookies ? net::OK : net::ERR_ACCESS_DENIED;
+}
+
+int WebRequestContext::CanSetCookie(const GURL&, const GURL&, const std::string&, net::CompletionCallback*)
+{
+ MutexLocker lock(m_allowCookiesMutex);
+ return m_allowCookies ? net::OK : net::ERR_ACCESS_DENIED;
+}
+
+bool WebRequestContext::allowCookies() {
+ MutexLocker lock(m_allowCookiesMutex);
+ return m_allowCookies;
+}
+
+void WebRequestContext::setAllowCookies(bool allow)
+{
+ MutexLocker lock(m_allowCookiesMutex);
+ m_allowCookies = allow;
+}
+
} // namespace android
diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.h b/WebKit/android/WebCoreSupport/WebRequestContext.h
index 788998e..f4a579c 100644
--- a/WebKit/android/WebCoreSupport/WebRequestContext.h
+++ b/WebKit/android/WebCoreSupport/WebRequestContext.h
@@ -29,14 +29,20 @@
#include "ChromiumIncludes.h"
#include "PlatformString.h"
+#include <wtf/ThreadingPrimitives.h>
+
namespace android {
-class WebRequestContext : public URLRequestContext {
+class WebRequestContext : public URLRequestContext, net::CookiePolicy {
public:
// URLRequestContext overrides.
virtual const std::string& GetUserAgent(const GURL&) const;
virtual const std::string& GetAcceptLanguage() const;
+ // CookiePolicy implementation.
+ virtual int CanGetCookies(const GURL& url, const GURL& first_party_for_cookies, net::CompletionCallback*);
+ virtual int CanSetCookie(const GURL& url, const GURL& first_party_for_cookies, const std::string& cookie_line, net::CompletionCallback*);
+
// Lazily create the relevant context. This class holds a reference.
// This may be called on any thread. The context returned, however, is not
// threadsafe, and should only be used on a single thread (the network stack
@@ -47,6 +53,8 @@ public:
static bool cleanupPrivateBrowsingFiles(const std::string& databaseDirectory, const std::string& cacheDirectory);
static void setUserAgent(WTF::String);
static void setAcceptLanguage(WTF::String);
+ bool allowCookies();
+ void setAllowCookies(bool allow);
private:
WebRequestContext();
@@ -55,6 +63,9 @@ private:
static WebRequestContext* getContextForPath(const char* cookieFilename, const char* cacheFilename);
static WebRequestContext* getRegularContext();
static WebRequestContext* getPrivateBrowsingContext();
+
+ bool m_allowCookies;
+ WTF::Mutex m_allowCookiesMutex;
};
} // namespace android