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 "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 Profile* profile = | 191 Profile* profile = |
192 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 192 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
193 | 193 |
194 StreamsPrivateAPI* streams_private = StreamsPrivateAPI::Get(profile); | 194 StreamsPrivateAPI* streams_private = StreamsPrivateAPI::Get(profile); |
195 if (!streams_private) | 195 if (!streams_private) |
196 return; | 196 return; |
197 streams_private->ExecuteMimeTypeHandler( | 197 streams_private->ExecuteMimeTypeHandler( |
198 extension_id, web_contents, stream.Pass(), expected_content_size); | 198 extension_id, web_contents, stream.Pass(), expected_content_size); |
199 } | 199 } |
200 | 200 |
201 void LaunchURL(const GURL& url, int render_process_id, int render_view_id) { | 201 void LaunchURL(const GURL& url, int render_process_id, int render_view_id, |
| 202 bool user_gesture) { |
202 // If there is no longer a WebContents, the request may have raced with tab | 203 // If there is no longer a WebContents, the request may have raced with tab |
203 // closing. Don't fire the external request. (It may have been a prerender.) | 204 // closing. Don't fire the external request. (It may have been a prerender.) |
204 content::WebContents* web_contents = | 205 content::WebContents* web_contents = |
205 tab_util::GetWebContentsByID(render_process_id, render_view_id); | 206 tab_util::GetWebContentsByID(render_process_id, render_view_id); |
206 if (!web_contents) | 207 if (!web_contents) |
207 return; | 208 return; |
208 | 209 |
209 // Do not launch external requests attached to unswapped prerenders. | 210 // Do not launch external requests attached to unswapped prerenders. |
210 prerender::PrerenderContents* prerender_contents = | 211 prerender::PrerenderContents* prerender_contents = |
211 prerender::PrerenderContents::FromWebContents(web_contents); | 212 prerender::PrerenderContents::FromWebContents(web_contents); |
212 if (prerender_contents) { | 213 if (prerender_contents) { |
213 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); | 214 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); |
214 prerender::ReportPrerenderExternalURL(); | 215 prerender::ReportPrerenderExternalURL(); |
215 return; | 216 return; |
216 } | 217 } |
217 | 218 |
218 ExternalProtocolHandler::LaunchUrlWithDelegate( | 219 ExternalProtocolHandler::LaunchUrlWithDelegate( |
219 url, render_process_id, render_view_id, | 220 url, render_process_id, render_view_id, |
220 g_external_protocol_handler_delegate); | 221 g_external_protocol_handler_delegate, |
| 222 user_gesture); |
221 } | 223 } |
222 #endif // !defined(OS_ANDROID) | 224 #endif // !defined(OS_ANDROID) |
223 | 225 |
224 void AppendComponentUpdaterThrottles( | 226 void AppendComponentUpdaterThrottles( |
225 net::URLRequest* request, | 227 net::URLRequest* request, |
226 content::ResourceContext* resource_context, | 228 content::ResourceContext* resource_context, |
227 ResourceType::Type resource_type, | 229 ResourceType::Type resource_type, |
228 ScopedVector<content::ResourceThrottle>* throttles) { | 230 ScopedVector<content::ResourceThrottle>* throttles) { |
229 const char* crx_id = NULL; | 231 const char* crx_id = NULL; |
230 component_updater::ComponentUpdateService* cus = | 232 component_updater::ComponentUpdateService* cus = |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 } | 436 } |
435 } | 437 } |
436 | 438 |
437 ResourceDispatcherHostLoginDelegate* | 439 ResourceDispatcherHostLoginDelegate* |
438 ChromeResourceDispatcherHostDelegate::CreateLoginDelegate( | 440 ChromeResourceDispatcherHostDelegate::CreateLoginDelegate( |
439 net::AuthChallengeInfo* auth_info, net::URLRequest* request) { | 441 net::AuthChallengeInfo* auth_info, net::URLRequest* request) { |
440 return CreateLoginPrompt(auth_info, request); | 442 return CreateLoginPrompt(auth_info, request); |
441 } | 443 } |
442 | 444 |
443 bool ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( | 445 bool ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( |
444 const GURL& url, int child_id, int route_id) { | 446 const GURL& url, |
| 447 int child_id, |
| 448 int route_id, |
| 449 bool initiated_by_user_gesture) { |
445 #if defined(OS_ANDROID) | 450 #if defined(OS_ANDROID) |
446 // Android use a resource throttle to handle external as well as internal | 451 // Android use a resource throttle to handle external as well as internal |
447 // protocols. | 452 // protocols. |
448 return false; | 453 return false; |
449 #else | 454 #else |
450 | 455 |
451 ExtensionRendererState::WebViewInfo info; | 456 ExtensionRendererState::WebViewInfo info; |
452 if (ExtensionRendererState::GetInstance()->GetWebViewInfo(child_id, | 457 if (ExtensionRendererState::GetInstance()->GetWebViewInfo(child_id, |
453 route_id, | 458 route_id, |
454 &info)) { | 459 &info)) { |
455 return false; | 460 return false; |
456 } | 461 } |
457 | 462 |
458 BrowserThread::PostTask( | 463 BrowserThread::PostTask( |
459 BrowserThread::UI, FROM_HERE, | 464 BrowserThread::UI, FROM_HERE, |
460 base::Bind(&LaunchURL, url, child_id, route_id)); | 465 base::Bind(&LaunchURL, url, child_id, route_id, |
| 466 initiated_by_user_gesture)); |
461 return true; | 467 return true; |
462 #endif | 468 #endif |
463 } | 469 } |
464 | 470 |
465 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( | 471 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( |
466 net::URLRequest* request, | 472 net::URLRequest* request, |
467 content::ResourceContext* resource_context, | 473 content::ResourceContext* resource_context, |
468 ResourceType::Type resource_type, | 474 ResourceType::Type resource_type, |
469 ScopedVector<content::ResourceThrottle>* throttles) { | 475 ScopedVector<content::ResourceThrottle>* throttles) { |
470 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 476 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 url_request->GetTotalReceivedBytes())); | 688 url_request->GetTotalReceivedBytes())); |
683 } | 689 } |
684 } | 690 } |
685 | 691 |
686 // static | 692 // static |
687 void ChromeResourceDispatcherHostDelegate:: | 693 void ChromeResourceDispatcherHostDelegate:: |
688 SetExternalProtocolHandlerDelegateForTesting( | 694 SetExternalProtocolHandlerDelegateForTesting( |
689 ExternalProtocolHandler::Delegate* delegate) { | 695 ExternalProtocolHandler::Delegate* delegate) { |
690 g_external_protocol_handler_delegate = delegate; | 696 g_external_protocol_handler_delegate = delegate; |
691 } | 697 } |
OLD | NEW |