Chromium Code Reviews| 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 |
| 219 scoped_ptr<ExternalProtocolHandler::ScopedUserGesture> scoped_gesture; | |
| 220 if (user_gesture) | |
| 221 scoped_gesture.reset(new ExternalProtocolHandler::ScopedUserGesture); | |
|
mmenke
2014/03/31 14:38:42
Can't this just be put this logic in ExternalProto
meacer
2014/03/31 18:32:30
Passing the user gesture bit directly to the exter
mmenke
2014/03/31 18:38:40
Do you mean putting the scoped_gesture in External
meacer
2014/03/31 19:34:00
I meant pushing the user_gesture bit all the way d
| |
| 218 ExternalProtocolHandler::LaunchUrlWithDelegate( | 222 ExternalProtocolHandler::LaunchUrlWithDelegate( |
| 219 url, render_process_id, render_view_id, | 223 url, render_process_id, render_view_id, |
| 220 g_external_protocol_handler_delegate); | 224 g_external_protocol_handler_delegate); |
| 221 } | 225 } |
| 222 #endif // !defined(OS_ANDROID) | 226 #endif // !defined(OS_ANDROID) |
| 223 | 227 |
| 224 void AppendComponentUpdaterThrottles( | 228 void AppendComponentUpdaterThrottles( |
| 225 net::URLRequest* request, | 229 net::URLRequest* request, |
| 226 content::ResourceContext* resource_context, | 230 content::ResourceContext* resource_context, |
| 227 ResourceType::Type resource_type, | 231 ResourceType::Type resource_type, |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 } | 438 } |
| 435 } | 439 } |
| 436 | 440 |
| 437 ResourceDispatcherHostLoginDelegate* | 441 ResourceDispatcherHostLoginDelegate* |
| 438 ChromeResourceDispatcherHostDelegate::CreateLoginDelegate( | 442 ChromeResourceDispatcherHostDelegate::CreateLoginDelegate( |
| 439 net::AuthChallengeInfo* auth_info, net::URLRequest* request) { | 443 net::AuthChallengeInfo* auth_info, net::URLRequest* request) { |
| 440 return CreateLoginPrompt(auth_info, request); | 444 return CreateLoginPrompt(auth_info, request); |
| 441 } | 445 } |
| 442 | 446 |
| 443 bool ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( | 447 bool ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( |
| 444 const GURL& url, int child_id, int route_id) { | 448 const GURL& url, |
| 449 int child_id, | |
| 450 int route_id, | |
| 451 bool initiated_by_user_gesture) { | |
| 445 #if defined(OS_ANDROID) | 452 #if defined(OS_ANDROID) |
| 446 // Android use a resource throttle to handle external as well as internal | 453 // Android use a resource throttle to handle external as well as internal |
| 447 // protocols. | 454 // protocols. |
| 448 return false; | 455 return false; |
| 449 #else | 456 #else |
| 450 | 457 |
| 451 ExtensionRendererState::WebViewInfo info; | 458 ExtensionRendererState::WebViewInfo info; |
| 452 if (ExtensionRendererState::GetInstance()->GetWebViewInfo(child_id, | 459 if (ExtensionRendererState::GetInstance()->GetWebViewInfo(child_id, |
| 453 route_id, | 460 route_id, |
| 454 &info)) { | 461 &info)) { |
| 455 return false; | 462 return false; |
| 456 } | 463 } |
| 457 | 464 |
| 458 BrowserThread::PostTask( | 465 BrowserThread::PostTask( |
| 459 BrowserThread::UI, FROM_HERE, | 466 BrowserThread::UI, FROM_HERE, |
| 460 base::Bind(&LaunchURL, url, child_id, route_id)); | 467 base::Bind(&LaunchURL, url, child_id, route_id, |
| 468 initiated_by_user_gesture)); | |
| 461 return true; | 469 return true; |
| 462 #endif | 470 #endif |
| 463 } | 471 } |
| 464 | 472 |
| 465 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( | 473 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( |
| 466 net::URLRequest* request, | 474 net::URLRequest* request, |
| 467 content::ResourceContext* resource_context, | 475 content::ResourceContext* resource_context, |
| 468 ResourceType::Type resource_type, | 476 ResourceType::Type resource_type, |
| 469 ScopedVector<content::ResourceThrottle>* throttles) { | 477 ScopedVector<content::ResourceThrottle>* throttles) { |
| 470 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 478 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 url_request->GetTotalReceivedBytes())); | 690 url_request->GetTotalReceivedBytes())); |
| 683 } | 691 } |
| 684 } | 692 } |
| 685 | 693 |
| 686 // static | 694 // static |
| 687 void ChromeResourceDispatcherHostDelegate:: | 695 void ChromeResourceDispatcherHostDelegate:: |
| 688 SetExternalProtocolHandlerDelegateForTesting( | 696 SetExternalProtocolHandlerDelegateForTesting( |
| 689 ExternalProtocolHandler::Delegate* delegate) { | 697 ExternalProtocolHandler::Delegate* delegate) { |
| 690 g_external_protocol_handler_delegate = delegate; | 698 g_external_protocol_handler_delegate = delegate; |
| 691 } | 699 } |
| OLD | NEW |