summaryrefslogtreecommitdiffstats
path: root/WebKit/android
diff options
context:
space:
mode:
authorElliott Slaughter <eds@google.com>2010-08-05 17:27:44 -0700
committerElliott Slaughter <eds@google.com>2010-08-17 13:40:44 -0700
commitaf55f2069e35150538b12690c2c881579443cf43 (patch)
tree496f96b0c9857d931c8aea91b54c911799f85c7d /WebKit/android
parent4bd4a23f634cde6e058898549605ea9a3bf3ec3c (diff)
downloadexternal_webkit-af55f2069e35150538b12690c2c881579443cf43.zip
external_webkit-af55f2069e35150538b12690c2c881579443cf43.tar.gz
external_webkit-af55f2069e35150538b12690c2c881579443cf43.tar.bz2
Browser incognito mode support for cookies and cache with chrome http stack.
Change-Id: Ib097f8fda80cf33185d9b6a3a00a47ca83a7e678
Diffstat (limited to 'WebKit/android')
-rw-r--r--WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp2
-rw-r--r--WebKit/android/WebCoreSupport/WebRequest.cpp8
-rw-r--r--WebKit/android/WebCoreSupport/WebRequest.h2
-rw-r--r--WebKit/android/WebCoreSupport/WebRequestContext.cpp50
-rw-r--r--WebKit/android/WebCoreSupport/WebRequestContext.h2
-rw-r--r--WebKit/android/WebCoreSupport/WebUrlLoader.cpp8
-rw-r--r--WebKit/android/WebCoreSupport/WebUrlLoader.h2
-rw-r--r--WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp6
-rw-r--r--WebKit/android/WebCoreSupport/WebUrlLoaderClient.h2
9 files changed, 52 insertions, 30 deletions
diff --git a/WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp b/WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp
index 2b2ad95..8872a52 100644
--- a/WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp
@@ -36,7 +36,7 @@ using namespace android;
namespace WebCore {
PassRefPtr<ResourceLoaderAndroid> ResourceLoaderAndroid::start(
- ResourceHandle* handle, const ResourceRequest& request, FrameLoaderClient* client, bool isMainResource, bool isSync)
+ ResourceHandle* handle, const ResourceRequest& request, FrameLoaderClient* client, bool isMainResource, bool isSync, bool /*isPrivateBrowsing*/)
{
FrameLoaderClientAndroid* clientAndroid = static_cast<FrameLoaderClientAndroid*> (client);
return clientAndroid->webFrame()->startLoadingResource(handle, request, isMainResource, isSync);
diff --git a/WebKit/android/WebCoreSupport/WebRequest.cpp b/WebKit/android/WebCoreSupport/WebRequest.cpp
index 45318bc..9118baf 100644
--- a/WebKit/android/WebCoreSupport/WebRequest.cpp
+++ b/WebKit/android/WebCoreSupport/WebRequest.cpp
@@ -84,13 +84,17 @@ void WebRequest::AppendBytesToUpload(const char* bytes, int bytesLen)
m_request->AppendBytesToUpload(bytes, bytesLen);
}
-void WebRequest::start()
+void WebRequest::start(bool isPrivateBrowsing)
{
// Handle data urls before we send it off to the http stack
if (m_request->url().SchemeIs("data"))
return handleDataURL(m_request->url());
- m_request->set_context(WebRequestContext::GetAndroidContext());
+ if (!isPrivateBrowsing)
+ m_request->set_context(WebRequestContext::GetAndroidContext());
+ else
+ m_request->set_context(WebRequestContext::GetAndroidPrivateBrowsingContext());
+
m_request->Start();
}
diff --git a/WebKit/android/WebCoreSupport/WebRequest.h b/WebKit/android/WebCoreSupport/WebRequest.h
index 2bd86d8..9c9c830 100644
--- a/WebKit/android/WebCoreSupport/WebRequest.h
+++ b/WebKit/android/WebCoreSupport/WebRequest.h
@@ -45,7 +45,7 @@ public:
// Optional, but if used has to be called before start
void AppendBytesToUpload(const char* bytes, int bytesLen);
- void start();
+ void start(bool isPrivateBrowsing);
void cancel();
// From URLRequest::Delegate
diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.cpp b/WebKit/android/WebCoreSupport/WebRequestContext.cpp
index e9ef24c..1de066e 100644
--- a/WebKit/android/WebCoreSupport/WebRequestContext.cpp
+++ b/WebKit/android/WebCoreSupport/WebRequestContext.cpp
@@ -77,28 +77,44 @@ const std::string* WebRequestContext::GetDataDirectory()
return s_dataDirectory;
}
+WebRequestContext* WebRequestContext::GetAndroidContextForPath(const char* cookieFilename, const char* cacheFilename)
+{
+ std::string cookieString(*GetDataDirectory());
+ cookieString.append(cookieFilename);
+ FilePath cookiePath(cookieString.c_str());
+ std::string cacheString(*GetDataDirectory());
+ cacheString.append(cacheFilename);
+ FilePath cachePath(cacheString.c_str());
+
+ scoped_refptr<WebRequestContext> androidContext = new WebRequestContext();
+ androidContext->host_resolver_ = net::CreateSystemHostResolver(0);
+ scoped_refptr<base::MessageLoopProxy> cacheMessageLoopProxy = base::MessageLoopProxy::CreateForCurrentThread();
+ // Todo: check if the context takes ownership of the cache
+ net::HttpCache::DefaultBackend* defaultBackend = new net::HttpCache::DefaultBackend(net::DISK_CACHE, cachePath, 20 * 1024 * 1024, cacheMessageLoopProxy);
+ androidContext->http_transaction_factory_ = new net::HttpCache(androidContext->host_resolver(), net::ProxyService::CreateNull(), net::SSLConfigService::CreateSystemSSLConfigService(), 0, 0, 0, defaultBackend);
+
+ scoped_refptr<SQLitePersistentCookieStore> cookieDb = new SQLitePersistentCookieStore(cookiePath);
+ androidContext->cookie_store_ = new net::CookieMonster(cookieDb.get(), 0);
+
+ return androidContext.release();
+}
+
WebRequestContext* WebRequestContext::GetAndroidContext()
{
static scoped_refptr<WebRequestContext> androidContext(0);
+ if (!androidContext)
+ androidContext = GetAndroidContextForPath("/chromecookies.db", "/chromecache");
+ return androidContext;
+}
+
+WebRequestContext* WebRequestContext::GetAndroidPrivateBrowsingContext()
+{
+ static scoped_refptr<WebRequestContext> androidContext(0);
if (!androidContext) {
- std::string cookieString(*GetDataDirectory());
- cookieString.append("/chromecookies.db");
- FilePath cookiePath(cookieString.c_str());
- std::string cacheString(*GetDataDirectory());
- cacheString.append("/chromecache");
- FilePath cachePath(cacheString.c_str());
-
- androidContext = new WebRequestContext();
- androidContext->host_resolver_ = net::CreateSystemHostResolver(0);
- scoped_refptr<base::MessageLoopProxy> cacheMessageLoopProxy = base::MessageLoopProxy::CreateForCurrentThread();
- // Todo: check if the context takes ownership of the cache
- net::HttpCache::DefaultBackend* defaultBackend = new net::HttpCache::DefaultBackend(net::DISK_CACHE, cachePath, 20 * 1024 * 1024, cacheMessageLoopProxy);
- androidContext->http_transaction_factory_ = new net::HttpCache(androidContext->host_resolver(), net::ProxyService::CreateNull(), net::SSLConfigService::CreateSystemSSLConfigService(), 0, 0, 0, defaultBackend);
-
- scoped_refptr<SQLitePersistentCookieStore> cookieDb = new SQLitePersistentCookieStore(cookiePath);
- androidContext->cookie_store_ = new net::CookieMonster(cookieDb.get(), 0);
+ // TODO: Where is the right place to put the temporary db? Should it be
+ // kept in memory?
+ androidContext = GetAndroidContextForPath("/chromecookies_private.db", "/chromecache_private");
}
-
return androidContext;
}
diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.h b/WebKit/android/WebCoreSupport/WebRequestContext.h
index 0ff081c..c321528 100644
--- a/WebKit/android/WebCoreSupport/WebRequestContext.h
+++ b/WebKit/android/WebCoreSupport/WebRequestContext.h
@@ -40,8 +40,10 @@ class WebRequestContext : public URLRequestContext {
public:
virtual const std::string& GetUserAgent(const GURL& url) const;
static WebRequestContext* GetAndroidContext();
+ static WebRequestContext* GetAndroidPrivateBrowsingContext();
private:
static const std::string* GetDataDirectory();
+ static WebRequestContext* GetAndroidContextForPath(const char* cookiePath, const char* cachePath);
WebRequestContext();
~WebRequestContext();
diff --git a/WebKit/android/WebCoreSupport/WebUrlLoader.cpp b/WebKit/android/WebCoreSupport/WebUrlLoader.cpp
index 9df58e4..4b815c6 100644
--- a/WebKit/android/WebCoreSupport/WebUrlLoader.cpp
+++ b/WebKit/android/WebCoreSupport/WebUrlLoader.cpp
@@ -42,10 +42,10 @@ WebUrlLoader::~WebUrlLoader()
{
}
-PassRefPtr<WebUrlLoader> WebUrlLoader::start(WebCore::ResourceHandle* resourceHandle, const WebCore::ResourceRequest& resourceRequest, bool isSync)
+PassRefPtr<WebUrlLoader> WebUrlLoader::start(WebCore::ResourceHandle* resourceHandle, const WebCore::ResourceRequest& resourceRequest, bool isSync, bool isPrivateBrowsing)
{
RefPtr<WebUrlLoader> loader = WebUrlLoader::create(resourceHandle, resourceRequest);
- loader->m_loaderClient->start(isSync);
+ loader->m_loaderClient->start(isSync, isPrivateBrowsing);
return loader.release();
}
@@ -69,9 +69,9 @@ namespace WebCore {
// static
// TODO: Implement sync requests
PassRefPtr<ResourceLoaderAndroid> ResourceLoaderAndroid::start(WebCore::ResourceHandle* resourceHandle, const WebCore::ResourceRequest& resourceRequest,
- FrameLoaderClient* /*client*/, bool /*isMainResource*/, bool isSync)
+ FrameLoaderClient* /*client*/, bool /*isMainResource*/, bool isSync, bool isPrivateBrowsing)
{
- return android::WebUrlLoader::start(resourceHandle, resourceRequest, isSync);
+ return android::WebUrlLoader::start(resourceHandle, resourceRequest, isSync, isPrivateBrowsing);
}
// static
diff --git a/WebKit/android/WebCoreSupport/WebUrlLoader.h b/WebKit/android/WebCoreSupport/WebUrlLoader.h
index 167bdc0..c465b66 100644
--- a/WebKit/android/WebCoreSupport/WebUrlLoader.h
+++ b/WebKit/android/WebCoreSupport/WebUrlLoader.h
@@ -36,7 +36,7 @@ class WebUrlLoaderClient;
class WebUrlLoader : public ResourceLoaderAndroid {
public:
virtual ~WebUrlLoader();
- static PassRefPtr<WebUrlLoader> start(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, bool sync);
+ static PassRefPtr<WebUrlLoader> start(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, bool sync, bool isPrivateBrowsing);
virtual void cancel();
virtual void downloadFile() {} // Not implemented yet
diff --git a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
index 33f94af..e3ee14c 100644
--- a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
+++ b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
@@ -143,7 +143,7 @@ WebUrlLoaderClient::WebUrlLoaderClient(WebCore::ResourceHandle* resourceHandle,
}
}
-bool WebUrlLoaderClient::start(bool sync)
+bool WebUrlLoaderClient::start(bool sync, bool isPrivateBrowsing)
{
base::Thread* thread = ioThread();
if (!thread) {
@@ -153,7 +153,7 @@ bool WebUrlLoaderClient::start(bool sync)
m_sync = sync;
if (m_sync) {
AutoLock autoLock(*syncLock());
- thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request, &WebRequest::start));
+ thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request, &WebRequest::start, isPrivateBrowsing));
// Run callbacks until the queue is exhausted and m_finished is true.
while(!m_finished) {
@@ -174,7 +174,7 @@ bool WebUrlLoaderClient::start(bool sync)
m_resourceHandle = 0;
} else {
// Asynchronous start.
- thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request, &WebRequest::start));
+ thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request, &WebRequest::start, isPrivateBrowsing));
}
return true;
}
diff --git a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.h b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.h
index 4231d02..a761f15 100644
--- a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.h
+++ b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.h
@@ -63,7 +63,7 @@ public:
~WebUrlLoaderClient();
// Called from WebCore, will be forwarded to the IO thread
- bool start(bool sync);
+ bool start(bool sync, bool isPrivateBrowsing);
void cancel();
void downloadFile();
void pauseLoad(bool pause) {} // Android method, does nothing for now