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

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

Issue 2538353002: fix external protocol handling for OOPIFs (Closed)
Patch Set: rebase 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 StreamsPrivateAPI* streams_private = StreamsPrivateAPI::Get(profile); 211 StreamsPrivateAPI* streams_private = StreamsPrivateAPI::Get(profile);
212 if (!streams_private) 212 if (!streams_private)
213 return; 213 return;
214 streams_private->ExecuteMimeTypeHandler( 214 streams_private->ExecuteMimeTypeHandler(
215 extension_id, std::move(stream), view_id, expected_content_size, embedded, 215 extension_id, std::move(stream), view_id, expected_content_size, embedded,
216 frame_tree_node_id, render_process_id, render_frame_id); 216 frame_tree_node_id, render_process_id, render_frame_id);
217 } 217 }
218 #endif // !BUILDFLAG(ENABLE_EXTENSIONS) 218 #endif // !BUILDFLAG(ENABLE_EXTENSIONS)
219 219
220 // TODO(davidsac): get rid of useless_render_process_id parameter???
alexmos 2016/12/01 19:21:14 Yes, let's remove this argument.
davidsac (gone - try alexmos) 2016/12/12 19:15:47 Done.
221 // TODO(davidsac): replace occurences of tab_contents_id with
alexmos 2016/12/01 19:21:14 This comment is for a function that doesn't actual
davidsac (gone - try alexmos) 2016/12/12 19:15:47 Done.
222 // render_view_routing_id
220 void LaunchURL( 223 void LaunchURL(
221 const GURL& url, 224 const GURL& url,
222 int render_process_id, 225 int useless_render_process_id,
223 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, 226 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
224 ui::PageTransition page_transition, 227 ui::PageTransition page_transition,
225 bool has_user_gesture, 228 bool has_user_gesture,
226 bool is_whitelisted) { 229 bool is_whitelisted) {
227 // If there is no longer a WebContents, the request may have raced with tab 230 // If there is no longer a WebContents, the request may have raced with tab
228 // closing. Don't fire the external request. (It may have been a prerender.) 231 // closing. Don't fire the external request. (It may have been a prerender.)
229 content::WebContents* web_contents = web_contents_getter.Run(); 232 content::WebContents* web_contents = web_contents_getter.Run();
233
234 int render_process_id =
235 web_contents->GetRenderViewHost()->GetProcess()->GetID();
230 if (!web_contents) 236 if (!web_contents)
231 return; 237 return;
232 238
233 // Do not launch external requests attached to unswapped prerenders. 239 // Do not launch external requests attached to unswapped prerenders.
234 prerender::PrerenderContents* prerender_contents = 240 prerender::PrerenderContents* prerender_contents =
235 prerender::PrerenderContents::FromWebContents(web_contents); 241 prerender::PrerenderContents::FromWebContents(web_contents);
236 if (prerender_contents) { 242 if (prerender_contents) {
237 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); 243 prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME);
238 prerender::ReportPrerenderExternalURL(); 244 prerender::ReportPrerenderExternalURL();
239 return; 245 return;
240 } 246 }
241 247
242 // If the URL is in whitelist, we launch it without asking the user and 248 // If the URL is in whitelist, we launch it without asking the user and
243 // without any additional security checks. Since the URL is whitelisted, 249 // without any additional security checks. Since the URL is whitelisted,
244 // we assume it can be executed. 250 // we assume it can be executed.
245 // TODO(davidsac): External protocol handling needs to be 251 // TODO(davidsac): External protocol handling needs to be
246 // fixed for OOPIFs. See https://crbug.com/668289. 252 // fixed for OOPIFs. See https://crbug.com/668289.
247 if (is_whitelisted) { 253 if (is_whitelisted) {
248 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck( 254 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url, web_contents);
249 url, render_process_id,
250 web_contents->GetRenderViewHost()->GetRoutingID());
251 } else { 255 } else {
252 ExternalProtocolHandler::LaunchUrlWithDelegate( 256 ExternalProtocolHandler::LaunchUrlWithDelegate(
253 url, render_process_id, 257 url, render_process_id,
254 web_contents->GetRenderViewHost()->GetRoutingID(), page_transition, 258 web_contents->GetRenderViewHost()->GetRoutingID(), page_transition,
255 has_user_gesture, g_external_protocol_handler_delegate); 259 has_user_gesture, g_external_protocol_handler_delegate);
256 } 260 }
257 } 261 }
258 262
259 #if !defined(DISABLE_NACL) 263 #if !defined(DISABLE_NACL)
260 void AppendComponentUpdaterThrottles( 264 void AppendComponentUpdaterThrottles(
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 887 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
884 base::Unretained(this), url, request_loading_time)); 888 base::Unretained(this), url, request_loading_time));
885 return; 889 return;
886 } 890 }
887 891
888 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 892 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
889 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 893 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
890 rappor::SampleDomainAndRegistryFromGURL( 894 rappor::SampleDomainAndRegistryFromGURL(
891 g_browser_process->rappor_service(), metric_name, url); 895 g_browser_process->rappor_service(), metric_name, url);
892 } 896 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698