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

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

Issue 1692503002: Functionality to allow blacklist and whitelist of custom schemes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unused comments Created 4 years, 9 months 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/renderer_host/chrome_resource_dispatcher_host_delegate. h" 5 #include "chrome/browser/renderer_host/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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 extension_id, web_contents, std::move(stream), view_id, 214 extension_id, web_contents, std::move(stream), view_id,
215 expected_content_size, embedded, render_process_id, render_frame_id); 215 expected_content_size, embedded, render_process_id, render_frame_id);
216 } 216 }
217 #endif // !defined(ENABLE_EXTENSIONS) 217 #endif // !defined(ENABLE_EXTENSIONS)
218 218
219 void LaunchURL( 219 void LaunchURL(
220 const GURL& url, 220 const GURL& url,
221 int render_process_id, 221 int render_process_id,
222 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, 222 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
223 ui::PageTransition page_transition, 223 ui::PageTransition page_transition,
224 bool has_user_gesture) { 224 bool has_user_gesture,
225 bool is_whitelisted) {
225 // If there is no longer a WebContents, the request may have raced with tab 226 // If there is no longer a WebContents, the request may have raced with tab
226 // closing. Don't fire the external request. (It may have been a prerender.) 227 // closing. Don't fire the external request. (It may have been a prerender.)
227 content::WebContents* web_contents = web_contents_getter.Run(); 228 content::WebContents* web_contents = web_contents_getter.Run();
228 if (!web_contents) 229 if (!web_contents)
229 return; 230 return;
230 231
231 // Do not launch external requests attached to unswapped prerenders. 232 // Do not launch external requests attached to unswapped prerenders.
232 prerender::PrerenderContents* prerender_contents = 233 prerender::PrerenderContents* prerender_contents =
233 prerender::PrerenderContents::FromWebContents(web_contents); 234 prerender::PrerenderContents::FromWebContents(web_contents);
234 if (prerender_contents) { 235 if (prerender_contents) {
235 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); 236 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME);
236 prerender::ReportPrerenderExternalURL(); 237 prerender::ReportPrerenderExternalURL();
237 return; 238 return;
238 } 239 }
239 240
240 ExternalProtocolHandler::LaunchUrlWithDelegate( 241 if (is_whitelisted) {
Thiemo Nagel 2016/03/08 18:44:34 Please explain what is happening here and why!
241 url, render_process_id, web_contents->GetRoutingID(), page_transition, 242 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(
242 has_user_gesture, g_external_protocol_handler_delegate); 243 url, render_process_id, web_contents->GetRoutingID());
244 } else {
245 ExternalProtocolHandler::LaunchUrlWithDelegate(
246 url, render_process_id, web_contents->GetRoutingID(), page_transition,
247 has_user_gesture, g_external_protocol_handler_delegate);
248 }
243 } 249 }
244 250
245 #if !defined(DISABLE_NACL) 251 #if !defined(DISABLE_NACL)
246 void AppendComponentUpdaterThrottles( 252 void AppendComponentUpdaterThrottles(
247 net::URLRequest* request, 253 net::URLRequest* request,
248 content::ResourceContext* resource_context, 254 content::ResourceContext* resource_context,
249 ResourceType resource_type, 255 ResourceType resource_type,
250 ScopedVector<content::ResourceThrottle>* throttles) { 256 ScopedVector<content::ResourceThrottle>* throttles) {
251 const char* crx_id = NULL; 257 const char* crx_id = NULL;
252 component_updater::ComponentUpdateService* cus = 258 component_updater::ComponentUpdateService* cus =
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 net::AuthChallengeInfo* auth_info, net::URLRequest* request) { 450 net::AuthChallengeInfo* auth_info, net::URLRequest* request) {
445 return CreateLoginPrompt(auth_info, request); 451 return CreateLoginPrompt(auth_info, request);
446 } 452 }
447 453
448 bool ChromeResourceDispatcherHostDelegate::HandleExternalProtocol( 454 bool ChromeResourceDispatcherHostDelegate::HandleExternalProtocol(
449 const GURL& url, 455 const GURL& url,
450 int child_id, 456 int child_id,
451 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, 457 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
452 bool is_main_frame, 458 bool is_main_frame,
453 ui::PageTransition page_transition, 459 ui::PageTransition page_transition,
454 bool has_user_gesture) { 460 bool has_user_gesture,
461 bool is_whitelisted) {
455 #if defined(ENABLE_EXTENSIONS) 462 #if defined(ENABLE_EXTENSIONS)
456 // External protocols are disabled for guests. An exception is made for the 463 // External protocols are disabled for guests. An exception is made for the
457 // "mailto" protocol, so that pages that utilize it work properly in a 464 // "mailto" protocol, so that pages that utilize it work properly in a
458 // WebView. 465 // WebView.
459 if (extensions::WebViewRendererState::GetInstance()->IsGuest(child_id) && 466 if (extensions::WebViewRendererState::GetInstance()->IsGuest(child_id) &&
460 !url.SchemeIs(url::kMailToScheme)) { 467 !url.SchemeIs(url::kMailToScheme)) {
461 return false; 468 return false;
462 } 469 }
463 #endif // defined(ENABLE_EXTENSIONS) 470 #endif // defined(ENABLE_EXTENSIONS)
464 471
465 #if defined(OS_ANDROID) 472 #if defined(OS_ANDROID)
466 // Main frame external protocols are handled by 473 // Main frame external protocols are handled by
467 // InterceptNavigationResourceThrottle. 474 // InterceptNavigationResourceThrottle.
468 if (is_main_frame) 475 if (is_main_frame)
469 return false; 476 return false;
470 #endif // defined(ANDROID) 477 #endif // defined(ANDROID)
471 478
472 BrowserThread::PostTask( 479 BrowserThread::PostTask(
473 BrowserThread::UI, FROM_HERE, 480 BrowserThread::UI, FROM_HERE,
474 base::Bind(&LaunchURL, url, child_id, web_contents_getter, 481 base::Bind(&LaunchURL, url, child_id, web_contents_getter,
475 page_transition, has_user_gesture)); 482 page_transition, has_user_gesture, is_whitelisted));
476 return true; 483 return true;
477 } 484 }
478 485
479 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles( 486 void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles(
480 net::URLRequest* request, 487 net::URLRequest* request,
481 content::ResourceContext* resource_context, 488 content::ResourceContext* resource_context,
482 ResourceType resource_type, 489 ResourceType resource_type,
483 ScopedVector<content::ResourceThrottle>* throttles) { 490 ScopedVector<content::ResourceThrottle>* throttles) {
484 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 491 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
485 492
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); 743 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request);
737 return false; 744 return false;
738 } 745 }
739 746
740 // static 747 // static
741 void ChromeResourceDispatcherHostDelegate:: 748 void ChromeResourceDispatcherHostDelegate::
742 SetExternalProtocolHandlerDelegateForTesting( 749 SetExternalProtocolHandlerDelegateForTesting(
743 ExternalProtocolHandler::Delegate* delegate) { 750 ExternalProtocolHandler::Delegate* delegate) {
744 g_external_protocol_handler_delegate = delegate; 751 g_external_protocol_handler_delegate = delegate;
745 } 752 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698