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 <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "android_webview/browser/aw_browser_context.h" | 10 #include "android_webview/browser/aw_browser_context.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Called when ResourceDispathcerHost detects a download request. | 59 // Called when ResourceDispathcerHost detects a download request. |
60 // The download is already cancelled when this is called, since | 60 // The download is already cancelled when this is called, since |
61 // relevant for DownloadListener is already extracted. | 61 // relevant for DownloadListener is already extracted. |
62 void DownloadStartingOnUIThread( | 62 void DownloadStartingOnUIThread( |
63 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 63 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
64 const GURL& url, | 64 const GURL& url, |
65 const std::string& user_agent, | 65 const std::string& user_agent, |
66 const std::string& content_disposition, | 66 const std::string& content_disposition, |
67 const std::string& mime_type, | 67 const std::string& mime_type, |
68 int64_t content_length) { | 68 int64_t content_length) { |
69 WebContents* web_contents = web_contents_getter.Run(); | |
70 AwContentsClientBridgeBase* client = | 69 AwContentsClientBridgeBase* client = |
71 AwContentsClientBridgeBase::FromWebContents(web_contents); | 70 AwContentsClientBridgeBase::FromWebContentsGetter(web_contents_getter); |
72 if (!client) | 71 if (!client) |
73 return; | 72 return; |
74 client->NewDownload(url, user_agent, content_disposition, mime_type, | 73 client->NewDownload(url, user_agent, content_disposition, mime_type, |
75 content_length); | 74 content_length); |
76 } | 75 } |
77 | 76 |
| 77 void NewLoginRequestOnUIThread( |
| 78 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
| 79 const std::string& realm, |
| 80 const std::string& account, |
| 81 const std::string& args) { |
| 82 AwContentsClientBridgeBase* client = |
| 83 AwContentsClientBridgeBase::FromWebContentsGetter(web_contents_getter); |
| 84 if (!client) |
| 85 return; |
| 86 client->NewLoginRequest(realm, account, args); |
| 87 } |
| 88 |
78 } // namespace | 89 } // namespace |
79 | 90 |
80 namespace android_webview { | 91 namespace android_webview { |
81 | 92 |
82 // Calls through the IoThreadClient to check the embedders settings to determine | 93 // Calls through the IoThreadClient to check the embedders settings to determine |
83 // if the request should be cancelled. There may not always be an IoThreadClient | 94 // if the request should be cancelled. There may not always be an IoThreadClient |
84 // available for the |render_process_id|, |render_frame_id| pair (in the case of | 95 // available for the |render_process_id|, |render_frame_id| pair (in the case of |
85 // newly created pop up windows, for example) and in that case the request and | 96 // newly created pop up windows, for example) and in that case the request and |
86 // the client callbacks will be deferred the request until a client is ready. | 97 // the client callbacks will be deferred the request until a client is ready. |
87 class IoThreadClientThrottle : public content::ResourceThrottle { | 98 class IoThreadClientThrottle : public content::ResourceThrottle { |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 if (!request_info) { | 363 if (!request_info) { |
353 DLOG(FATAL) << "Started request without associated info: " << | 364 DLOG(FATAL) << "Started request without associated info: " << |
354 request->url(); | 365 request->url(); |
355 return; | 366 return; |
356 } | 367 } |
357 | 368 |
358 if (request_info->GetResourceType() == content::RESOURCE_TYPE_MAIN_FRAME) { | 369 if (request_info->GetResourceType() == content::RESOURCE_TYPE_MAIN_FRAME) { |
359 // Check for x-auto-login header. | 370 // Check for x-auto-login header. |
360 HeaderData header_data; | 371 HeaderData header_data; |
361 if (ParserHeaderInResponse(request, ALLOW_ANY_REALM, &header_data)) { | 372 if (ParserHeaderInResponse(request, ALLOW_ANY_REALM, &header_data)) { |
362 std::unique_ptr<AwContentsIoThreadClient> io_client = | 373 BrowserThread::PostTask( |
363 AwContentsIoThreadClient::FromID(request_info->GetChildID(), | 374 BrowserThread::UI, FROM_HERE, |
364 request_info->GetRenderFrameID()); | 375 base::Bind(&NewLoginRequestOnUIThread, |
365 if (io_client) { | 376 request_info->GetWebContentsGetterForRequest(), |
366 io_client->NewLoginRequest(header_data.realm, header_data.account, | 377 header_data.realm, header_data.account, header_data.args)); |
367 header_data.args); | |
368 } | |
369 } | 378 } |
370 } | 379 } |
371 } | 380 } |
372 | 381 |
373 void AwResourceDispatcherHostDelegate::RemovePendingThrottleOnIoThread( | 382 void AwResourceDispatcherHostDelegate::RemovePendingThrottleOnIoThread( |
374 IoThreadClientThrottle* throttle) { | 383 IoThreadClientThrottle* throttle) { |
375 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 384 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
376 PendingThrottleMap::iterator it = pending_throttles_.find( | 385 PendingThrottleMap::iterator it = pending_throttles_.find( |
377 FrameRouteIDPair(throttle->render_process_id(), | 386 FrameRouteIDPair(throttle->render_process_id(), |
378 throttle->render_frame_id())); | 387 throttle->render_frame_id())); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 net::HttpRequestHeaders headers; | 464 net::HttpRequestHeaders headers; |
456 headers.AddHeadersFromString(extra_headers); | 465 headers.AddHeadersFromString(extra_headers); |
457 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { | 466 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { |
458 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); | 467 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); |
459 } | 468 } |
460 } | 469 } |
461 } | 470 } |
462 } | 471 } |
463 | 472 |
464 } // namespace android_webview | 473 } // namespace android_webview |
OLD | NEW |