Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc

Issue 2538353002: fix external protocol handling for OOPIFs (Closed)
Patch Set: add bug reference for TODO Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(),
mmenke 2016/12/15 20:54:54 How can we be sure the process associated with the
Charlie Reis 2016/12/15 21:55:06 Good point. Maybe we should be passing both the p
davidsac (gone - try alexmos) 2016/12/15 22:40:23 Yes, we could keep passing the process_id to Launc
mmenke 2016/12/16 16:24:17 Why do we need the process ID for either of those
alexmos 2016/12/16 21:11:38 The process ID and routing ID are just used to get
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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 ProfileIOData::FromResourceContext(info->GetContext()); 554 ProfileIOData::FromResourceContext(info->GetContext());
560 const policy::URLBlacklist::URLBlacklistState url_state = 555 const policy::URLBlacklist::URLBlacklistState url_state =
561 io_data->GetURLBlacklistState(url); 556 io_data->GetURLBlacklistState(url);
562 if (url_state == policy::URLBlacklist::URLBlacklistState::URL_IN_BLACKLIST) { 557 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 558 // 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 559 // 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 560 // will see it's in the blacklist and the user will be shown the blocked
566 // content page. 561 // content page.
567 return false; 562 return false;
568 } 563 }
569 int child_id = info->GetChildID(); 564
570 #if BUILDFLAG(ENABLE_EXTENSIONS) 565 #if BUILDFLAG(ENABLE_EXTENSIONS)
571 // External protocols are disabled for guests. An exception is made for the 566 // 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 567 // "mailto" protocol, so that pages that utilize it work properly in a
573 // WebView. 568 // WebView.
569 int child_id = info->GetChildID();
574 ChromeNavigationUIData* navigation_data = 570 ChromeNavigationUIData* navigation_data =
575 static_cast<ChromeNavigationUIData*>(info->GetNavigationUIData()); 571 static_cast<ChromeNavigationUIData*>(info->GetNavigationUIData());
576 if ((extensions::WebViewRendererState::GetInstance()->IsGuest(child_id) || 572 if ((extensions::WebViewRendererState::GetInstance()->IsGuest(child_id) ||
577 (navigation_data && 573 (navigation_data &&
578 navigation_data->GetExtensionNavigationUIData()->is_web_view())) && 574 navigation_data->GetExtensionNavigationUIData()->is_web_view())) &&
579 !url.SchemeIs(url::kMailToScheme)) { 575 !url.SchemeIs(url::kMailToScheme)) {
580 return false; 576 return false;
581 } 577 }
582 #endif // BUILDFLAG(ENABLE_EXTENSIONS) 578 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
583 579
584 #if defined(OS_ANDROID) 580 #if defined(OS_ANDROID)
585 // Main frame external protocols are handled by 581 // Main frame external protocols are handled by
586 // InterceptNavigationResourceThrottle. 582 // InterceptNavigationResourceThrottle.
587 if (info->IsMainFrame()) 583 if (info->IsMainFrame())
588 return false; 584 return false;
589 #endif // defined(ANDROID) 585 #endif // defined(ANDROID)
590 586
591 const bool is_whitelisted = 587 const bool is_whitelisted =
592 url_state == policy::URLBlacklist::URLBlacklistState::URL_IN_WHITELIST; 588 url_state == policy::URLBlacklist::URLBlacklistState::URL_IN_WHITELIST;
593 BrowserThread::PostTask( 589 BrowserThread::PostTask(
594 BrowserThread::UI, FROM_HERE, 590 BrowserThread::UI, FROM_HERE,
595 base::Bind(&LaunchURL, url, child_id, 591 base::Bind(&LaunchURL, url, info->GetWebContentsGetterForRequest(),
596 info->GetWebContentsGetterForRequest(),
597 info->GetPageTransition(), info->HasUserGesture(), 592 info->GetPageTransition(), info->HasUserGesture(),
598 is_whitelisted)); 593 is_whitelisted));
599 return true; 594 return true;
600 } 595 }
601 596
602 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( 597 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles(
603 net::URLRequest* request, 598 net::URLRequest* request,
604 content::ResourceContext* resource_context, 599 content::ResourceContext* resource_context,
605 ResourceType resource_type, 600 ResourceType resource_type,
606 ScopedVector<content::ResourceThrottle>* throttles) { 601 ScopedVector<content::ResourceThrottle>* throttles) {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 880 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
886 base::Unretained(this), url, request_loading_time)); 881 base::Unretained(this), url, request_loading_time));
887 return; 882 return;
888 } 883 }
889 884
890 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 885 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
891 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 886 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
892 rappor::SampleDomainAndRegistryFromGURL( 887 rappor::SampleDomainAndRegistryFromGURL(
893 g_browser_process->rappor_service(), metric_name, url); 888 g_browser_process->rappor_service(), metric_name, url);
894 } 889 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698