| 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 "content/browser/frame_host/frame_tree.h" | 8 #include "content/browser/frame_host/frame_tree.h" |
| 9 #include "content/browser/frame_host/frame_tree_node.h" | 9 #include "content/browser/frame_host/frame_tree_node.h" |
| 10 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 } | 376 } |
| 377 | 377 |
| 378 void NavigatorImpl::DidNavigate( | 378 void NavigatorImpl::DidNavigate( |
| 379 RenderFrameHostImpl* render_frame_host, | 379 RenderFrameHostImpl* render_frame_host, |
| 380 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) { | 380 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) { |
| 381 FrameHostMsg_DidCommitProvisionalLoad_Params params(input_params); | 381 FrameHostMsg_DidCommitProvisionalLoad_Params params(input_params); |
| 382 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); | 382 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); |
| 383 RenderViewHostImpl* rvh = render_frame_host->render_view_host(); | 383 RenderViewHostImpl* rvh = render_frame_host->render_view_host(); |
| 384 bool use_site_per_process = | 384 bool use_site_per_process = |
| 385 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess); | 385 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess); |
| 386 if (frame_tree->IsFirstNavigationAfterSwap()) { | |
| 387 // First navigation should be a main frame navigation. | |
| 388 // TODO(creis): This DCHECK is currently disabled for --site-per-process | |
| 389 // because cross-process subframe navigations still have a main frame | |
| 390 // PageTransition. | |
| 391 if (!use_site_per_process) | |
| 392 DCHECK(PageTransitionIsMainFrame(params.transition)); | |
| 393 frame_tree->OnFirstNavigationAfterSwap(params.frame_id); | |
| 394 } | |
| 395 | 386 |
| 396 // When using --site-per-process, look up the FrameTreeNode ID that the | 387 // When using --site-per-process, look up the FrameTreeNode ID that the |
| 397 // renderer-specific frame ID corresponds to. | 388 // renderer-specific frame ID corresponds to. |
| 398 int64 frame_tree_node_id = frame_tree->root()->frame_tree_node_id(); | 389 int64 frame_tree_node_id = frame_tree->root()->frame_tree_node_id(); |
| 399 if (use_site_per_process) { | 390 if (use_site_per_process) { |
| 400 frame_tree_node_id = | 391 frame_tree_node_id = |
| 401 render_frame_host->frame_tree_node()->frame_tree_node_id(); | 392 render_frame_host->frame_tree_node()->frame_tree_node_id(); |
| 402 | 393 |
| 403 // TODO(creis): In the short term, cross-process subframe navigations are | 394 // TODO(creis): In the short term, cross-process subframe navigations are |
| 404 // happening in the pending RenderViewHost's top-level frame. (We need to | 395 // happening in the pending RenderViewHost's top-level frame. (We need to |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 // PageTransitionIsMainFrame code block above. | 458 // PageTransitionIsMainFrame code block above. |
| 468 if (PageTransitionIsMainFrame(params.transition) && delegate_) | 459 if (PageTransitionIsMainFrame(params.transition) && delegate_) |
| 469 delegate_->SetMainFrameMimeType(params.contents_mime_type); | 460 delegate_->SetMainFrameMimeType(params.contents_mime_type); |
| 470 | 461 |
| 471 LoadCommittedDetails details; | 462 LoadCommittedDetails details; |
| 472 bool did_navigate = controller_->RendererDidNavigate(rvh, params, &details); | 463 bool did_navigate = controller_->RendererDidNavigate(rvh, params, &details); |
| 473 | 464 |
| 474 // For now, keep track of each frame's URL in its FrameTreeNode. This lets | 465 // For now, keep track of each frame's URL in its FrameTreeNode. This lets |
| 475 // us estimate our process count for implementing OOP iframes. | 466 // us estimate our process count for implementing OOP iframes. |
| 476 // TODO(creis): Remove this when we track which pages commit in each frame. | 467 // TODO(creis): Remove this when we track which pages commit in each frame. |
| 477 frame_tree->SetFrameUrl(params.frame_id, params.url); | 468 FrameTreeNode* node = |
| 469 frame_tree->FindByRoutingID(params.frame_id, |
| 470 render_frame_host->GetProcess()->GetID()); |
| 471 if (node) |
| 472 node->set_current_url(params.url); |
| 478 | 473 |
| 479 // Send notification about committed provisional loads. This notification is | 474 // Send notification about committed provisional loads. This notification is |
| 480 // different from the NAV_ENTRY_COMMITTED notification which doesn't include | 475 // different from the NAV_ENTRY_COMMITTED notification which doesn't include |
| 481 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. | 476 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. |
| 482 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) { | 477 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) { |
| 483 // For AUTO_SUBFRAME navigations, an event for the main frame is generated | 478 // For AUTO_SUBFRAME navigations, an event for the main frame is generated |
| 484 // that is not recorded in the navigation history. For the purpose of | 479 // that is not recorded in the navigation history. For the purpose of |
| 485 // tracking navigation events, we treat this event as a sub frame navigation | 480 // tracking navigation events, we treat this event as a sub frame navigation |
| 486 // event. | 481 // event. |
| 487 bool is_main_frame = did_navigate ? details.is_main_frame : false; | 482 bool is_main_frame = did_navigate ? details.is_main_frame : false; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 // still be used for a normal web site. | 522 // still be used for a normal web site. |
| 528 if (url == GURL(kAboutBlankURL)) | 523 if (url == GURL(kAboutBlankURL)) |
| 529 return false; | 524 return false; |
| 530 | 525 |
| 531 // The embedder will then have the opportunity to determine if the URL | 526 // The embedder will then have the opportunity to determine if the URL |
| 532 // should "use up" the SiteInstance. | 527 // should "use up" the SiteInstance. |
| 533 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); | 528 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); |
| 534 } | 529 } |
| 535 | 530 |
| 536 } // namespace content | 531 } // namespace content |
| OLD | NEW |