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(); |
230 int render_process_id = | |
alexmos
2016/12/12 21:11:40
The else {} below is the only place left where it'
davidsac (gone - try alexmos)
2016/12/13 23:02:33
Done.
| |
231 web_contents->GetRenderViewHost()->GetProcess()->GetID(); | |
231 if (!web_contents) | 232 if (!web_contents) |
232 return; | 233 return; |
233 | 234 |
234 // Do not launch external requests attached to unswapped prerenders. | 235 // Do not launch external requests attached to unswapped prerenders. |
235 prerender::PrerenderContents* prerender_contents = | 236 prerender::PrerenderContents* prerender_contents = |
236 prerender::PrerenderContents::FromWebContents(web_contents); | 237 prerender::PrerenderContents::FromWebContents(web_contents); |
237 if (prerender_contents) { | 238 if (prerender_contents) { |
238 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); | 239 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); |
239 prerender::ReportPrerenderExternalURL(); | 240 prerender::ReportPrerenderExternalURL(); |
240 return; | 241 return; |
241 } | 242 } |
242 | 243 |
243 // If the URL is in whitelist, we launch it without asking the user and | 244 // 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, | 245 // without any additional security checks. Since the URL is whitelisted, |
245 // we assume it can be executed. | 246 // we assume it can be executed. |
246 // TODO(davidsac): External protocol handling needs to be | 247 // TODO(davidsac): External protocol handling needs to be |
247 // fixed for OOPIFs. See https://crbug.com/668289. | 248 // fixed for OOPIFs. See https://crbug.com/668289. |
248 if (is_whitelisted) { | 249 if (is_whitelisted) { |
249 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck( | 250 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url, web_contents); |
250 url, render_process_id, | |
251 web_contents->GetRenderViewHost()->GetRoutingID()); | |
252 } else { | 251 } else { |
253 ExternalProtocolHandler::LaunchUrlWithDelegate( | 252 ExternalProtocolHandler::LaunchUrlWithDelegate( |
254 url, render_process_id, | 253 url, render_process_id, |
255 web_contents->GetRenderViewHost()->GetRoutingID(), page_transition, | 254 web_contents->GetRenderViewHost()->GetRoutingID(), page_transition, |
256 has_user_gesture, g_external_protocol_handler_delegate); | 255 has_user_gesture, g_external_protocol_handler_delegate); |
257 } | 256 } |
258 } | 257 } |
259 | 258 |
260 #if !defined(DISABLE_NACL) | 259 #if !defined(DISABLE_NACL) |
261 void AppendComponentUpdaterThrottles( | 260 void AppendComponentUpdaterThrottles( |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 ProfileIOData::FromResourceContext(info->GetContext()); | 558 ProfileIOData::FromResourceContext(info->GetContext()); |
560 const policy::URLBlacklist::URLBlacklistState url_state = | 559 const policy::URLBlacklist::URLBlacklistState url_state = |
561 io_data->GetURLBlacklistState(url); | 560 io_data->GetURLBlacklistState(url); |
562 if (url_state == policy::URLBlacklist::URLBlacklistState::URL_IN_BLACKLIST) { | 561 if (url_state == policy::URLBlacklist::URLBlacklistState::URL_IN_BLACKLIST) { |
563 // It's a link with custom scheme and it's blacklisted. We return false here | 562 // It's a link with custom scheme and it's blacklisted. We return false here |
564 // and let it process as a normal URL. Eventually chrome_network_delegate | 563 // and let it process as a normal URL. Eventually chrome_network_delegate |
565 // will see it's in the blacklist and the user will be shown the blocked | 564 // will see it's in the blacklist and the user will be shown the blocked |
566 // content page. | 565 // content page. |
567 return false; | 566 return false; |
568 } | 567 } |
569 int child_id = info->GetChildID(); | 568 |
570 #if BUILDFLAG(ENABLE_EXTENSIONS) | 569 #if BUILDFLAG(ENABLE_EXTENSIONS) |
571 // External protocols are disabled for guests. An exception is made for the | 570 // External protocols are disabled for guests. An exception is made for the |
572 // "mailto" protocol, so that pages that utilize it work properly in a | 571 // "mailto" protocol, so that pages that utilize it work properly in a |
573 // WebView. | 572 // WebView. |
573 int child_id = info->GetChildID(); | |
574 ChromeNavigationUIData* navigation_data = | 574 ChromeNavigationUIData* navigation_data = |
575 static_cast<ChromeNavigationUIData*>(info->GetNavigationUIData()); | 575 static_cast<ChromeNavigationUIData*>(info->GetNavigationUIData()); |
576 if ((extensions::WebViewRendererState::GetInstance()->IsGuest(child_id) || | 576 if ((extensions::WebViewRendererState::GetInstance()->IsGuest(child_id) || |
577 (navigation_data && | 577 (navigation_data && |
578 navigation_data->GetExtensionNavigationUIData()->is_web_view())) && | 578 navigation_data->GetExtensionNavigationUIData()->is_web_view())) && |
579 !url.SchemeIs(url::kMailToScheme)) { | 579 !url.SchemeIs(url::kMailToScheme)) { |
580 return false; | 580 return false; |
581 } | 581 } |
582 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 582 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
583 | 583 |
584 #if defined(OS_ANDROID) | 584 #if defined(OS_ANDROID) |
585 // Main frame external protocols are handled by | 585 // Main frame external protocols are handled by |
586 // InterceptNavigationResourceThrottle. | 586 // InterceptNavigationResourceThrottle. |
587 if (info->IsMainFrame()) | 587 if (info->IsMainFrame()) |
588 return false; | 588 return false; |
589 #endif // defined(ANDROID) | 589 #endif // defined(ANDROID) |
590 | 590 |
591 const bool is_whitelisted = | 591 const bool is_whitelisted = |
592 url_state == policy::URLBlacklist::URLBlacklistState::URL_IN_WHITELIST; | 592 url_state == policy::URLBlacklist::URLBlacklistState::URL_IN_WHITELIST; |
593 BrowserThread::PostTask( | 593 BrowserThread::PostTask( |
594 BrowserThread::UI, FROM_HERE, | 594 BrowserThread::UI, FROM_HERE, |
595 base::Bind(&LaunchURL, url, child_id, | 595 base::Bind(&LaunchURL, url, info->GetWebContentsGetterForRequest(), |
596 info->GetWebContentsGetterForRequest(), | |
597 info->GetPageTransition(), info->HasUserGesture(), | 596 info->GetPageTransition(), info->HasUserGesture(), |
598 is_whitelisted)); | 597 is_whitelisted)); |
599 return true; | 598 return true; |
600 } | 599 } |
601 | 600 |
602 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( | 601 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( |
603 net::URLRequest* request, | 602 net::URLRequest* request, |
604 content::ResourceContext* resource_context, | 603 content::ResourceContext* resource_context, |
605 ResourceType resource_type, | 604 ResourceType resource_type, |
606 ScopedVector<content::ResourceThrottle>* throttles) { | 605 ScopedVector<content::ResourceThrottle>* throttles) { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 884 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
886 base::Unretained(this), url, request_loading_time)); | 885 base::Unretained(this), url, request_loading_time)); |
887 return; | 886 return; |
888 } | 887 } |
889 | 888 |
890 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 889 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
891 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 890 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
892 rappor::SampleDomainAndRegistryFromGURL( | 891 rappor::SampleDomainAndRegistryFromGURL( |
893 g_browser_process->rappor_service(), metric_name, url); | 892 g_browser_process->rappor_service(), metric_name, url); |
894 } | 893 } |
OLD | NEW |