| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (!profile) | 149 if (!profile) |
| 150 return; | 150 return; |
| 151 | 151 |
| 152 StreamsPrivateAPI* streams_private = StreamsPrivateAPI::Get(profile); | 152 StreamsPrivateAPI* streams_private = StreamsPrivateAPI::Get(profile); |
| 153 if (!streams_private) | 153 if (!streams_private) |
| 154 return; | 154 return; |
| 155 streams_private->ExecuteMimeTypeHandler( | 155 streams_private->ExecuteMimeTypeHandler( |
| 156 extension_id, web_contents, stream.Pass(), expected_content_size); | 156 extension_id, web_contents, stream.Pass(), expected_content_size); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void LaunchURL(const GURL& url, int render_process_id, int render_view_id) { | 159 void LaunchURL(const GURL& url, int render_process_id, int render_view_id, |
| 160 bool user_gesture) { |
| 160 // If there is no longer a WebContents, the request may have raced with tab | 161 // If there is no longer a WebContents, the request may have raced with tab |
| 161 // closing. Don't fire the external request. (It may have been a prerender.) | 162 // closing. Don't fire the external request. (It may have been a prerender.) |
| 162 content::RenderViewHost* rvh = content::RenderViewHost::FromID( | 163 content::RenderViewHost* rvh = content::RenderViewHost::FromID( |
| 163 render_process_id, render_view_id); | 164 render_process_id, render_view_id); |
| 164 if (!rvh) | 165 if (!rvh) |
| 165 return; | 166 return; |
| 166 content::WebContents* web_contents = | 167 content::WebContents* web_contents = |
| 167 content::WebContents::FromRenderViewHost(rvh); | 168 content::WebContents::FromRenderViewHost(rvh); |
| 168 if (!web_contents) | 169 if (!web_contents) |
| 169 return; | 170 return; |
| 170 | 171 |
| 171 // If the request was for a prerender, abort the prerender and do not | 172 // If the request was for a prerender, abort the prerender and do not |
| 172 // continue. | 173 // continue. |
| 173 prerender::PrerenderContents* prerender_contents = | 174 prerender::PrerenderContents* prerender_contents = |
| 174 prerender::PrerenderContents::FromWebContents(web_contents); | 175 prerender::PrerenderContents::FromWebContents(web_contents); |
| 175 if (prerender_contents) { | 176 if (prerender_contents) { |
| 176 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); | 177 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); |
| 177 prerender::ReportPrerenderExternalURL(); | 178 prerender::ReportPrerenderExternalURL(); |
| 178 return; | 179 return; |
| 179 } | 180 } |
| 180 | 181 |
| 181 ExternalProtocolHandler::LaunchUrlWithDelegate( | 182 ExternalProtocolHandler::LaunchUrlWithDelegate( |
| 182 url, render_process_id, render_view_id, | 183 url, render_process_id, render_view_id, |
| 183 g_external_protocol_handler_delegate); | 184 g_external_protocol_handler_delegate, user_gesture); |
| 184 } | 185 } |
| 185 #endif // !defined(OS_ANDROID) | 186 #endif // !defined(OS_ANDROID) |
| 186 | 187 |
| 187 void AppendComponentUpdaterThrottles( | 188 void AppendComponentUpdaterThrottles( |
| 188 net::URLRequest* request, | 189 net::URLRequest* request, |
| 189 content::ResourceContext* resource_context, | 190 content::ResourceContext* resource_context, |
| 190 ResourceType::Type resource_type, | 191 ResourceType::Type resource_type, |
| 191 ScopedVector<content::ResourceThrottle>* throttles) { | 192 ScopedVector<content::ResourceThrottle>* throttles) { |
| 192 const char* crx_id = NULL; | 193 const char* crx_id = NULL; |
| 193 component_updater::ComponentUpdateService* cus = | 194 component_updater::ComponentUpdateService* cus = |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } | 397 } |
| 397 } | 398 } |
| 398 | 399 |
| 399 ResourceDispatcherHostLoginDelegate* | 400 ResourceDispatcherHostLoginDelegate* |
| 400 ChromeResourceDispatcherHostDelegate::CreateLoginDelegate( | 401 ChromeResourceDispatcherHostDelegate::CreateLoginDelegate( |
| 401 net::AuthChallengeInfo* auth_info, net::URLRequest* request) { | 402 net::AuthChallengeInfo* auth_info, net::URLRequest* request) { |
| 402 return CreateLoginPrompt(auth_info, request); | 403 return CreateLoginPrompt(auth_info, request); |
| 403 } | 404 } |
| 404 | 405 |
| 405 bool ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( | 406 bool ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( |
| 406 const GURL& url, int child_id, int route_id) { | 407 const GURL& url, int child_id, int route_id, bool user_gesture) { |
| 407 #if defined(OS_ANDROID) | 408 #if defined(OS_ANDROID) |
| 408 // Android use a resource throttle to handle external as well as internal | 409 // Android use a resource throttle to handle external as well as internal |
| 409 // protocols. | 410 // protocols. |
| 410 return false; | 411 return false; |
| 411 #else | 412 #else |
| 412 | 413 |
| 413 ExtensionRendererState::WebViewInfo info; | 414 ExtensionRendererState::WebViewInfo info; |
| 414 if (ExtensionRendererState::GetInstance()->GetWebViewInfo(child_id, | 415 if (ExtensionRendererState::GetInstance()->GetWebViewInfo(child_id, |
| 415 route_id, | 416 route_id, |
| 416 &info)) { | 417 &info)) { |
| 417 return false; | 418 return false; |
| 418 } | 419 } |
| 419 | 420 |
| 420 BrowserThread::PostTask( | 421 BrowserThread::PostTask( |
| 421 BrowserThread::UI, FROM_HERE, | 422 BrowserThread::UI, FROM_HERE, |
| 422 base::Bind(&LaunchURL, url, child_id, route_id)); | 423 base::Bind(&LaunchURL, url, child_id, route_id, user_gesture)); |
| 423 return true; | 424 return true; |
| 424 #endif | 425 #endif |
| 425 } | 426 } |
| 426 | 427 |
| 427 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( | 428 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( |
| 428 net::URLRequest* request, | 429 net::URLRequest* request, |
| 429 content::ResourceContext* resource_context, | 430 content::ResourceContext* resource_context, |
| 430 ResourceType::Type resource_type, | 431 ResourceType::Type resource_type, |
| 431 ScopedVector<content::ResourceThrottle>* throttles) { | 432 ScopedVector<content::ResourceThrottle>* throttles) { |
| 432 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 433 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data, | 621 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data, |
| 621 info->GetChildID(), info->GetRouteID()); | 622 info->GetChildID(), info->GetRouteID()); |
| 622 } | 623 } |
| 623 | 624 |
| 624 // static | 625 // static |
| 625 void ChromeResourceDispatcherHostDelegate:: | 626 void ChromeResourceDispatcherHostDelegate:: |
| 626 SetExternalProtocolHandlerDelegateForTesting( | 627 SetExternalProtocolHandlerDelegateForTesting( |
| 627 ExternalProtocolHandler::Delegate* delegate) { | 628 ExternalProtocolHandler::Delegate* delegate) { |
| 628 g_external_protocol_handler_delegate = delegate; | 629 g_external_protocol_handler_delegate = delegate; |
| 629 } | 630 } |
| OLD | NEW |