OLD | NEW |
---|---|
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 <string> | 7 #include <string> |
8 | 8 |
9 #include "android_webview/browser/aw_contents_io_thread_client.h" | 9 #include "android_webview/browser/aw_contents_io_thread_client.h" |
10 #include "android_webview/browser/aw_login_delegate.h" | 10 #include "android_webview/browser/aw_login_delegate.h" |
11 #include "android_webview/browser/aw_resource_context.h" | 11 #include "android_webview/browser/aw_resource_context.h" |
12 #include "android_webview/common/url_constants.h" | 12 #include "android_webview/common/url_constants.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "components/auto_login_parser/auto_login_parser.h" | 15 #include "components/auto_login_parser/auto_login_parser.h" |
16 #include "components/navigation_interception/intercept_navigation_delegate.h" | 16 #include "components/navigation_interception/intercept_navigation_delegate.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/resource_controller.h" | 18 #include "content/public/browser/resource_controller.h" |
19 #include "content/public/browser/resource_dispatcher_host.h" | 19 #include "content/public/browser/resource_dispatcher_host.h" |
20 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" | 20 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" |
21 #include "content/public/browser/resource_request_info.h" | 21 #include "content/public/browser/resource_request_info.h" |
22 #include "content/public/browser/resource_throttle.h" | 22 #include "content/public/browser/resource_throttle.h" |
23 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
24 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
25 #include "net/http/http_response_headers.h" | 25 #include "net/http/http_response_headers.h" |
26 #include "net/url_request/url_request.h" | 26 #include "net/url_request/url_request.h" |
27 #include "net/url_request/url_request_status.h" | |
27 #include "url/url_constants.h" | 28 #include "url/url_constants.h" |
28 | 29 |
29 using android_webview::AwContentsIoThreadClient; | 30 using android_webview::AwContentsIoThreadClient; |
30 using content::BrowserThread; | 31 using content::BrowserThread; |
31 using content::ResourceType; | 32 using content::ResourceType; |
32 using navigation_interception::InterceptNavigationDelegate; | 33 using navigation_interception::InterceptNavigationDelegate; |
33 | 34 |
34 namespace { | 35 namespace { |
35 | 36 |
36 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate> | 37 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate> |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 } | 235 } |
235 | 236 |
236 void AwResourceDispatcherHostDelegate::OnRequestRedirected( | 237 void AwResourceDispatcherHostDelegate::OnRequestRedirected( |
237 const GURL& redirect_url, | 238 const GURL& redirect_url, |
238 net::URLRequest* request, | 239 net::URLRequest* request, |
239 content::ResourceContext* resource_context, | 240 content::ResourceContext* resource_context, |
240 content::ResourceResponse* response) { | 241 content::ResourceResponse* response) { |
241 AddExtraHeadersIfNeeded(request, resource_context); | 242 AddExtraHeadersIfNeeded(request, resource_context); |
242 } | 243 } |
243 | 244 |
245 void AwResourceDispatcherHostDelegate::RequestComplete( | |
246 net::URLRequest* request) { | |
247 const content::ResourceRequestInfo* request_info = | |
248 content::ResourceRequestInfo::ForRequest(request); | |
249 if (!request_info) { | |
sgurun-gerrit only
2015/03/17 00:30:04
curious if this can this can actually be null, sin
mnaganov (inactive)
2015/03/17 15:29:09
Thanks for pointing this out! ChromeResourceDispat
| |
250 DLOG(FATAL) << "Completed request without associated info: " << | |
251 request->url(); | |
252 return; | |
253 } | |
254 | |
255 if (!request->status().is_success()) { | |
256 scoped_ptr<AwContentsIoThreadClient> io_client = | |
257 AwContentsIoThreadClient::FromID(request_info->GetChildID(), | |
258 request_info->GetRenderFrameID()); | |
259 if (io_client) { | |
260 io_client->OnReceivedError(request); | |
261 } | |
sgurun-gerrit only
2015/03/17 00:30:04
maybe dlog here if there is no io_client, otherwis
mnaganov (inactive)
2015/03/17 15:29:09
Done.
| |
262 } | |
263 } | |
264 | |
244 | 265 |
245 void AwResourceDispatcherHostDelegate::DownloadStarting( | 266 void AwResourceDispatcherHostDelegate::DownloadStarting( |
246 net::URLRequest* request, | 267 net::URLRequest* request, |
247 content::ResourceContext* resource_context, | 268 content::ResourceContext* resource_context, |
248 int child_id, | 269 int child_id, |
249 int route_id, | 270 int route_id, |
250 int request_id, | 271 int request_id, |
251 bool is_content_initiated, | 272 bool is_content_initiated, |
252 bool must_download, | 273 bool must_download, |
253 ScopedVector<content::ResourceThrottle>* throttles) { | 274 ScopedVector<content::ResourceThrottle>* throttles) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 net::HttpRequestHeaders headers; | 439 net::HttpRequestHeaders headers; |
419 headers.AddHeadersFromString(extra_headers); | 440 headers.AddHeadersFromString(extra_headers); |
420 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { | 441 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { |
421 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); | 442 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); |
422 } | 443 } |
423 } | 444 } |
424 } | 445 } |
425 } | 446 } |
426 | 447 |
427 } // namespace android_webview | 448 } // namespace android_webview |
OLD | NEW |