Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc

Issue 11090003: [Android] Upstream WebView.allow{Content|File}Access implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comments in AwSettings.java Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" 5 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h"
6 6
7 #include "android_webview/browser/aw_login_delegate.h" 7 #include "android_webview/browser/aw_login_delegate.h"
8 #include "android_webview/browser/aw_contents_io_thread_client.h" 8 #include "android_webview/browser/aw_contents_io_thread_client.h"
9 #include "android_webview/common/url_constants.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
11 #include "content/public/browser/resource_controller.h" 12 #include "content/public/browser/resource_controller.h"
12 #include "content/public/browser/resource_dispatcher_host.h" 13 #include "content/public/browser/resource_dispatcher_host.h"
13 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" 14 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
14 #include "content/public/browser/resource_throttle.h" 15 #include "content/public/browser/resource_throttle.h"
15 #include "content/public/common/url_constants.h" 16 #include "content/public/common/url_constants.h"
16 #include "net/base/load_flags.h" 17 #include "net/base/load_flags.h"
17 #include "net/url_request/url_request.h" 18 #include "net/url_request/url_request.h"
18 19
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 void AwResourceDispatcherHostDelegate::RequestBeginning( 52 void AwResourceDispatcherHostDelegate::RequestBeginning(
52 net::URLRequest* request, 53 net::URLRequest* request,
53 content::ResourceContext* resource_context, 54 content::ResourceContext* resource_context,
54 appcache::AppCacheService* appcache_service, 55 appcache::AppCacheService* appcache_service,
55 ResourceType::Type resource_type, 56 ResourceType::Type resource_type,
56 int child_id, 57 int child_id,
57 int route_id, 58 int route_id,
58 bool is_continuation_of_transferred_request, 59 bool is_continuation_of_transferred_request,
59 ScopedVector<content::ResourceThrottle>* throttles) { 60 ScopedVector<content::ResourceThrottle>* throttles) {
60 61
61 // Part of Implemention of WebSettings.blockNetworkLoads.
62 scoped_ptr<AwContentsIoThreadClient> io_client = 62 scoped_ptr<AwContentsIoThreadClient> io_client =
63 AwContentsIoThreadClient::FromID(child_id, route_id); 63 AwContentsIoThreadClient::FromID(child_id, route_id);
64 DCHECK(io_client.get()); 64 DCHECK(io_client.get());
65 65
66 // Part of implementation of WebSettings.allowContentAccess.
67 if (io_client->ShouldBlockContentUrls() &&
68 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.
69 throttles->push_back(new CancelResourceThrottle);
70 }
71
72 // Part of implementation of WebSettings.allowFileAccess.
73 if (io_client->ShouldBlockFileUrls() && request->url().SchemeIsFile()) {
joth 2012/10/08 17:29:01 ditto
mnaganov (inactive) 2012/10/09 09:59:36 Done.
74 const GURL& url = request->url();
75 if (!url.has_path() ||
76 // Application's assets and resources are always available.
77 (url.path().find(android_webview::kAndroidResourcePath) != 0 &&
78 url.path().find(android_webview::kAndroidAssetPath) != 0)) {
79 throttles->push_back(new CancelResourceThrottle);
80 }
81 }
82
83 // Part of implementation of WebSettings.blockNetworkLoads.
66 if (io_client->ShouldBlockNetworkLoads()) { 84 if (io_client->ShouldBlockNetworkLoads()) {
67 // Need to cancel ftp since it does not support net::LOAD_ONLY_FROM_CACHE 85 // Need to cancel ftp since it does not support net::LOAD_ONLY_FROM_CACHE
68 // flag, so must cancel the request if network load is blocked. 86 // flag, so must cancel the request if network load is blocked.
69 if (request->url().SchemeIs(chrome::kFtpScheme)) { 87 if (request->url().SchemeIs(chrome::kFtpScheme)) {
70 throttles->push_back(new CancelResourceThrottle); 88 throttles->push_back(new CancelResourceThrottle);
71 } else { 89 } else {
72 int load_flags = request->load_flags(); 90 SetAllowOnlyLoadFromCache(request);
73 load_flags &= ~(net::LOAD_BYPASS_CACHE &
74 net::LOAD_VALIDATE_CACHE &
75 net::LOAD_PREFERRING_CACHE);
76 load_flags |= net::LOAD_ONLY_FROM_CACHE;
77 request->set_load_flags(load_flags);
78 } 91 }
79 } 92 }
80 } 93 }
81 94
82 bool AwResourceDispatcherHostDelegate::AcceptAuthRequest( 95 bool AwResourceDispatcherHostDelegate::AcceptAuthRequest(
83 net::URLRequest* request, 96 net::URLRequest* request,
84 net::AuthChallengeInfo* auth_info) { 97 net::AuthChallengeInfo* auth_info) {
85 return true; 98 return true;
86 } 99 }
87 100
88 content::ResourceDispatcherHostLoginDelegate* 101 content::ResourceDispatcherHostLoginDelegate*
89 AwResourceDispatcherHostDelegate::CreateLoginDelegate( 102 AwResourceDispatcherHostDelegate::CreateLoginDelegate(
90 net::AuthChallengeInfo* auth_info, 103 net::AuthChallengeInfo* auth_info,
91 net::URLRequest* request) { 104 net::URLRequest* request) {
92 return new AwLoginDelegate(auth_info, request); 105 return new AwLoginDelegate(auth_info, request);
93 } 106 }
94 107
108 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.
109 net::URLRequest* request) {
110 int load_flags = request->load_flags();
111 load_flags &= ~(net::LOAD_BYPASS_CACHE &
112 net::LOAD_VALIDATE_CACHE &
113 net::LOAD_PREFERRING_CACHE);
114 load_flags |= net::LOAD_ONLY_FROM_CACHE;
115 request->set_load_flags(load_flags);
95 } 116 }
117
118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698