Chromium Code Reviews| 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..74488ff4d289e45359a089fee4cd74586b5e50f7 100644 |
| --- a/android_webview/browser/aw_browser_context.cc |
| +++ b/android_webview/browser/aw_browser_context.cc |
| @@ -6,10 +6,40 @@ |
| #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 { |
| +namespace { |
| + |
| +class AwResourceContext : public content::ResourceContext { |
| + public: |
| + explicit AwResourceContext(net::URLRequestContextGetter* getter) |
| + : getter_(getter) {} |
| + virtual ~AwResourceContext() {} |
| + |
| + // content::ResourceContext implementation. |
| + 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); |
| +}; |
| + |
| +} // namespace |
| + |
| AwBrowserContext::AwBrowserContext( |
| const FilePath path, |
| GeolocationPermissionFactoryFn* geolocation_permission_factory) |
| @@ -53,8 +83,7 @@ bool AwBrowserContext::IsOffTheRecord() const { |
| } |
| net::URLRequestContextGetter* AwBrowserContext::GetRequestContext() { |
| - DCHECK(url_request_context_getter_); |
| - return url_request_context_getter_; |
| + return GetDefaultStoragePartition(this)->GetURLRequestContext(); |
| } |
| net::URLRequestContextGetter* |
| @@ -63,13 +92,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 +110,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 +151,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) { |
|
joth
2013/02/07 00:41:41
comment why all the protocol handlers are ignored?
pauljensen
2013/02/07 14:10:54
Since we're returning the same URLRequestContextGe
|
| + CHECK(url_request_context_getter_); |
| + return url_request_context_getter_.get(); |
| +} |
| + |
| } // namespace android_webview |