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

Side by Side Diff: content/browser/tab_contents/navigation_controller.cc

Issue 8253002: Move PageTransition into content namespace. While I'm touching all these files, I've also updated... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tab_contents/navigation_controller.h" 5 #include "content/browser/tab_contents/navigation_controller.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 // Configure all the NavigationEntries in entries for restore. This resets 65 // Configure all the NavigationEntries in entries for restore. This resets
66 // the transition type to reload and makes sure the content state isn't empty. 66 // the transition type to reload and makes sure the content state isn't empty.
67 void ConfigureEntriesForRestore( 67 void ConfigureEntriesForRestore(
68 std::vector<linked_ptr<NavigationEntry> >* entries, 68 std::vector<linked_ptr<NavigationEntry> >* entries,
69 bool from_last_session) { 69 bool from_last_session) {
70 for (size_t i = 0; i < entries->size(); ++i) { 70 for (size_t i = 0; i < entries->size(); ++i) {
71 // Use a transition type of reload so that we don't incorrectly increase 71 // Use a transition type of reload so that we don't incorrectly increase
72 // the typed count. 72 // the typed count.
73 (*entries)[i]->set_transition_type(PageTransition::RELOAD); 73 (*entries)[i]->set_transition_type(content::PAGE_TRANSITION_RELOAD);
74 (*entries)[i]->set_restore_type(from_last_session ? 74 (*entries)[i]->set_restore_type(from_last_session ?
75 NavigationEntry::RESTORE_LAST_SESSION : 75 NavigationEntry::RESTORE_LAST_SESSION :
76 NavigationEntry::RESTORE_CURRENT_SESSION); 76 NavigationEntry::RESTORE_CURRENT_SESSION);
77 // NOTE(darin): This code is only needed for backwards compat. 77 // NOTE(darin): This code is only needed for backwards compat.
78 SetContentStateIfEmpty((*entries)[i].get()); 78 SetContentStateIfEmpty((*entries)[i].get());
79 } 79 }
80 } 80 }
81 81
82 // See NavigationController::IsURLInPageNavigation for how this works and why. 82 // See NavigationController::IsURLInPageNavigation for how this works and why.
83 bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) { 83 bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 Source<NavigationController>(this), 188 Source<NavigationController>(this),
189 NotificationService::NoDetails()); 189 NotificationService::NoDetails());
190 190
191 pending_reload_ = reload_type; 191 pending_reload_ = reload_type;
192 tab_contents_->Activate(); 192 tab_contents_->Activate();
193 tab_contents_->delegate()->ShowRepostFormWarningDialog(tab_contents_); 193 tab_contents_->delegate()->ShowRepostFormWarningDialog(tab_contents_);
194 } else { 194 } else {
195 DiscardNonCommittedEntriesInternal(); 195 DiscardNonCommittedEntriesInternal();
196 196
197 pending_entry_index_ = current_index; 197 pending_entry_index_ = current_index;
198 entries_[pending_entry_index_]->set_transition_type(PageTransition::RELOAD); 198 entries_[pending_entry_index_]->set_transition_type(
199 content::PAGE_TRANSITION_RELOAD);
199 NavigateToPendingEntry(reload_type); 200 NavigateToPendingEntry(reload_type);
200 } 201 }
201 } 202 }
202 203
203 void NavigationController::CancelPendingReload() { 204 void NavigationController::CancelPendingReload() {
204 DCHECK(pending_reload_ != NO_RELOAD); 205 DCHECK(pending_reload_ != NO_RELOAD);
205 pending_reload_ = NO_RELOAD; 206 pending_reload_ = NO_RELOAD;
206 } 207 }
207 208
208 void NavigationController::ContinuePendingReload() { 209 void NavigationController::ContinuePendingReload() {
209 if (pending_reload_ == NO_RELOAD) { 210 if (pending_reload_ == NO_RELOAD) {
210 NOTREACHED(); 211 NOTREACHED();
211 } else { 212 } else {
212 ReloadInternal(false, pending_reload_); 213 ReloadInternal(false, pending_reload_);
213 pending_reload_ = NO_RELOAD; 214 pending_reload_ = NO_RELOAD;
214 } 215 }
215 } 216 }
216 217
217 bool NavigationController::IsInitialNavigation() { 218 bool NavigationController::IsInitialNavigation() {
218 return last_document_loaded_.is_null(); 219 return last_document_loaded_.is_null();
219 } 220 }
220 221
221 // static 222 // static
222 NavigationEntry* NavigationController::CreateNavigationEntry( 223 NavigationEntry* NavigationController::CreateNavigationEntry(
223 const GURL& url, const GURL& referrer, PageTransition::Type transition, 224 const GURL& url, const GURL& referrer, content::PageTransition transition,
224 const std::string& extra_headers, 225 const std::string& extra_headers,
225 content::BrowserContext* browser_context) { 226 content::BrowserContext* browser_context) {
226 // Allow the browser URL handler to rewrite the URL. This will, for example, 227 // Allow the browser URL handler to rewrite the URL. This will, for example,
227 // remove "view-source:" from the beginning of the URL to get the URL that 228 // remove "view-source:" from the beginning of the URL to get the URL that
228 // will actually be loaded. This real URL won't be shown to the user, just 229 // will actually be loaded. This real URL won't be shown to the user, just
229 // used internally. 230 // used internally.
230 GURL loaded_url(url); 231 GURL loaded_url(url);
231 bool reverse_on_redirect = false; 232 bool reverse_on_redirect = false;
232 BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( 233 BrowserURLHandler::GetInstance()->RewriteURLIfNecessary(
233 &loaded_url, browser_context, &reverse_on_redirect); 234 &loaded_url, browser_context, &reverse_on_redirect);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 return; 351 return;
351 } 352 }
352 353
353 // Base the navigation on where we are now... 354 // Base the navigation on where we are now...
354 int current_index = GetCurrentEntryIndex(); 355 int current_index = GetCurrentEntryIndex();
355 356
356 DiscardNonCommittedEntries(); 357 DiscardNonCommittedEntries();
357 358
358 pending_entry_index_ = current_index - 1; 359 pending_entry_index_ = current_index - 1;
359 entries_[pending_entry_index_]->set_transition_type( 360 entries_[pending_entry_index_]->set_transition_type(
360 entries_[pending_entry_index_]->transition_type() | 361 content::PageTransitionFromInt(
361 PageTransition::FORWARD_BACK); 362 entries_[pending_entry_index_]->transition_type() |
363 content::PAGE_TRANSITION_FORWARD_BACK));
362 NavigateToPendingEntry(NO_RELOAD); 364 NavigateToPendingEntry(NO_RELOAD);
363 } 365 }
364 366
365 void NavigationController::GoForward() { 367 void NavigationController::GoForward() {
366 if (!CanGoForward()) { 368 if (!CanGoForward()) {
367 NOTREACHED(); 369 NOTREACHED();
368 return; 370 return;
369 } 371 }
370 372
371 // If an interstitial page is showing, the previous renderer is blocked and 373 // If an interstitial page is showing, the previous renderer is blocked and
(...skipping 11 matching lines...) Expand all
383 385
384 DiscardNonCommittedEntries(); 386 DiscardNonCommittedEntries();
385 387
386 pending_entry_index_ = current_index; 388 pending_entry_index_ = current_index;
387 // If there was a transient entry, we removed it making the current index 389 // If there was a transient entry, we removed it making the current index
388 // the next page. 390 // the next page.
389 if (!transient) 391 if (!transient)
390 pending_entry_index_++; 392 pending_entry_index_++;
391 393
392 entries_[pending_entry_index_]->set_transition_type( 394 entries_[pending_entry_index_]->set_transition_type(
393 entries_[pending_entry_index_]->transition_type() | 395 content::PageTransitionFromInt(
394 PageTransition::FORWARD_BACK); 396 entries_[pending_entry_index_]->transition_type() |
397 content::PAGE_TRANSITION_FORWARD_BACK));
395 NavigateToPendingEntry(NO_RELOAD); 398 NavigateToPendingEntry(NO_RELOAD);
396 } 399 }
397 400
398 void NavigationController::GoToIndex(int index) { 401 void NavigationController::GoToIndex(int index) {
399 if (index < 0 || index >= static_cast<int>(entries_.size())) { 402 if (index < 0 || index >= static_cast<int>(entries_.size())) {
400 NOTREACHED(); 403 NOTREACHED();
401 return; 404 return;
402 } 405 }
403 406
404 if (transient_entry_index_ != -1) { 407 if (transient_entry_index_ != -1) {
(...skipping 19 matching lines...) Expand all
424 // navigation to succeed. The interstitial will stay visible until the 427 // navigation to succeed. The interstitial will stay visible until the
425 // resulting DidNavigate. 428 // resulting DidNavigate.
426 tab_contents_->interstitial_page()->CancelForNavigation(); 429 tab_contents_->interstitial_page()->CancelForNavigation();
427 } 430 }
428 } 431 }
429 432
430 DiscardNonCommittedEntries(); 433 DiscardNonCommittedEntries();
431 434
432 pending_entry_index_ = index; 435 pending_entry_index_ = index;
433 entries_[pending_entry_index_]->set_transition_type( 436 entries_[pending_entry_index_]->set_transition_type(
434 entries_[pending_entry_index_]->transition_type() | 437 content::PageTransitionFromInt(
435 PageTransition::FORWARD_BACK); 438 entries_[pending_entry_index_]->transition_type() |
439 content::PAGE_TRANSITION_FORWARD_BACK));
436 NavigateToPendingEntry(NO_RELOAD); 440 NavigateToPendingEntry(NO_RELOAD);
437 } 441 }
438 442
439 void NavigationController::GoToOffset(int offset) { 443 void NavigationController::GoToOffset(int offset) {
440 int index = (transient_entry_index_ != -1) ? 444 int index = (transient_entry_index_ != -1) ?
441 transient_entry_index_ + offset : 445 transient_entry_index_ + offset :
442 last_committed_entry_index_ + offset; 446 last_committed_entry_index_ + offset;
443 if (index < 0 || index >= entry_count()) 447 if (index < 0 || index >= entry_count())
444 return; 448 return;
445 449
446 GoToIndex(index); 450 GoToIndex(index);
447 } 451 }
448 452
449 void NavigationController::RemoveEntryAtIndex(int index, 453 void NavigationController::RemoveEntryAtIndex(int index,
450 const GURL& default_url) { 454 const GURL& default_url) {
451 bool is_current = index == last_committed_entry_index_; 455 bool is_current = index == last_committed_entry_index_;
452 RemoveEntryAtIndexInternal(index); 456 RemoveEntryAtIndexInternal(index);
453 if (is_current) { 457 if (is_current) {
454 // We removed the currently shown entry, so we have to load something else. 458 // We removed the currently shown entry, so we have to load something else.
455 if (last_committed_entry_index_ != -1) { 459 if (last_committed_entry_index_ != -1) {
456 pending_entry_index_ = last_committed_entry_index_; 460 pending_entry_index_ = last_committed_entry_index_;
457 NavigateToPendingEntry(NO_RELOAD); 461 NavigateToPendingEntry(NO_RELOAD);
458 } else { 462 } else {
459 // If there is nothing to show, show a default page. 463 // If there is nothing to show, show a default page.
460 LoadURL(default_url.is_empty() ? GURL("about:blank") : default_url, 464 LoadURL(default_url.is_empty() ? GURL("about:blank") : default_url,
461 GURL(), PageTransition::START_PAGE, std::string()); 465 GURL(), content::PAGE_TRANSITION_START_PAGE, std::string());
462 } 466 }
463 } 467 }
464 } 468 }
465 469
466 void NavigationController::UpdateVirtualURLToURL( 470 void NavigationController::UpdateVirtualURLToURL(
467 NavigationEntry* entry, const GURL& new_url) { 471 NavigationEntry* entry, const GURL& new_url) {
468 GURL new_virtual_url(new_url); 472 GURL new_virtual_url(new_url);
469 if (BrowserURLHandler::GetInstance()->ReverseURLRewrite( 473 if (BrowserURLHandler::GetInstance()->ReverseURLRewrite(
470 &new_virtual_url, entry->virtual_url(), browser_context_)) { 474 &new_virtual_url, entry->virtual_url(), browser_context_)) {
471 entry->set_virtual_url(new_virtual_url); 475 entry->set_virtual_url(new_virtual_url);
472 } 476 }
473 } 477 }
474 478
475 void NavigationController::AddTransientEntry(NavigationEntry* entry) { 479 void NavigationController::AddTransientEntry(NavigationEntry* entry) {
476 // Discard any current transient entry, we can only have one at a time. 480 // Discard any current transient entry, we can only have one at a time.
477 int index = 0; 481 int index = 0;
478 if (last_committed_entry_index_ != -1) 482 if (last_committed_entry_index_ != -1)
479 index = last_committed_entry_index_ + 1; 483 index = last_committed_entry_index_ + 1;
480 DiscardTransientEntry(); 484 DiscardTransientEntry();
481 entries_.insert(entries_.begin() + index, linked_ptr<NavigationEntry>(entry)); 485 entries_.insert(entries_.begin() + index, linked_ptr<NavigationEntry>(entry));
482 transient_entry_index_ = index; 486 transient_entry_index_ = index;
483 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); 487 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll);
484 } 488 }
485 489
486 void NavigationController::LoadURL( 490 void NavigationController::LoadURL(
487 const GURL& url, 491 const GURL& url,
488 const GURL& referrer, 492 const GURL& referrer,
489 PageTransition::Type transition, 493 content::PageTransition transition,
490 const std::string& extra_headers) { 494 const std::string& extra_headers) {
491 // The user initiated a load, we don't need to reload anymore. 495 // The user initiated a load, we don't need to reload anymore.
492 needs_reload_ = false; 496 needs_reload_ = false;
493 497
494 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, 498 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition,
495 extra_headers, 499 extra_headers,
496 browser_context_); 500 browser_context_);
497 501
498 LoadEntry(entry); 502 LoadEntry(entry);
499 } 503 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 // get confused when we go back to them (see the function for details). 569 // get confused when we go back to them (see the function for details).
566 DCHECK(!params.content_state.empty()); 570 DCHECK(!params.content_state.empty());
567 NavigationEntry* active_entry = GetActiveEntry(); 571 NavigationEntry* active_entry = GetActiveEntry();
568 active_entry->set_content_state(params.content_state); 572 active_entry->set_content_state(params.content_state);
569 573
570 // The active entry's SiteInstance should match our SiteInstance. 574 // The active entry's SiteInstance should match our SiteInstance.
571 DCHECK(active_entry->site_instance() == tab_contents_->GetSiteInstance()); 575 DCHECK(active_entry->site_instance() == tab_contents_->GetSiteInstance());
572 576
573 // Now prep the rest of the details for the notification and broadcast. 577 // Now prep the rest of the details for the notification and broadcast.
574 details->entry = active_entry; 578 details->entry = active_entry;
575 details->is_main_frame = PageTransition::IsMainFrame(params.transition); 579 details->is_main_frame =
580 content::PageTransitionIsMainFrame(params.transition);
576 details->serialized_security_info = params.security_info; 581 details->serialized_security_info = params.security_info;
577 details->http_status_code = params.http_status_code; 582 details->http_status_code = params.http_status_code;
578 NotifyNavigationEntryCommitted(details); 583 NotifyNavigationEntryCommitted(details);
579 584
580 return true; 585 return true;
581 } 586 }
582 587
583 NavigationType::Type NavigationController::ClassifyNavigation( 588 NavigationType::Type NavigationController::ClassifyNavigation(
584 const ViewHostMsg_FrameNavigate_Params& params) const { 589 const ViewHostMsg_FrameNavigate_Params& params) const {
585 if (params.page_id == -1) { 590 if (params.page_id == -1) {
(...skipping 15 matching lines...) Expand all
601 // list. 606 // list.
602 // 607 //
603 // In these cases, there's nothing we can do with them, so ignore. 608 // In these cases, there's nothing we can do with them, so ignore.
604 return NavigationType::NAV_IGNORE; 609 return NavigationType::NAV_IGNORE;
605 } 610 }
606 611
607 if (params.page_id > tab_contents_->GetMaxPageID()) { 612 if (params.page_id > tab_contents_->GetMaxPageID()) {
608 // Greater page IDs than we've ever seen before are new pages. We may or may 613 // Greater page IDs than we've ever seen before are new pages. We may or may
609 // not have a pending entry for the page, and this may or may not be the 614 // not have a pending entry for the page, and this may or may not be the
610 // main frame. 615 // main frame.
611 if (PageTransition::IsMainFrame(params.transition)) 616 if (content::PageTransitionIsMainFrame(params.transition))
612 return NavigationType::NEW_PAGE; 617 return NavigationType::NEW_PAGE;
613 618
614 // When this is a new subframe navigation, we should have a committed page 619 // When this is a new subframe navigation, we should have a committed page
615 // for which it's a suframe in. This may not be the case when an iframe is 620 // for which it's a suframe in. This may not be the case when an iframe is
616 // navigated on a popup navigated to about:blank (the iframe would be 621 // navigated on a popup navigated to about:blank (the iframe would be
617 // written into the popup by script on the main page). For these cases, 622 // written into the popup by script on the main page). For these cases,
618 // there isn't any navigation stuff we can do, so just ignore it. 623 // there isn't any navigation stuff we can do, so just ignore it.
619 if (!GetLastCommittedEntry()) 624 if (!GetLastCommittedEntry())
620 return NavigationType::NAV_IGNORE; 625 return NavigationType::NAV_IGNORE;
621 626
(...skipping 14 matching lines...) Expand all
636 // Because the unknown entry has committed, we risk showing the wrong URL in 641 // Because the unknown entry has committed, we risk showing the wrong URL in
637 // release builds. Instead, we'll kill the renderer process to be safe. 642 // release builds. Instead, we'll kill the renderer process to be safe.
638 LOG(ERROR) << "terminating renderer for bad navigation: " << params.url; 643 LOG(ERROR) << "terminating renderer for bad navigation: " << params.url;
639 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_NC")); 644 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_NC"));
640 if (tab_contents_->GetSiteInstance()->HasProcess()) 645 if (tab_contents_->GetSiteInstance()->HasProcess())
641 tab_contents_->GetSiteInstance()->GetProcess()->ReceivedBadMessage(); 646 tab_contents_->GetSiteInstance()->GetProcess()->ReceivedBadMessage();
642 return NavigationType::NAV_IGNORE; 647 return NavigationType::NAV_IGNORE;
643 } 648 }
644 NavigationEntry* existing_entry = entries_[existing_entry_index].get(); 649 NavigationEntry* existing_entry = entries_[existing_entry_index].get();
645 650
646 if (!PageTransition::IsMainFrame(params.transition)) { 651 if (!content::PageTransitionIsMainFrame(params.transition)) {
647 // All manual subframes would get new IDs and were handled above, so we 652 // All manual subframes would get new IDs and were handled above, so we
648 // know this is auto. Since the current page was found in the navigation 653 // know this is auto. Since the current page was found in the navigation
649 // entry list, we're guaranteed to have a last committed entry. 654 // entry list, we're guaranteed to have a last committed entry.
650 DCHECK(GetLastCommittedEntry()); 655 DCHECK(GetLastCommittedEntry());
651 return NavigationType::AUTO_SUBFRAME; 656 return NavigationType::AUTO_SUBFRAME;
652 } 657 }
653 658
654 // Anything below here we know is a main frame navigation. 659 // Anything below here we know is a main frame navigation.
655 if (pending_entry_ && 660 if (pending_entry_ &&
656 existing_entry != pending_entry_ && 661 existing_entry != pending_entry_ &&
(...skipping 19 matching lines...) Expand all
676 681
677 // Since we weeded out "new" navigations above, we know this is an existing 682 // Since we weeded out "new" navigations above, we know this is an existing
678 // (back/forward) navigation. 683 // (back/forward) navigation.
679 return NavigationType::EXISTING_PAGE; 684 return NavigationType::EXISTING_PAGE;
680 } 685 }
681 686
682 bool NavigationController::IsRedirect( 687 bool NavigationController::IsRedirect(
683 const ViewHostMsg_FrameNavigate_Params& params) { 688 const ViewHostMsg_FrameNavigate_Params& params) {
684 // For main frame transition, we judge by params.transition. 689 // For main frame transition, we judge by params.transition.
685 // Otherwise, by params.redirects. 690 // Otherwise, by params.redirects.
686 if (PageTransition::IsMainFrame(params.transition)) { 691 if (content::PageTransitionIsMainFrame(params.transition)) {
687 return PageTransition::IsRedirect(params.transition); 692 return content::PageTransitionIsRedirect(params.transition);
688 } 693 }
689 return params.redirects.size() > 1; 694 return params.redirects.size() > 1;
690 } 695 }
691 696
692 void NavigationController::RendererDidNavigateToNewPage( 697 void NavigationController::RendererDidNavigateToNewPage(
693 const ViewHostMsg_FrameNavigate_Params& params, bool* did_replace_entry) { 698 const ViewHostMsg_FrameNavigate_Params& params, bool* did_replace_entry) {
694 NavigationEntry* new_entry; 699 NavigationEntry* new_entry;
695 bool update_virtual_url; 700 bool update_virtual_url;
696 if (pending_entry_) { 701 if (pending_entry_) {
697 // TODO(brettw) this assumes that the pending entry is appropriate for the 702 // TODO(brettw) this assumes that the pending entry is appropriate for the
(...skipping 23 matching lines...) Expand all
721 new_entry->set_transition_type(params.transition); 726 new_entry->set_transition_type(params.transition);
722 new_entry->set_site_instance(tab_contents_->GetSiteInstance()); 727 new_entry->set_site_instance(tab_contents_->GetSiteInstance());
723 new_entry->set_has_post_data(params.is_post); 728 new_entry->set_has_post_data(params.is_post);
724 729
725 InsertOrReplaceEntry(new_entry, *did_replace_entry); 730 InsertOrReplaceEntry(new_entry, *did_replace_entry);
726 } 731 }
727 732
728 void NavigationController::RendererDidNavigateToExistingPage( 733 void NavigationController::RendererDidNavigateToExistingPage(
729 const ViewHostMsg_FrameNavigate_Params& params) { 734 const ViewHostMsg_FrameNavigate_Params& params) {
730 // We should only get here for main frame navigations. 735 // We should only get here for main frame navigations.
731 DCHECK(PageTransition::IsMainFrame(params.transition)); 736 DCHECK(content::PageTransitionIsMainFrame(params.transition));
732 737
733 // This is a back/forward navigation. The existing page for the ID is 738 // This is a back/forward navigation. The existing page for the ID is
734 // guaranteed to exist by ClassifyNavigation, and we just need to update it 739 // guaranteed to exist by ClassifyNavigation, and we just need to update it
735 // with new information from the renderer. 740 // with new information from the renderer.
736 int entry_index = GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(), 741 int entry_index = GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(),
737 params.page_id); 742 params.page_id);
738 DCHECK(entry_index >= 0 && 743 DCHECK(entry_index >= 0 &&
739 entry_index < static_cast<int>(entries_.size())); 744 entry_index < static_cast<int>(entries_.size()));
740 NavigationEntry* entry = entries_[entry_index].get(); 745 NavigationEntry* entry = entries_[entry_index].get();
741 746
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 // The URL may have changed due to redirects. 791 // The URL may have changed due to redirects.
787 if (existing_entry->update_virtual_url_with_url()) 792 if (existing_entry->update_virtual_url_with_url())
788 UpdateVirtualURLToURL(existing_entry, params.url); 793 UpdateVirtualURLToURL(existing_entry, params.url);
789 existing_entry->set_url(params.url); 794 existing_entry->set_url(params.url);
790 795
791 DiscardNonCommittedEntries(); 796 DiscardNonCommittedEntries();
792 } 797 }
793 798
794 void NavigationController::RendererDidNavigateInPage( 799 void NavigationController::RendererDidNavigateInPage(
795 const ViewHostMsg_FrameNavigate_Params& params, bool* did_replace_entry) { 800 const ViewHostMsg_FrameNavigate_Params& params, bool* did_replace_entry) {
796 DCHECK(PageTransition::IsMainFrame(params.transition)) << 801 DCHECK(content::PageTransitionIsMainFrame(params.transition)) <<
797 "WebKit should only tell us about in-page navs for the main frame."; 802 "WebKit should only tell us about in-page navs for the main frame.";
798 // We're guaranteed to have an entry for this one. 803 // We're guaranteed to have an entry for this one.
799 NavigationEntry* existing_entry = GetEntryWithPageID( 804 NavigationEntry* existing_entry = GetEntryWithPageID(
800 tab_contents_->GetSiteInstance(), 805 tab_contents_->GetSiteInstance(),
801 params.page_id); 806 params.page_id);
802 807
803 // Reference fragment navigation. We're guaranteed to have the last_committed 808 // Reference fragment navigation. We're guaranteed to have the last_committed
804 // entry and it will be the same page as the new navigation (minus the 809 // entry and it will be the same page as the new navigation (minus the
805 // reference fragments, of course). We'll update the URL of the existing 810 // reference fragments, of course). We'll update the URL of the existing
806 // entry without pruning the forward history. 811 // entry without pruning the forward history.
807 existing_entry->set_url(params.url); 812 existing_entry->set_url(params.url);
808 if (existing_entry->update_virtual_url_with_url()) 813 if (existing_entry->update_virtual_url_with_url())
809 UpdateVirtualURLToURL(existing_entry, params.url); 814 UpdateVirtualURLToURL(existing_entry, params.url);
810 815
811 // This replaces the existing entry since the page ID didn't change. 816 // This replaces the existing entry since the page ID didn't change.
812 *did_replace_entry = true; 817 *did_replace_entry = true;
813 818
814 if (pending_entry_) 819 if (pending_entry_)
815 DiscardNonCommittedEntriesInternal(); 820 DiscardNonCommittedEntriesInternal();
816 821
817 // If a transient entry was removed, the indices might have changed, so we 822 // If a transient entry was removed, the indices might have changed, so we
818 // have to query the entry index again. 823 // have to query the entry index again.
819 last_committed_entry_index_ = 824 last_committed_entry_index_ =
820 GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(), params.page_id); 825 GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(), params.page_id);
821 } 826 }
822 827
823 void NavigationController::RendererDidNavigateNewSubframe( 828 void NavigationController::RendererDidNavigateNewSubframe(
824 const ViewHostMsg_FrameNavigate_Params& params) { 829 const ViewHostMsg_FrameNavigate_Params& params) {
825 if (PageTransition::StripQualifier(params.transition) == 830 if (content::PageTransitionStripQualifier(params.transition) ==
826 PageTransition::AUTO_SUBFRAME) { 831 content::PAGE_TRANSITION_AUTO_SUBFRAME) {
827 // This is not user-initiated. Ignore. 832 // This is not user-initiated. Ignore.
828 return; 833 return;
829 } 834 }
830 835
831 // Manual subframe navigations just get the current entry cloned so the user 836 // Manual subframe navigations just get the current entry cloned so the user
832 // can go back or forward to it. The actual subframe information will be 837 // can go back or forward to it. The actual subframe information will be
833 // stored in the page state for each of those entries. This happens out of 838 // stored in the page state for each of those entries. This happens out of
834 // band with the actual navigations. 839 // band with the actual navigations.
835 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " 840 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee "
836 << "that a last committed entry exists."; 841 << "that a last committed entry exists.";
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 1003
999 // If there was a transient entry, invalidate everything so the new active 1004 // If there was a transient entry, invalidate everything so the new active
1000 // entry state is shown. 1005 // entry state is shown.
1001 if (transient) { 1006 if (transient) {
1002 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); 1007 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll);
1003 } 1008 }
1004 } 1009 }
1005 1010
1006 void NavigationController::InsertOrReplaceEntry(NavigationEntry* entry, 1011 void NavigationController::InsertOrReplaceEntry(NavigationEntry* entry,
1007 bool replace) { 1012 bool replace) {
1008 DCHECK(entry->transition_type() != PageTransition::AUTO_SUBFRAME); 1013 DCHECK(entry->transition_type() != content::PAGE_TRANSITION_AUTO_SUBFRAME);
1009 1014
1010 // Copy the pending entry's unique ID to the committed entry. 1015 // Copy the pending entry's unique ID to the committed entry.
1011 // I don't know if pending_entry_index_ can be other than -1 here. 1016 // I don't know if pending_entry_index_ can be other than -1 here.
1012 const NavigationEntry* const pending_entry = (pending_entry_index_ == -1) ? 1017 const NavigationEntry* const pending_entry = (pending_entry_index_ == -1) ?
1013 pending_entry_ : entries_[pending_entry_index_].get(); 1018 pending_entry_ : entries_[pending_entry_index_].get();
1014 if (pending_entry) 1019 if (pending_entry)
1015 entry->set_unique_id(pending_entry->unique_id()); 1020 entry->set_unique_id(pending_entry->unique_id());
1016 1021
1017 DiscardNonCommittedEntriesInternal(); 1022 DiscardNonCommittedEntriesInternal();
1018 1023
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 // a session history navigation to the last committed page, RenderViewHost 1061 // a session history navigation to the last committed page, RenderViewHost
1057 // will force the throbber to start, but WebKit will essentially ignore the 1062 // will force the throbber to start, but WebKit will essentially ignore the
1058 // navigation, and won't send a message to stop the throbber. To prevent this 1063 // navigation, and won't send a message to stop the throbber. To prevent this
1059 // from happening, we drop the navigation here and stop the slow-to-commit 1064 // from happening, we drop the navigation here and stop the slow-to-commit
1060 // page from loading (which would normally happen during the navigation). 1065 // page from loading (which would normally happen during the navigation).
1061 if (pending_entry_index_ != -1 && 1066 if (pending_entry_index_ != -1 &&
1062 pending_entry_index_ == last_committed_entry_index_ && 1067 pending_entry_index_ == last_committed_entry_index_ &&
1063 (entries_[pending_entry_index_]->restore_type() == 1068 (entries_[pending_entry_index_]->restore_type() ==
1064 NavigationEntry::RESTORE_NONE) && 1069 NavigationEntry::RESTORE_NONE) &&
1065 (entries_[pending_entry_index_]->transition_type() & 1070 (entries_[pending_entry_index_]->transition_type() &
1066 PageTransition::FORWARD_BACK)) { 1071 content::PAGE_TRANSITION_FORWARD_BACK)) {
1067 tab_contents_->Stop(); 1072 tab_contents_->Stop();
1068 DiscardNonCommittedEntries(); 1073 DiscardNonCommittedEntries();
1069 return; 1074 return;
1070 } 1075 }
1071 1076
1072 // For session history navigations only the pending_entry_index_ is set. 1077 // For session history navigations only the pending_entry_index_ is set.
1073 if (!pending_entry_) { 1078 if (!pending_entry_) {
1074 DCHECK_NE(pending_entry_index_, -1); 1079 DCHECK_NE(pending_entry_index_, -1);
1075 pending_entry_ = entries_[pending_entry_index_].get(); 1080 pending_entry_ = entries_[pending_entry_index_].get();
1076 } 1081 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 size_t insert_index = 0; 1199 size_t insert_index = 0;
1195 for (int i = 0; i < max_index; i++) { 1200 for (int i = 0; i < max_index; i++) {
1196 // When cloning a tab, copy all entries except interstitial pages 1201 // When cloning a tab, copy all entries except interstitial pages
1197 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) { 1202 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) {
1198 entries_.insert(entries_.begin() + insert_index++, 1203 entries_.insert(entries_.begin() + insert_index++,
1199 linked_ptr<NavigationEntry>( 1204 linked_ptr<NavigationEntry>(
1200 new NavigationEntry(*source.entries_[i]))); 1205 new NavigationEntry(*source.entries_[i])));
1201 } 1206 }
1202 } 1207 }
1203 } 1208 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/navigation_controller.h ('k') | content/browser/tab_contents/navigation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698