| 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 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 url, | 231 url, |
| 232 GURL(), | 232 GURL(), |
| 233 &plugin)) { | 233 &plugin)) { |
| 234 return true; | 234 return true; |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 return false; | 237 return false; |
| 238 } | 238 } |
| 239 #endif // !defined(ENABLE_EXTENSIONS) | 239 #endif // !defined(ENABLE_EXTENSIONS) |
| 240 | 240 |
| 241 #if !defined(OS_ANDROID) | 241 void LaunchURL( |
| 242 void LaunchURL(const GURL& url, int render_process_id, int render_view_id) { | 242 const GURL& url, |
| 243 int render_process_id, |
| 244 int render_view_id, |
| 245 ui::PageTransition page_transition, |
| 246 bool has_user_gesture) { |
| 243 // If there is no longer a WebContents, the request may have raced with tab | 247 // If there is no longer a WebContents, the request may have raced with tab |
| 244 // closing. Don't fire the external request. (It may have been a prerender.) | 248 // closing. Don't fire the external request. (It may have been a prerender.) |
| 245 content::WebContents* web_contents = | 249 content::WebContents* web_contents = |
| 246 tab_util::GetWebContentsByID(render_process_id, render_view_id); | 250 tab_util::GetWebContentsByID(render_process_id, render_view_id); |
| 247 if (!web_contents) | 251 if (!web_contents) |
| 248 return; | 252 return; |
| 249 | 253 |
| 250 // Do not launch external requests attached to unswapped prerenders. | 254 // Do not launch external requests attached to unswapped prerenders. |
| 251 prerender::PrerenderContents* prerender_contents = | 255 prerender::PrerenderContents* prerender_contents = |
| 252 prerender::PrerenderContents::FromWebContents(web_contents); | 256 prerender::PrerenderContents::FromWebContents(web_contents); |
| 253 if (prerender_contents) { | 257 if (prerender_contents) { |
| 254 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); | 258 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); |
| 255 prerender::ReportPrerenderExternalURL(); | 259 prerender::ReportPrerenderExternalURL(); |
| 256 return; | 260 return; |
| 257 } | 261 } |
| 258 | 262 |
| 259 ExternalProtocolHandler::LaunchUrlWithDelegate( | 263 ExternalProtocolHandler::LaunchUrlWithDelegate( |
| 260 url, | 264 url, |
| 261 render_process_id, | 265 render_process_id, |
| 262 render_view_id, | 266 render_view_id, |
| 267 page_transition, |
| 268 has_user_gesture, |
| 263 g_external_protocol_handler_delegate); | 269 g_external_protocol_handler_delegate); |
| 264 } | 270 } |
| 265 #endif // !defined(OS_ANDROID) | |
| 266 | 271 |
| 267 #if !defined(DISABLE_NACL) | 272 #if !defined(DISABLE_NACL) |
| 268 void AppendComponentUpdaterThrottles( | 273 void AppendComponentUpdaterThrottles( |
| 269 net::URLRequest* request, | 274 net::URLRequest* request, |
| 270 content::ResourceContext* resource_context, | 275 content::ResourceContext* resource_context, |
| 271 ResourceType resource_type, | 276 ResourceType resource_type, |
| 272 ScopedVector<content::ResourceThrottle>* throttles) { | 277 ScopedVector<content::ResourceThrottle>* throttles) { |
| 273 const char* crx_id = NULL; | 278 const char* crx_id = NULL; |
| 274 component_updater::ComponentUpdateService* cus = | 279 component_updater::ComponentUpdateService* cus = |
| 275 g_browser_process->component_updater(); | 280 g_browser_process->component_updater(); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 | 513 |
| 509 ResourceDispatcherHostLoginDelegate* | 514 ResourceDispatcherHostLoginDelegate* |
| 510 ChromeResourceDispatcherHostDelegate::CreateLoginDelegate( | 515 ChromeResourceDispatcherHostDelegate::CreateLoginDelegate( |
| 511 net::AuthChallengeInfo* auth_info, net::URLRequest* request) { | 516 net::AuthChallengeInfo* auth_info, net::URLRequest* request) { |
| 512 return CreateLoginPrompt(auth_info, request); | 517 return CreateLoginPrompt(auth_info, request); |
| 513 } | 518 } |
| 514 | 519 |
| 515 bool ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( | 520 bool ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( |
| 516 const GURL& url, | 521 const GURL& url, |
| 517 int child_id, | 522 int child_id, |
| 518 int route_id) { | 523 int route_id, |
| 519 #if defined(OS_ANDROID) | 524 bool is_main_frame, |
| 520 // Android use a resource throttle to handle external as well as internal | 525 ui::PageTransition page_transition, |
| 521 // protocols. | 526 bool has_user_gesture) { |
| 522 return false; | |
| 523 #else | |
| 524 | |
| 525 #if defined(ENABLE_EXTENSIONS) | 527 #if defined(ENABLE_EXTENSIONS) |
| 526 if (extensions::WebViewRendererState::GetInstance()->IsGuest(child_id)) | 528 if (extensions::WebViewRendererState::GetInstance()->IsGuest(child_id)) |
| 527 return false; | 529 return false; |
| 528 | |
| 529 #endif // defined(ENABLE_EXTENSIONS) | 530 #endif // defined(ENABLE_EXTENSIONS) |
| 530 | 531 |
| 531 BrowserThread::PostTask(BrowserThread::UI, | 532 #if defined(OS_ANDROID) |
| 532 FROM_HERE, | 533 // Main frame external protocols are handled by |
| 533 base::Bind(&LaunchURL, url, child_id, route_id)); | 534 // InterceptNavigationResourceThrottle. |
| 535 if (is_main_frame) |
| 536 return false; |
| 537 #endif // defined(ANDROID) |
| 538 |
| 539 BrowserThread::PostTask( |
| 540 BrowserThread::UI, |
| 541 FROM_HERE, |
| 542 base::Bind(&LaunchURL, url, child_id, route_id, page_transition, |
| 543 has_user_gesture)); |
| 534 return true; | 544 return true; |
| 535 #endif | |
| 536 } | 545 } |
| 537 | 546 |
| 538 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( | 547 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( |
| 539 net::URLRequest* request, | 548 net::URLRequest* request, |
| 540 content::ResourceContext* resource_context, | 549 content::ResourceContext* resource_context, |
| 541 ResourceType resource_type, | 550 ResourceType resource_type, |
| 542 ScopedVector<content::ResourceThrottle>* throttles) { | 551 ScopedVector<content::ResourceThrottle>* throttles) { |
| 543 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 552 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 544 #if defined(SAFE_BROWSING_SERVICE) | 553 #if defined(SAFE_BROWSING_SERVICE) |
| 545 // Insert safe browsing at the front of the list, so it gets to decide on | 554 // Insert safe browsing at the front of the list, so it gets to decide on |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 url_request->GetTotalReceivedBytes())); | 770 url_request->GetTotalReceivedBytes())); |
| 762 } | 771 } |
| 763 } | 772 } |
| 764 | 773 |
| 765 // static | 774 // static |
| 766 void ChromeResourceDispatcherHostDelegate:: | 775 void ChromeResourceDispatcherHostDelegate:: |
| 767 SetExternalProtocolHandlerDelegateForTesting( | 776 SetExternalProtocolHandlerDelegateForTesting( |
| 768 ExternalProtocolHandler::Delegate* delegate) { | 777 ExternalProtocolHandler::Delegate* delegate) { |
| 769 g_external_protocol_handler_delegate = delegate; | 778 g_external_protocol_handler_delegate = delegate; |
| 770 } | 779 } |
| OLD | NEW |