OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/navigation_controller_impl.h" | 5 #include "content/browser/web_contents/navigation_controller_impl.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_number_conversions.h" // Temporary | 9 #include "base/string_number_conversions.h" // Temporary |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 // scenarios can be differentiated with the TransitionType. | 107 // scenarios can be differentiated with the TransitionType. |
108 return false; | 108 return false; |
109 } | 109 } |
110 | 110 |
111 url_canon::Replacements<char> replacements; | 111 url_canon::Replacements<char> replacements; |
112 replacements.ClearRef(); | 112 replacements.ClearRef(); |
113 return existing_url.ReplaceComponents(replacements) == | 113 return existing_url.ReplaceComponents(replacements) == |
114 new_url.ReplaceComponents(replacements); | 114 new_url.ReplaceComponents(replacements); |
115 } | 115 } |
116 | 116 |
117 // Determines whether or not we should be carrying over a user agent override | |
118 // between two NavigationEntries. | |
119 bool ShouldKeepOverride( | |
120 content::PageTransition transition, | |
Charlie Reis
2012/06/19 22:47:59
Why is transition needed?
gone
2012/06/20 00:01:10
Was a leftover bit... removed.
| |
121 const content::NavigationEntry* last_entry) { | |
122 return last_entry && last_entry->GetIsOverridingUserAgent(); | |
123 } | |
124 | |
117 } // namespace | 125 } // namespace |
118 | 126 |
119 // NavigationControllerImpl ---------------------------------------------------- | 127 // NavigationControllerImpl ---------------------------------------------------- |
120 | 128 |
121 const size_t kMaxEntryCountForTestingNotSet = -1; | 129 const size_t kMaxEntryCountForTestingNotSet = -1; |
122 | 130 |
123 // static | 131 // static |
124 size_t NavigationControllerImpl::max_entry_count_for_testing_ = | 132 size_t NavigationControllerImpl::max_entry_count_for_testing_ = |
125 kMaxEntryCountForTestingNotSet; | 133 kMaxEntryCountForTestingNotSet; |
126 | 134 |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 } | 578 } |
571 | 579 |
572 void NavigationControllerImpl::LoadURL( | 580 void NavigationControllerImpl::LoadURL( |
573 const GURL& url, | 581 const GURL& url, |
574 const content::Referrer& referrer, | 582 const content::Referrer& referrer, |
575 content::PageTransition transition, | 583 content::PageTransition transition, |
576 const std::string& extra_headers) { | 584 const std::string& extra_headers) { |
577 if (content::HandleDebugURL(url, transition)) | 585 if (content::HandleDebugURL(url, transition)) |
578 return; | 586 return; |
579 | 587 |
580 // The user initiated a load, we don't need to reload anymore. | 588 bool override = ShouldKeepOverride(transition, GetLastCommittedEntry()); |
581 needs_reload_ = false; | 589 LoadURLWithUserAgentOverride(url, referrer, transition, false, extra_headers, |
582 | 590 override); |
583 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | |
584 CreateNavigationEntry( | |
585 url, referrer, transition, false, extra_headers, browser_context_)); | |
586 | |
587 LoadEntry(entry); | |
588 } | 591 } |
589 | 592 |
590 void NavigationControllerImpl::LoadURLFromRenderer( | 593 void NavigationControllerImpl::LoadURLFromRenderer( |
591 const GURL& url, | 594 const GURL& url, |
592 const content::Referrer& referrer, | 595 const content::Referrer& referrer, |
593 content::PageTransition transition, | 596 content::PageTransition transition, |
594 const std::string& extra_headers) { | 597 const std::string& extra_headers) { |
598 bool override = ShouldKeepOverride(transition, GetLastCommittedEntry()); | |
599 LoadURLWithUserAgentOverride(url, referrer, transition, true, extra_headers, | |
600 override); | |
601 } | |
602 | |
603 void NavigationControllerImpl::LoadURLWithUserAgentOverride( | |
604 const GURL& url, | |
605 const content::Referrer& referrer, | |
606 content::PageTransition transition, | |
607 bool is_renderer_initiated, | |
608 const std::string& extra_headers, | |
609 bool is_overriding_user_agent) { | |
595 // The user initiated a load, we don't need to reload anymore. | 610 // The user initiated a load, we don't need to reload anymore. |
596 needs_reload_ = false; | 611 needs_reload_ = false; |
597 | 612 |
598 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | 613 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( |
599 CreateNavigationEntry( | 614 CreateNavigationEntry( |
600 url, referrer, transition, true, extra_headers, browser_context_)); | 615 url, referrer, transition, is_renderer_initiated, extra_headers, |
616 browser_context_)); | |
617 entry->SetIsOverridingUserAgent(is_overriding_user_agent); | |
601 | 618 |
602 LoadEntry(entry); | 619 LoadEntry(entry); |
603 } | 620 } |
604 | 621 |
605 void NavigationControllerImpl::DocumentLoadedInFrame() { | 622 void NavigationControllerImpl::DocumentLoadedInFrame() { |
606 last_document_loaded_ = base::TimeTicks::Now(); | 623 last_document_loaded_ = base::TimeTicks::Now(); |
607 } | 624 } |
608 | 625 |
609 bool NavigationControllerImpl::RendererDidNavigate( | 626 bool NavigationControllerImpl::RendererDidNavigate( |
610 const ViewHostMsg_FrameNavigate_Params& params, | 627 const ViewHostMsg_FrameNavigate_Params& params, |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
861 new_entry->SetURL(params.url); | 878 new_entry->SetURL(params.url); |
862 if (update_virtual_url) | 879 if (update_virtual_url) |
863 UpdateVirtualURLToURL(new_entry, params.url); | 880 UpdateVirtualURLToURL(new_entry, params.url); |
864 new_entry->SetReferrer(params.referrer); | 881 new_entry->SetReferrer(params.referrer); |
865 new_entry->SetPageID(params.page_id); | 882 new_entry->SetPageID(params.page_id); |
866 new_entry->SetTransitionType(params.transition); | 883 new_entry->SetTransitionType(params.transition); |
867 new_entry->set_site_instance( | 884 new_entry->set_site_instance( |
868 static_cast<SiteInstanceImpl*>(web_contents_->GetSiteInstance())); | 885 static_cast<SiteInstanceImpl*>(web_contents_->GetSiteInstance())); |
869 new_entry->SetHasPostData(params.is_post); | 886 new_entry->SetHasPostData(params.is_post); |
870 new_entry->SetPostID(params.post_id); | 887 new_entry->SetPostID(params.post_id); |
888 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent); | |
871 | 889 |
872 if (params.redirects.size() > 0) | 890 if (params.redirects.size() > 0) |
873 new_entry->SetOriginalRequestURL(params.redirects[0]); | 891 new_entry->SetOriginalRequestURL(params.redirects[0]); |
874 else | 892 else |
875 new_entry->SetOriginalRequestURL(params.url); | 893 new_entry->SetOriginalRequestURL(params.url); |
876 | 894 |
877 InsertOrReplaceEntry(new_entry, *did_replace_entry); | 895 InsertOrReplaceEntry(new_entry, *did_replace_entry); |
878 } | 896 } |
879 | 897 |
880 void NavigationControllerImpl::RendererDidNavigateToExistingPage( | 898 void NavigationControllerImpl::RendererDidNavigateToExistingPage( |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1432 for (int i = 0; i < max_index; i++) { | 1450 for (int i = 0; i < max_index; i++) { |
1433 // When cloning a tab, copy all entries except interstitial pages | 1451 // When cloning a tab, copy all entries except interstitial pages |
1434 if (source.entries_[i].get()->GetPageType() != | 1452 if (source.entries_[i].get()->GetPageType() != |
1435 content::PAGE_TYPE_INTERSTITIAL) { | 1453 content::PAGE_TYPE_INTERSTITIAL) { |
1436 entries_.insert(entries_.begin() + insert_index++, | 1454 entries_.insert(entries_.begin() + insert_index++, |
1437 linked_ptr<NavigationEntryImpl>( | 1455 linked_ptr<NavigationEntryImpl>( |
1438 new NavigationEntryImpl(*source.entries_[i]))); | 1456 new NavigationEntryImpl(*source.entries_[i]))); |
1439 } | 1457 } |
1440 } | 1458 } |
1441 } | 1459 } |
OLD | NEW |