OLD | NEW |
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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "content/public/browser/navigation_controller.h" | 29 #include "content/public/browser/navigation_controller.h" |
30 #include "content/public/browser/navigation_details.h" | 30 #include "content/public/browser/navigation_details.h" |
31 #include "content/public/browser/page_navigator.h" | 31 #include "content/public/browser/page_navigator.h" |
32 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
33 #include "content/public/browser/stream_handle.h" | 33 #include "content/public/browser/stream_handle.h" |
34 #include "content/public/browser/user_metrics.h" | 34 #include "content/public/browser/user_metrics.h" |
35 #include "content/public/common/bindings_policy.h" | 35 #include "content/public/common/bindings_policy.h" |
36 #include "content/public/common/content_client.h" | 36 #include "content/public/common/content_client.h" |
37 #include "content/public/common/content_switches.h" | 37 #include "content/public/common/content_switches.h" |
38 #include "content/public/common/resource_response.h" | 38 #include "content/public/common/resource_response.h" |
| 39 #include "content/public/common/site_isolation_policy.h" |
39 #include "content/public/common/url_constants.h" | 40 #include "content/public/common/url_constants.h" |
40 #include "content/public/common/url_utils.h" | 41 #include "content/public/common/url_utils.h" |
41 #include "net/base/net_errors.h" | 42 #include "net/base/net_errors.h" |
42 | 43 |
43 namespace content { | 44 namespace content { |
44 | 45 |
45 namespace { | 46 namespace { |
46 | 47 |
47 FrameMsg_Navigate_Type::Value GetNavigationType( | 48 FrameMsg_Navigate_Type::Value GetNavigationType( |
48 BrowserContext* browser_context, const NavigationEntryImpl& entry, | 49 BrowserContext* browser_context, const NavigationEntryImpl& entry, |
(...skipping 15 matching lines...) Expand all Loading... |
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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 return NavigateToEntry(frame_tree_node, frame_entry, | 345 return NavigateToEntry(frame_tree_node, frame_entry, |
346 *controller_->GetPendingEntry(), reload_type, | 346 *controller_->GetPendingEntry(), reload_type, |
347 is_same_document_history_load); | 347 is_same_document_history_load); |
348 } | 348 } |
349 | 349 |
350 void NavigatorImpl::DidNavigate( | 350 void NavigatorImpl::DidNavigate( |
351 RenderFrameHostImpl* render_frame_host, | 351 RenderFrameHostImpl* render_frame_host, |
352 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) { | 352 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) { |
353 FrameHostMsg_DidCommitProvisionalLoad_Params params(input_params); | 353 FrameHostMsg_DidCommitProvisionalLoad_Params params(input_params); |
354 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); | 354 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); |
355 bool use_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( | 355 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
356 switches::kSitePerProcess); | |
357 | 356 |
358 if (ui::PageTransitionIsMainFrame(params.transition)) { | 357 if (ui::PageTransitionIsMainFrame(params.transition)) { |
359 if (delegate_) { | 358 if (delegate_) { |
360 // When overscroll navigation gesture is enabled, a screenshot of the page | 359 // When overscroll navigation gesture is enabled, a screenshot of the page |
361 // in its current state is taken so that it can be used during the | 360 // in its current state is taken so that it can be used during the |
362 // nav-gesture. It is necessary to take the screenshot here, before | 361 // nav-gesture. It is necessary to take the screenshot here, before |
363 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can | 362 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can |
364 // change WebContents::GetRenderViewHost to return the new host, instead | 363 // change WebContents::GetRenderViewHost to return the new host, instead |
365 // of the one that may have just been swapped out. | 364 // of the one that may have just been swapped out. |
366 if (delegate_->CanOverscrollContent()) { | 365 if (delegate_->CanOverscrollContent()) { |
367 // Don't take screenshots if we are staying on the same page. We want | 366 // Don't take screenshots if we are staying on the same page. We want |
368 // in-page navigations to be super fast, and taking a screenshot | 367 // in-page navigations to be super fast, and taking a screenshot |
369 // currently blocks GPU for a longer time than we are willing to | 368 // currently blocks GPU for a longer time than we are willing to |
370 // tolerate in this use case. | 369 // tolerate in this use case. |
371 if (!params.was_within_same_page) | 370 if (!params.was_within_same_page) |
372 controller_->TakeScreenshot(); | 371 controller_->TakeScreenshot(); |
373 } | 372 } |
374 | 373 |
375 // Run tasks that must execute just before the commit. | 374 // Run tasks that must execute just before the commit. |
376 bool is_navigation_within_page = controller_->IsURLInPageNavigation( | 375 bool is_navigation_within_page = controller_->IsURLInPageNavigation( |
377 params.url, params.was_within_same_page, render_frame_host); | 376 params.url, params.was_within_same_page, render_frame_host); |
378 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page); | 377 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page); |
379 } | 378 } |
380 | 379 |
381 if (!use_site_per_process) | 380 if (!oopifs_possible) |
382 frame_tree->root()->render_manager()->DidNavigateFrame( | 381 frame_tree->root()->render_manager()->DidNavigateFrame( |
383 render_frame_host, params.gesture == NavigationGestureUser); | 382 render_frame_host, params.gesture == NavigationGestureUser); |
384 } | 383 } |
385 | 384 |
386 // Save the origin of the new page. Do this before calling | 385 // Save the origin of the new page. Do this before calling |
387 // DidNavigateFrame(), because the origin needs to be included in the SwapOut | 386 // DidNavigateFrame(), because the origin needs to be included in the SwapOut |
388 // message, which is sent inside DidNavigateFrame(). SwapOut needs the | 387 // message, which is sent inside DidNavigateFrame(). SwapOut needs the |
389 // origin because it creates a RenderFrameProxy that needs this to initialize | 388 // origin because it creates a RenderFrameProxy that needs this to initialize |
390 // its security context. This origin will also be sent to RenderFrameProxies | 389 // its security context. This origin will also be sent to RenderFrameProxies |
391 // created via ViewMsg_New and FrameMsg_NewFrameProxy. | 390 // created via ViewMsg_New and FrameMsg_NewFrameProxy. |
392 render_frame_host->frame_tree_node()->SetCurrentOrigin(params.origin); | 391 render_frame_host->frame_tree_node()->SetCurrentOrigin(params.origin); |
393 | 392 |
394 // When using --site-per-process, we notify the RFHM for all navigations, | 393 // When using --site-per-process, we notify the RFHM for all navigations, |
395 // not just main frame navigations. | 394 // not just main frame navigations. |
396 if (use_site_per_process) { | 395 if (oopifs_possible) { |
397 FrameTreeNode* frame = render_frame_host->frame_tree_node(); | 396 FrameTreeNode* frame = render_frame_host->frame_tree_node(); |
398 frame->render_manager()->DidNavigateFrame( | 397 frame->render_manager()->DidNavigateFrame( |
399 render_frame_host, params.gesture == NavigationGestureUser); | 398 render_frame_host, params.gesture == NavigationGestureUser); |
400 } | 399 } |
401 | 400 |
402 // Update the site of the SiteInstance if it doesn't have one yet, unless | 401 // Update the site of the SiteInstance if it doesn't have one yet, unless |
403 // assigning a site is not necessary for this URL. In that case, the | 402 // assigning a site is not necessary for this URL. In that case, the |
404 // SiteInstance can still be considered unused until a navigation to a real | 403 // SiteInstance can still be considered unused until a navigation to a real |
405 // page. | 404 // page. |
406 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); | 405 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 if (!GetContentClient()->browser()->ShouldAllowOpenURL( | 536 if (!GetContentClient()->browser()->ShouldAllowOpenURL( |
538 current_site_instance, url)) { | 537 current_site_instance, url)) { |
539 dest_url = GURL(url::kAboutBlankURL); | 538 dest_url = GURL(url::kAboutBlankURL); |
540 } | 539 } |
541 | 540 |
542 int frame_tree_node_id = -1; | 541 int frame_tree_node_id = -1; |
543 | 542 |
544 // Send the navigation to the current FrameTreeNode if it's destined for a | 543 // Send the navigation to the current FrameTreeNode if it's destined for a |
545 // subframe in the current tab. We'll assume it's for the main frame | 544 // subframe in the current tab. We'll assume it's for the main frame |
546 // (possibly of a new or different WebContents) otherwise. | 545 // (possibly of a new or different WebContents) otherwise. |
547 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 546 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && |
548 switches::kSitePerProcess) && | 547 disposition == CURRENT_TAB && render_frame_host->GetParent()) { |
549 disposition == CURRENT_TAB && | |
550 render_frame_host->GetParent()) { | |
551 frame_tree_node_id = | 548 frame_tree_node_id = |
552 render_frame_host->frame_tree_node()->frame_tree_node_id(); | 549 render_frame_host->frame_tree_node()->frame_tree_node_id(); |
553 } | 550 } |
554 | 551 |
555 OpenURLParams params( | 552 OpenURLParams params( |
556 dest_url, referrer, frame_tree_node_id, disposition, page_transition, | 553 dest_url, referrer, frame_tree_node_id, disposition, page_transition, |
557 true /* is_renderer_initiated */); | 554 true /* is_renderer_initiated */); |
558 params.source_site_instance = source_site_instance; | 555 params.source_site_instance = source_site_instance; |
559 if (redirect_chain.size() > 0) | 556 if (redirect_chain.size() > 0) |
560 params.redirect_chain = redirect_chain; | 557 params.redirect_chain = redirect_chain; |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | 901 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
905 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 902 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
906 } | 903 } |
907 controller_->SetPendingEntry(entry.Pass()); | 904 controller_->SetPendingEntry(entry.Pass()); |
908 if (delegate_) | 905 if (delegate_) |
909 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 906 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
910 } | 907 } |
911 } | 908 } |
912 | 909 |
913 } // namespace content | 910 } // namespace content |
OLD | NEW |