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

Side by Side Diff: content/browser/frame_host/navigator_impl.cc

Issue 1208143002: Move existing kSitePerProcess checks to a policy-oracle object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@swapped_out_cmdline_checks
Patch Set: Fix some includes Created 5 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/frame_host/navigator_impl.h" 5 #include "content/browser/frame_host/navigator_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "content/browser/frame_host/frame_tree.h" 10 #include "content/browser/frame_host/frame_tree.h"
11 #include "content/browser/frame_host/frame_tree_node.h" 11 #include "content/browser/frame_host/frame_tree_node.h"
12 #include "content/browser/frame_host/navigation_controller_impl.h" 12 #include "content/browser/frame_host/navigation_controller_impl.h"
13 #include "content/browser/frame_host/navigation_entry_impl.h" 13 #include "content/browser/frame_host/navigation_entry_impl.h"
14 #include "content/browser/frame_host/navigation_request.h" 14 #include "content/browser/frame_host/navigation_request.h"
15 #include "content/browser/frame_host/navigation_request_info.h" 15 #include "content/browser/frame_host/navigation_request_info.h"
16 #include "content/browser/frame_host/navigator_delegate.h" 16 #include "content/browser/frame_host/navigator_delegate.h"
17 #include "content/browser/frame_host/render_frame_host_impl.h" 17 #include "content/browser/frame_host/render_frame_host_impl.h"
18 #include "content/browser/renderer_host/render_view_host_impl.h" 18 #include "content/browser/renderer_host/render_view_host_impl.h"
19 #include "content/browser/site_instance_impl.h" 19 #include "content/browser/site_instance_impl.h"
20 #include "content/browser/webui/web_ui_controller_factory_registry.h" 20 #include "content/browser/webui/web_ui_controller_factory_registry.h"
21 #include "content/browser/webui/web_ui_impl.h" 21 #include "content/browser/webui/web_ui_impl.h"
22 #include "content/common/frame_messages.h" 22 #include "content/common/frame_messages.h"
23 #include "content/common/navigation_params.h" 23 #include "content/common/navigation_params.h"
24 #include "content/common/site_isolation_policy.h"
24 #include "content/common/view_messages.h" 25 #include "content/common/view_messages.h"
25 #include "content/public/browser/browser_context.h" 26 #include "content/public/browser/browser_context.h"
26 #include "content/public/browser/content_browser_client.h" 27 #include "content/public/browser/content_browser_client.h"
27 #include "content/public/browser/global_request_id.h" 28 #include "content/public/browser/global_request_id.h"
28 #include "content/public/browser/invalidate_type.h" 29 #include "content/public/browser/invalidate_type.h"
29 #include "content/public/browser/navigation_controller.h" 30 #include "content/public/browser/navigation_controller.h"
30 #include "content/public/browser/navigation_details.h" 31 #include "content/public/browser/navigation_details.h"
31 #include "content/public/browser/page_navigator.h" 32 #include "content/public/browser/page_navigator.h"
32 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
33 #include "content/public/browser/stream_handle.h" 34 #include "content/public/browser/stream_handle.h"
(...skipping 30 matching lines...) Expand all
64 NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY) { 65 NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY) {
65 if (entry.GetHasPostData()) 66 if (entry.GetHasPostData())
66 return FrameMsg_Navigate_Type::RESTORE_WITH_POST; 67 return FrameMsg_Navigate_Type::RESTORE_WITH_POST;
67 return FrameMsg_Navigate_Type::RESTORE; 68 return FrameMsg_Navigate_Type::RESTORE;
68 } 69 }
69 70
70 return FrameMsg_Navigate_Type::NORMAL; 71 return FrameMsg_Navigate_Type::NORMAL;
71 } 72 }
72 73
73 RenderFrameHostManager* GetRenderManager(RenderFrameHostImpl* rfh) { 74 RenderFrameHostManager* GetRenderManager(RenderFrameHostImpl* rfh) {
74 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 75 if (SiteIsolationPolicy::AreCrossProcessFramesPossible())
75 switches::kSitePerProcess))
76 return rfh->frame_tree_node()->render_manager(); 76 return rfh->frame_tree_node()->render_manager();
77 77
78 return rfh->frame_tree_node()->frame_tree()->root()->render_manager(); 78 return rfh->frame_tree_node()->frame_tree()->root()->render_manager();
79 } 79 }
80 80
81 } // namespace 81 } // namespace
82 82
83 struct NavigatorImpl::NavigationMetricsData { 83 struct NavigatorImpl::NavigationMetricsData {
84 NavigationMetricsData(base::TimeTicks start_time, 84 NavigationMetricsData(base::TimeTicks start_time,
85 GURL url, 85 GURL url,
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 return NavigateToEntry(frame_tree_node, frame_entry, 357 return NavigateToEntry(frame_tree_node, frame_entry,
358 *controller_->GetPendingEntry(), reload_type, 358 *controller_->GetPendingEntry(), reload_type,
359 is_same_document_history_load); 359 is_same_document_history_load);
360 } 360 }
361 361
362 void NavigatorImpl::DidNavigate( 362 void NavigatorImpl::DidNavigate(
363 RenderFrameHostImpl* render_frame_host, 363 RenderFrameHostImpl* render_frame_host,
364 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) { 364 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) {
365 FrameHostMsg_DidCommitProvisionalLoad_Params params(input_params); 365 FrameHostMsg_DidCommitProvisionalLoad_Params params(input_params);
366 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); 366 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree();
367 bool use_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( 367 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible();
368 switches::kSitePerProcess);
369 368
370 if (ui::PageTransitionIsMainFrame(params.transition)) { 369 if (ui::PageTransitionIsMainFrame(params.transition)) {
371 if (delegate_) { 370 if (delegate_) {
372 // When overscroll navigation gesture is enabled, a screenshot of the page 371 // When overscroll navigation gesture is enabled, a screenshot of the page
373 // in its current state is taken so that it can be used during the 372 // in its current state is taken so that it can be used during the
374 // nav-gesture. It is necessary to take the screenshot here, before 373 // nav-gesture. It is necessary to take the screenshot here, before
375 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can 374 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can
376 // change WebContents::GetRenderViewHost to return the new host, instead 375 // change WebContents::GetRenderViewHost to return the new host, instead
377 // of the one that may have just been swapped out. 376 // of the one that may have just been swapped out.
378 if (delegate_->CanOverscrollContent()) { 377 if (delegate_->CanOverscrollContent()) {
379 // Don't take screenshots if we are staying on the same page. We want 378 // Don't take screenshots if we are staying on the same page. We want
380 // in-page navigations to be super fast, and taking a screenshot 379 // in-page navigations to be super fast, and taking a screenshot
381 // currently blocks GPU for a longer time than we are willing to 380 // currently blocks GPU for a longer time than we are willing to
382 // tolerate in this use case. 381 // tolerate in this use case.
383 if (!params.was_within_same_page) 382 if (!params.was_within_same_page)
384 controller_->TakeScreenshot(); 383 controller_->TakeScreenshot();
385 } 384 }
386 385
387 // Run tasks that must execute just before the commit. 386 // Run tasks that must execute just before the commit.
388 bool is_navigation_within_page = controller_->IsURLInPageNavigation( 387 bool is_navigation_within_page = controller_->IsURLInPageNavigation(
389 params.url, params.was_within_same_page, render_frame_host); 388 params.url, params.was_within_same_page, render_frame_host);
390 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page); 389 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page);
391 } 390 }
392 391
393 if (!use_site_per_process) 392 if (!oopifs_possible)
394 frame_tree->root()->render_manager()->DidNavigateFrame( 393 frame_tree->root()->render_manager()->DidNavigateFrame(
395 render_frame_host, params.gesture == NavigationGestureUser); 394 render_frame_host, params.gesture == NavigationGestureUser);
396 } 395 }
397 396
398 // Save the origin of the new page. Do this before calling 397 // Save the origin of the new page. Do this before calling
399 // DidNavigateFrame(), because the origin needs to be included in the SwapOut 398 // DidNavigateFrame(), because the origin needs to be included in the SwapOut
400 // message, which is sent inside DidNavigateFrame(). SwapOut needs the 399 // message, which is sent inside DidNavigateFrame(). SwapOut needs the
401 // origin because it creates a RenderFrameProxy that needs this to initialize 400 // origin because it creates a RenderFrameProxy that needs this to initialize
402 // its security context. This origin will also be sent to RenderFrameProxies 401 // its security context. This origin will also be sent to RenderFrameProxies
403 // created via ViewMsg_New and FrameMsg_NewFrameProxy. 402 // created via ViewMsg_New and FrameMsg_NewFrameProxy.
404 render_frame_host->frame_tree_node()->SetCurrentOrigin(params.origin); 403 render_frame_host->frame_tree_node()->SetCurrentOrigin(params.origin);
405 404
406 // When using --site-per-process, we notify the RFHM for all navigations, 405 // When using --site-per-process, we notify the RFHM for all navigations,
407 // not just main frame navigations. 406 // not just main frame navigations.
408 if (use_site_per_process) { 407 if (oopifs_possible) {
409 FrameTreeNode* frame = render_frame_host->frame_tree_node(); 408 FrameTreeNode* frame = render_frame_host->frame_tree_node();
410 frame->render_manager()->DidNavigateFrame( 409 frame->render_manager()->DidNavigateFrame(
411 render_frame_host, params.gesture == NavigationGestureUser); 410 render_frame_host, params.gesture == NavigationGestureUser);
412 } 411 }
413 412
414 // Update the site of the SiteInstance if it doesn't have one yet, unless 413 // Update the site of the SiteInstance if it doesn't have one yet, unless
415 // assigning a site is not necessary for this URL. In that case, the 414 // assigning a site is not necessary for this URL. In that case, the
416 // SiteInstance can still be considered unused until a navigation to a real 415 // SiteInstance can still be considered unused until a navigation to a real
417 // page. 416 // page.
418 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); 417 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 if (!GetContentClient()->browser()->ShouldAllowOpenURL( 548 if (!GetContentClient()->browser()->ShouldAllowOpenURL(
550 current_site_instance, url)) { 549 current_site_instance, url)) {
551 dest_url = GURL(url::kAboutBlankURL); 550 dest_url = GURL(url::kAboutBlankURL);
552 } 551 }
553 552
554 int frame_tree_node_id = -1; 553 int frame_tree_node_id = -1;
555 554
556 // Send the navigation to the current FrameTreeNode if it's destined for a 555 // Send the navigation to the current FrameTreeNode if it's destined for a
557 // subframe in the current tab. We'll assume it's for the main frame 556 // subframe in the current tab. We'll assume it's for the main frame
558 // (possibly of a new or different WebContents) otherwise. 557 // (possibly of a new or different WebContents) otherwise.
559 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 558 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() &&
560 switches::kSitePerProcess) && 559 disposition == CURRENT_TAB && render_frame_host->GetParent()) {
561 disposition == CURRENT_TAB &&
562 render_frame_host->GetParent()) {
563 frame_tree_node_id = 560 frame_tree_node_id =
564 render_frame_host->frame_tree_node()->frame_tree_node_id(); 561 render_frame_host->frame_tree_node()->frame_tree_node_id();
565 } 562 }
566 563
567 OpenURLParams params( 564 OpenURLParams params(
568 dest_url, referrer, frame_tree_node_id, disposition, page_transition, 565 dest_url, referrer, frame_tree_node_id, disposition, page_transition,
569 true /* is_renderer_initiated */); 566 true /* is_renderer_initiated */);
570 params.source_site_instance = source_site_instance; 567 params.source_site_instance = source_site_instance;
571 if (redirect_chain.size() > 0) 568 if (redirect_chain.size() > 0)
572 params.redirect_chain = redirect_chain; 569 params.redirect_chain = redirect_chain;
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 entry->set_should_replace_entry(pending_entry->should_replace_entry()); 916 entry->set_should_replace_entry(pending_entry->should_replace_entry());
920 entry->SetRedirectChain(pending_entry->GetRedirectChain()); 917 entry->SetRedirectChain(pending_entry->GetRedirectChain());
921 } 918 }
922 controller_->SetPendingEntry(entry.Pass()); 919 controller_->SetPendingEntry(entry.Pass());
923 if (delegate_) 920 if (delegate_)
924 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 921 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
925 } 922 }
926 } 923 }
927 924
928 } // namespace content 925 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698