Index: android_webview/browser/aw_browser_context.cc |
diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc |
index d7f9789df1b413c8ae412d9e2d2549980807e659..8bf6582fd08e04e9df368f0e3ad042a950df2c01 100644 |
--- a/android_webview/browser/aw_browser_context.cc |
+++ b/android_webview/browser/aw_browser_context.cc |
@@ -6,10 +6,35 @@ |
#include "android_webview/browser/net/aw_url_request_context_getter.h" |
#include "components/visitedlink/browser/visitedlink_master.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/resource_context.h" |
+#include "content/public/browser/storage_partition.h" |
#include "content/public/browser/web_contents.h" |
+#include "net/url_request/url_request_context.h" |
namespace android_webview { |
+class AwBrowserContext::AwResourceContext : public content::ResourceContext { |
awong
2013/02/02 03:26:12
Any reason this isn't just file-scoped in an anony
pauljensen
2013/02/04 14:18:54
We need a pointer to it inside AwBrowserContext so
|
+ public: |
+ AwResourceContext(net::URLRequestContextGetter* getter) : getter_(getter) {} |
awong
2013/02/02 03:26:12
explicit
pauljensen
2013/02/04 14:18:54
Done.
|
+ virtual ~AwResourceContext() {} |
+ |
+ // content::ResourceContext implementation: |
awong
2013/02/02 03:26:12
: -> .
Seems to match the prevailing convention f
pauljensen
2013/02/04 14:18:54
Done.
|
+ virtual net::HostResolver* GetHostResolver() OVERRIDE { |
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ return getter_->GetURLRequestContext()->host_resolver(); |
+ } |
+ virtual net::URLRequestContext* GetRequestContext() OVERRIDE { |
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ return getter_->GetURLRequestContext(); |
+ } |
+ |
+ private: |
+ net::URLRequestContextGetter* getter_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AwResourceContext); |
+}; |
+ |
AwBrowserContext::AwBrowserContext( |
const FilePath path, |
GeolocationPermissionFactoryFn* geolocation_permission_factory) |
@@ -53,8 +78,9 @@ bool AwBrowserContext::IsOffTheRecord() const { |
} |
net::URLRequestContextGetter* AwBrowserContext::GetRequestContext() { |
- DCHECK(url_request_context_getter_); |
- return url_request_context_getter_; |
+ content::StoragePartition* storage_partition = |
+ BrowserContext::GetStoragePartition(this, NULL); |
+ return storage_partition->GetURLRequestContext(); |
} |
net::URLRequestContextGetter* |
@@ -63,13 +89,6 @@ AwBrowserContext::GetRequestContextForRenderProcess( |
return GetRequestContext(); |
} |
-net::URLRequestContextGetter* |
-AwBrowserContext::GetRequestContextForStoragePartition( |
- const FilePath& partition_path, |
- bool in_memory) { |
- return GetRequestContext(); |
-} |
- |
net::URLRequestContextGetter* AwBrowserContext::GetMediaRequestContext() { |
return GetRequestContext(); |
} |
@@ -88,7 +107,12 @@ AwBrowserContext::GetMediaRequestContextForStoragePartition( |
} |
content::ResourceContext* AwBrowserContext::GetResourceContext() { |
- return url_request_context_getter_->GetResourceContext(); |
+ if (!resource_context_) { |
+ CHECK(url_request_context_getter_); |
+ resource_context_.reset(new AwResourceContext( |
+ url_request_context_getter_.get())); |
+ } |
+ return resource_context_.get(); |
} |
content::DownloadManagerDelegate* |
@@ -124,4 +148,41 @@ void AwBrowserContext::RebuildTable( |
enumerator->OnComplete(true); |
} |
+net::URLRequestContextGetter* AwBrowserContext::CreateRequestContext( |
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
+ blob_protocol_handler, |
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
+ file_system_protocol_handler, |
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
+ developer_protocol_handler, |
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
+ chrome_protocol_handler, |
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
+ chrome_devtools_protocol_handler) { |
+ CHECK(url_request_context_getter_); |
+ url_request_context_getter_->SetProtocolHandlers( |
+ blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(), |
+ developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(), |
+ chrome_devtools_protocol_handler.Pass()); |
+ return url_request_context_getter_.get(); |
+} |
+ |
+net::URLRequestContextGetter* |
+AwBrowserContext::CreateRequestContextForStoragePartition( |
+ const FilePath& partition_path, |
+ bool in_memory, |
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
+ blob_protocol_handler, |
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
+ file_system_protocol_handler, |
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
+ developer_protocol_handler, |
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
+ chrome_protocol_handler, |
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
+ chrome_devtools_protocol_handler) { |
+ CHECK(url_request_context_getter_); |
+ return url_request_context_getter_.get(); |
+} |
+ |
} // namespace android_webview |