Chromium Code Reviews| Index: android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc |
| diff --git a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc |
| index cb5d870e7112089e0c5940d503ea7901378e8fce..aad7981782620b55c899f51829067fefa42f886e 100644 |
| --- a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc |
| +++ b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc |
| @@ -6,6 +6,7 @@ |
| #include "android_webview/browser/aw_login_delegate.h" |
| #include "android_webview/browser/aw_contents_io_thread_client.h" |
| +#include "android_webview/common/url_constants.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/scoped_vector.h" |
| #include "content/public/browser/resource_controller.h" |
| @@ -58,23 +59,35 @@ void AwResourceDispatcherHostDelegate::RequestBeginning( |
| bool is_continuation_of_transferred_request, |
| ScopedVector<content::ResourceThrottle>* throttles) { |
| - // Part of Implemention of WebSettings.blockNetworkLoads. |
| scoped_ptr<AwContentsIoThreadClient> io_client = |
| AwContentsIoThreadClient::FromID(child_id, route_id); |
| DCHECK(io_client.get()); |
| + // Part of implementation of WebSettings.allowContentAccess. |
| + if (io_client->ShouldBlockContentUrls() && |
| + request->url().SchemeIs(android_webview::kContentScheme)) { |
|
joth
2012/10/08 17:29:01
nit: swap expression order: if (SchemeIs(content)
mnaganov (inactive)
2012/10/09 09:59:36
Done.
|
| + throttles->push_back(new CancelResourceThrottle); |
| + } |
| + |
| + // Part of implementation of WebSettings.allowFileAccess. |
| + if (io_client->ShouldBlockFileUrls() && request->url().SchemeIsFile()) { |
|
joth
2012/10/08 17:29:01
ditto
mnaganov (inactive)
2012/10/09 09:59:36
Done.
|
| + const GURL& url = request->url(); |
| + if (!url.has_path() || |
| + // Application's assets and resources are always available. |
| + (url.path().find(android_webview::kAndroidResourcePath) != 0 && |
| + url.path().find(android_webview::kAndroidAssetPath) != 0)) { |
| + throttles->push_back(new CancelResourceThrottle); |
| + } |
| + } |
| + |
| + // Part of implementation of WebSettings.blockNetworkLoads. |
| if (io_client->ShouldBlockNetworkLoads()) { |
| // Need to cancel ftp since it does not support net::LOAD_ONLY_FROM_CACHE |
| // flag, so must cancel the request if network load is blocked. |
| if (request->url().SchemeIs(chrome::kFtpScheme)) { |
| throttles->push_back(new CancelResourceThrottle); |
| } else { |
| - int load_flags = request->load_flags(); |
| - load_flags &= ~(net::LOAD_BYPASS_CACHE & |
| - net::LOAD_VALIDATE_CACHE & |
| - net::LOAD_PREFERRING_CACHE); |
| - load_flags |= net::LOAD_ONLY_FROM_CACHE; |
| - request->set_load_flags(load_flags); |
| + SetAllowOnlyLoadFromCache(request); |
| } |
| } |
| } |
| @@ -92,4 +105,14 @@ content::ResourceDispatcherHostLoginDelegate* |
| return new AwLoginDelegate(auth_info, request); |
| } |
| +void AwResourceDispatcherHostDelegate::SetAllowOnlyLoadFromCache( |
|
joth
2012/10/08 17:29:01
nit: maybe easier to read as SetOnlyAllowLoadFromC
mnaganov (inactive)
2012/10/09 09:59:36
Done.
|
| + net::URLRequest* request) { |
| + int load_flags = request->load_flags(); |
| + load_flags &= ~(net::LOAD_BYPASS_CACHE & |
| + net::LOAD_VALIDATE_CACHE & |
| + net::LOAD_PREFERRING_CACHE); |
| + load_flags |= net::LOAD_ONLY_FROM_CACHE; |
| + request->set_load_flags(load_flags); |
| +} |
| + |
| } |