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/loader/chrome_resource_dispatcher_host_delegate.h" | 5 #include "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 if (!streams_private) | 213 if (!streams_private) |
214 return; | 214 return; |
215 streams_private->ExecuteMimeTypeHandler( | 215 streams_private->ExecuteMimeTypeHandler( |
216 extension_id, std::move(stream), view_id, expected_content_size, embedded, | 216 extension_id, std::move(stream), view_id, expected_content_size, embedded, |
217 frame_tree_node_id, render_process_id, render_frame_id); | 217 frame_tree_node_id, render_process_id, render_frame_id); |
218 } | 218 } |
219 #endif // !BUILDFLAG(ENABLE_EXTENSIONS) | 219 #endif // !BUILDFLAG(ENABLE_EXTENSIONS) |
220 | 220 |
221 void LaunchURL( | 221 void LaunchURL( |
222 const GURL& url, | 222 const GURL& url, |
223 int render_process_id, | |
224 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 223 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
225 ui::PageTransition page_transition, | 224 ui::PageTransition page_transition, |
226 bool has_user_gesture, | 225 bool has_user_gesture, |
227 bool is_whitelisted) { | 226 bool is_whitelisted) { |
228 // If there is no longer a WebContents, the request may have raced with tab | 227 // If there is no longer a WebContents, the request may have raced with tab |
229 // closing. Don't fire the external request. (It may have been a prerender.) | 228 // closing. Don't fire the external request. (It may have been a prerender.) |
230 content::WebContents* web_contents = web_contents_getter.Run(); | 229 content::WebContents* web_contents = web_contents_getter.Run(); |
231 if (!web_contents) | 230 if (!web_contents) |
232 return; | 231 return; |
233 | 232 |
234 // Do not launch external requests attached to unswapped prerenders. | 233 // Do not launch external requests attached to unswapped prerenders. |
235 prerender::PrerenderContents* prerender_contents = | 234 prerender::PrerenderContents* prerender_contents = |
236 prerender::PrerenderContents::FromWebContents(web_contents); | 235 prerender::PrerenderContents::FromWebContents(web_contents); |
237 if (prerender_contents) { | 236 if (prerender_contents) { |
238 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); | 237 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); |
239 prerender::ReportPrerenderExternalURL(); | 238 prerender::ReportPrerenderExternalURL(); |
240 return; | 239 return; |
241 } | 240 } |
242 | 241 |
243 // If the URL is in whitelist, we launch it without asking the user and | 242 // If the URL is in whitelist, we launch it without asking the user and |
244 // without any additional security checks. Since the URL is whitelisted, | 243 // without any additional security checks. Since the URL is whitelisted, |
245 // we assume it can be executed. | 244 // we assume it can be executed. |
246 // TODO(davidsac): External protocol handling needs to be | |
247 // fixed for OOPIFs. See https://crbug.com/668289. | |
248 if (is_whitelisted) { | 245 if (is_whitelisted) { |
249 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck( | 246 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url, web_contents); |
250 url, render_process_id, | |
251 web_contents->GetRenderViewHost()->GetRoutingID()); | |
252 } else { | 247 } else { |
253 ExternalProtocolHandler::LaunchUrlWithDelegate( | 248 ExternalProtocolHandler::LaunchUrlWithDelegate( |
254 url, render_process_id, | 249 url, web_contents->GetRenderViewHost()->GetProcess()->GetID(), |
255 web_contents->GetRenderViewHost()->GetRoutingID(), page_transition, | 250 web_contents->GetRenderViewHost()->GetRoutingID(), page_transition, |
256 has_user_gesture, g_external_protocol_handler_delegate); | 251 has_user_gesture, g_external_protocol_handler_delegate); |
257 } | 252 } |
258 } | 253 } |
259 | 254 |
260 #if !defined(DISABLE_NACL) | 255 #if !defined(DISABLE_NACL) |
261 void AppendComponentUpdaterThrottles( | 256 void AppendComponentUpdaterThrottles( |
262 net::URLRequest* request, | 257 net::URLRequest* request, |
263 const ResourceRequestInfo& info, | 258 const ResourceRequestInfo& info, |
264 content::ResourceContext* resource_context, | 259 content::ResourceContext* resource_context, |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 ProfileIOData::FromResourceContext(info->GetContext()); | 557 ProfileIOData::FromResourceContext(info->GetContext()); |
563 const policy::URLBlacklist::URLBlacklistState url_state = | 558 const policy::URLBlacklist::URLBlacklistState url_state = |
564 io_data->GetURLBlacklistState(url); | 559 io_data->GetURLBlacklistState(url); |
565 if (url_state == policy::URLBlacklist::URLBlacklistState::URL_IN_BLACKLIST) { | 560 if (url_state == policy::URLBlacklist::URLBlacklistState::URL_IN_BLACKLIST) { |
566 // It's a link with custom scheme and it's blacklisted. We return false here | 561 // It's a link with custom scheme and it's blacklisted. We return false here |
567 // and let it process as a normal URL. Eventually chrome_network_delegate | 562 // and let it process as a normal URL. Eventually chrome_network_delegate |
568 // will see it's in the blacklist and the user will be shown the blocked | 563 // will see it's in the blacklist and the user will be shown the blocked |
569 // content page. | 564 // content page. |
570 return false; | 565 return false; |
571 } | 566 } |
572 int child_id = info->GetChildID(); | 567 |
573 #if BUILDFLAG(ENABLE_EXTENSIONS) | 568 #if BUILDFLAG(ENABLE_EXTENSIONS) |
574 // External protocols are disabled for guests. An exception is made for the | 569 // External protocols are disabled for guests. An exception is made for the |
575 // "mailto" protocol, so that pages that utilize it work properly in a | 570 // "mailto" protocol, so that pages that utilize it work properly in a |
576 // WebView. | 571 // WebView. |
| 572 int child_id = info->GetChildID(); |
577 ChromeNavigationUIData* navigation_data = | 573 ChromeNavigationUIData* navigation_data = |
578 static_cast<ChromeNavigationUIData*>(info->GetNavigationUIData()); | 574 static_cast<ChromeNavigationUIData*>(info->GetNavigationUIData()); |
579 if ((extensions::WebViewRendererState::GetInstance()->IsGuest(child_id) || | 575 if ((extensions::WebViewRendererState::GetInstance()->IsGuest(child_id) || |
580 (navigation_data && | 576 (navigation_data && |
581 navigation_data->GetExtensionNavigationUIData()->is_web_view())) && | 577 navigation_data->GetExtensionNavigationUIData()->is_web_view())) && |
582 !url.SchemeIs(url::kMailToScheme)) { | 578 !url.SchemeIs(url::kMailToScheme)) { |
583 return false; | 579 return false; |
584 } | 580 } |
585 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 581 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
586 | 582 |
587 #if defined(OS_ANDROID) | 583 #if defined(OS_ANDROID) |
588 // Main frame external protocols are handled by | 584 // Main frame external protocols are handled by |
589 // InterceptNavigationResourceThrottle. | 585 // InterceptNavigationResourceThrottle. |
590 if (info->IsMainFrame()) | 586 if (info->IsMainFrame()) |
591 return false; | 587 return false; |
592 #endif // defined(ANDROID) | 588 #endif // defined(ANDROID) |
593 | 589 |
594 const bool is_whitelisted = | 590 const bool is_whitelisted = |
595 url_state == policy::URLBlacklist::URLBlacklistState::URL_IN_WHITELIST; | 591 url_state == policy::URLBlacklist::URLBlacklistState::URL_IN_WHITELIST; |
596 BrowserThread::PostTask( | 592 BrowserThread::PostTask( |
597 BrowserThread::UI, FROM_HERE, | 593 BrowserThread::UI, FROM_HERE, |
598 base::Bind(&LaunchURL, url, child_id, | 594 base::Bind(&LaunchURL, url, info->GetWebContentsGetterForRequest(), |
599 info->GetWebContentsGetterForRequest(), | |
600 info->GetPageTransition(), info->HasUserGesture(), | 595 info->GetPageTransition(), info->HasUserGesture(), |
601 is_whitelisted)); | 596 is_whitelisted)); |
602 return true; | 597 return true; |
603 } | 598 } |
604 | 599 |
605 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( | 600 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( |
606 net::URLRequest* request, | 601 net::URLRequest* request, |
607 content::ResourceContext* resource_context, | 602 content::ResourceContext* resource_context, |
608 ResourceType resource_type, | 603 ResourceType resource_type, |
609 ScopedVector<content::ResourceThrottle>* throttles) { | 604 ScopedVector<content::ResourceThrottle>* throttles) { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 883 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
889 base::Unretained(this), url, request_loading_time)); | 884 base::Unretained(this), url, request_loading_time)); |
890 return; | 885 return; |
891 } | 886 } |
892 | 887 |
893 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 888 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
894 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 889 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
895 rappor::SampleDomainAndRegistryFromGURL( | 890 rappor::SampleDomainAndRegistryFromGURL( |
896 g_browser_process->rappor_service(), metric_name, url); | 891 g_browser_process->rappor_service(), metric_name, url); |
897 } | 892 } |
OLD | NEW |