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

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

Issue 1309323004: Create a NavigationEntry for the initial blank page. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GetEntryCount, more tests Created 5 years, 2 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"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // We can skip this step in the rare case that this is a transfer navigation 324 // We can skip this step in the rare case that this is a transfer navigation
325 // which began in the chosen RenderFrameHost, since the request has already 325 // which began in the chosen RenderFrameHost, since the request has already
326 // been issued. In that case, simply resume the response. 326 // been issued. In that case, simply resume the response.
327 bool is_transfer_to_same = 327 bool is_transfer_to_same =
328 entry.transferred_global_request_id().child_id != -1 && 328 entry.transferred_global_request_id().child_id != -1 &&
329 entry.transferred_global_request_id().child_id == 329 entry.transferred_global_request_id().child_id ==
330 dest_render_frame_host->GetProcess()->GetID(); 330 dest_render_frame_host->GetProcess()->GetID();
331 if (!is_transfer_to_same) { 331 if (!is_transfer_to_same) {
332 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, 332 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url,
333 entry.restore_type())); 333 entry.restore_type()));
334
335 // The renderer expects the history length to be 0 for the initial page.
336 int history_offset = controller_->IsInitialNavigation() ? -1 :
337 controller_->GetLastCommittedEntryIndex();
338 int history_length = controller_->IsInitialNavigation() ? 0 :
339 controller_->GetEntryCount();
340
334 // Create the navigation parameters. 341 // Create the navigation parameters.
335 FrameMsg_Navigate_Type::Value navigation_type = 342 FrameMsg_Navigate_Type::Value navigation_type =
336 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); 343 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type);
337 dest_render_frame_host->Navigate( 344 dest_render_frame_host->Navigate(
338 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, 345 entry.ConstructCommonNavigationParams(dest_url, dest_referrer,
339 frame_entry, navigation_type), 346 frame_entry, navigation_type),
340 entry.ConstructStartNavigationParams(), 347 entry.ConstructStartNavigationParams(),
341 entry.ConstructRequestNavigationParams( 348 entry.ConstructRequestNavigationParams(
342 frame_entry, navigation_start, is_same_document_history_load, 349 frame_entry, navigation_start, is_same_document_history_load,
343 frame_tree_node->has_committed_real_load(), 350 frame_tree_node->has_committed_real_load(),
344 controller_->GetPendingEntryIndex() == -1, 351 controller_->GetPendingEntryIndex() == -1,
345 controller_->GetIndexOfEntry(&entry), 352 controller_->GetIndexOfEntry(&entry),
346 controller_->GetLastCommittedEntryIndex(), 353 history_offset, history_length));
347 controller_->GetEntryCount()));
348 } else { 354 } else {
349 // No need to navigate again. Just resume the deferred request. 355 // No need to navigate again. Just resume the deferred request.
350 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation( 356 dest_render_frame_host->GetProcess()->ResumeDeferredNavigation(
351 entry.transferred_global_request_id()); 357 entry.transferred_global_request_id());
352 } 358 }
353 359
354 // Make sure no code called via RFH::Navigate clears the pending entry. 360 // Make sure no code called via RFH::Navigate clears the pending entry.
355 CHECK_EQ(controller_->GetPendingEntry(), &entry); 361 CHECK_EQ(controller_->GetPendingEntry(), &entry);
356 362
357 if (controller_->GetPendingEntryIndex() == -1 && 363 if (controller_->GetPendingEntryIndex() == -1 &&
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 LoadCommittedDetails details; 468 LoadCommittedDetails details;
463 bool did_navigate = controller_->RendererDidNavigate(render_frame_host, 469 bool did_navigate = controller_->RendererDidNavigate(render_frame_host,
464 params, &details); 470 params, &details);
465 471
466 // Keep track of each frame's URL in its FrameTreeNode. 472 // Keep track of each frame's URL in its FrameTreeNode.
467 render_frame_host->frame_tree_node()->SetCurrentURL(params.url); 473 render_frame_host->frame_tree_node()->SetCurrentURL(params.url);
468 474
469 // Send notification about committed provisional loads. This notification is 475 // Send notification about committed provisional loads. This notification is
470 // different from the NAV_ENTRY_COMMITTED notification which doesn't include 476 // different from the NAV_ENTRY_COMMITTED notification which doesn't include
471 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. 477 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations.
472 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) { 478 // TODO(creis): Do we need to send this for AUTO_SUBFRAME when did_navigate
479 // is false?
480 if (delegate_) {
473 DCHECK_EQ(!render_frame_host->GetParent(), 481 DCHECK_EQ(!render_frame_host->GetParent(),
474 did_navigate ? details.is_main_frame : false); 482 did_navigate ? details.is_main_frame : false);
475 ui::PageTransition transition_type = params.transition; 483 ui::PageTransition transition_type = params.transition;
476 // Whether or not a page transition was triggered by going backward or 484 // Whether or not a page transition was triggered by going backward or
477 // forward in the history is only stored in the navigation controller's 485 // forward in the history is only stored in the navigation controller's
478 // entry list. 486 // entry list.
479 if (did_navigate && 487 if (did_navigate &&
480 (controller_->GetLastCommittedEntry()->GetTransitionType() & 488 (controller_->GetLastCommittedEntry()->GetTransitionType() &
481 ui::PAGE_TRANSITION_FORWARD_BACK)) { 489 ui::PAGE_TRANSITION_FORWARD_BACK)) {
482 transition_type = ui::PageTransitionFromInt( 490 transition_type = ui::PageTransitionFromInt(
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 entry->set_should_replace_entry(pending_entry->should_replace_entry()); 954 entry->set_should_replace_entry(pending_entry->should_replace_entry());
947 entry->SetRedirectChain(pending_entry->GetRedirectChain()); 955 entry->SetRedirectChain(pending_entry->GetRedirectChain());
948 } 956 }
949 controller_->SetPendingEntry(entry.Pass()); 957 controller_->SetPendingEntry(entry.Pass());
950 if (delegate_) 958 if (delegate_)
951 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 959 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
952 } 960 }
953 } 961 }
954 962
955 } // namespace content 963 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698