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

Side by Side Diff: content/browser/web_contents/navigation_controller_impl.cc

Issue 10450002: Transfer user agent override info between browser and renderer (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Default to not overriding in prerender config Created 8 years, 6 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 (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
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(const content::NavigationEntry* last_entry) {
120 return last_entry && last_entry->GetIsOverridingUserAgent();
121 }
122
117 } // namespace 123 } // namespace
118 124
119 // NavigationControllerImpl ---------------------------------------------------- 125 // NavigationControllerImpl ----------------------------------------------------
120 126
121 const size_t kMaxEntryCountForTestingNotSet = -1; 127 const size_t kMaxEntryCountForTestingNotSet = -1;
122 128
123 // static 129 // static
124 size_t NavigationControllerImpl::max_entry_count_for_testing_ = 130 size_t NavigationControllerImpl::max_entry_count_for_testing_ =
125 kMaxEntryCountForTestingNotSet; 131 kMaxEntryCountForTestingNotSet;
126 132
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 } 576 }
571 577
572 void NavigationControllerImpl::LoadURL( 578 void NavigationControllerImpl::LoadURL(
573 const GURL& url, 579 const GURL& url,
574 const content::Referrer& referrer, 580 const content::Referrer& referrer,
575 content::PageTransition transition, 581 content::PageTransition transition,
576 const std::string& extra_headers) { 582 const std::string& extra_headers) {
577 if (content::HandleDebugURL(url, transition)) 583 if (content::HandleDebugURL(url, transition))
578 return; 584 return;
579 585
580 // The user initiated a load, we don't need to reload anymore. 586 bool override = ShouldKeepOverride(GetLastCommittedEntry());
581 needs_reload_ = false; 587 LoadURLWithUserAgentOverride(url, referrer, transition, false, extra_headers,
582 588 override);
583 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(
584 CreateNavigationEntry(
585 url, referrer, transition, false, extra_headers, browser_context_));
586
587 LoadEntry(entry);
588 } 589 }
589 590
590 void NavigationControllerImpl::LoadURLFromRenderer( 591 void NavigationControllerImpl::LoadURLFromRenderer(
591 const GURL& url, 592 const GURL& url,
592 const content::Referrer& referrer, 593 const content::Referrer& referrer,
593 content::PageTransition transition, 594 content::PageTransition transition,
594 const std::string& extra_headers) { 595 const std::string& extra_headers) {
596 bool override = ShouldKeepOverride(GetLastCommittedEntry());
597 LoadURLWithUserAgentOverride(url, referrer, transition, true, extra_headers,
598 override);
599 }
600
601 void NavigationControllerImpl::LoadURLWithUserAgentOverride(
602 const GURL& url,
603 const content::Referrer& referrer,
604 content::PageTransition transition,
605 bool is_renderer_initiated,
606 const std::string& extra_headers,
607 bool is_overriding_user_agent) {
595 // The user initiated a load, we don't need to reload anymore. 608 // The user initiated a load, we don't need to reload anymore.
596 needs_reload_ = false; 609 needs_reload_ = false;
597 610
598 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( 611 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(
599 CreateNavigationEntry( 612 CreateNavigationEntry(
600 url, referrer, transition, true, extra_headers, browser_context_)); 613 url, referrer, transition, is_renderer_initiated, extra_headers,
614 browser_context_));
615 entry->SetIsOverridingUserAgent(is_overriding_user_agent);
601 616
602 LoadEntry(entry); 617 LoadEntry(entry);
603 } 618 }
604 619
605 void NavigationControllerImpl::DocumentLoadedInFrame() { 620 void NavigationControllerImpl::DocumentLoadedInFrame() {
606 last_document_loaded_ = base::TimeTicks::Now(); 621 last_document_loaded_ = base::TimeTicks::Now();
607 } 622 }
608 623
609 bool NavigationControllerImpl::RendererDidNavigate( 624 bool NavigationControllerImpl::RendererDidNavigate(
610 const ViewHostMsg_FrameNavigate_Params& params, 625 const ViewHostMsg_FrameNavigate_Params& params,
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 new_entry->SetURL(params.url); 876 new_entry->SetURL(params.url);
862 if (update_virtual_url) 877 if (update_virtual_url)
863 UpdateVirtualURLToURL(new_entry, params.url); 878 UpdateVirtualURLToURL(new_entry, params.url);
864 new_entry->SetReferrer(params.referrer); 879 new_entry->SetReferrer(params.referrer);
865 new_entry->SetPageID(params.page_id); 880 new_entry->SetPageID(params.page_id);
866 new_entry->SetTransitionType(params.transition); 881 new_entry->SetTransitionType(params.transition);
867 new_entry->set_site_instance( 882 new_entry->set_site_instance(
868 static_cast<SiteInstanceImpl*>(web_contents_->GetSiteInstance())); 883 static_cast<SiteInstanceImpl*>(web_contents_->GetSiteInstance()));
869 new_entry->SetHasPostData(params.is_post); 884 new_entry->SetHasPostData(params.is_post);
870 new_entry->SetPostID(params.post_id); 885 new_entry->SetPostID(params.post_id);
886 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent);
871 887
872 if (params.redirects.size() > 0) 888 if (params.redirects.size() > 0)
873 new_entry->SetOriginalRequestURL(params.redirects[0]); 889 new_entry->SetOriginalRequestURL(params.redirects[0]);
874 else 890 else
875 new_entry->SetOriginalRequestURL(params.url); 891 new_entry->SetOriginalRequestURL(params.url);
876 892
877 InsertOrReplaceEntry(new_entry, *did_replace_entry); 893 InsertOrReplaceEntry(new_entry, *did_replace_entry);
878 } 894 }
879 895
880 void NavigationControllerImpl::RendererDidNavigateToExistingPage( 896 void NavigationControllerImpl::RendererDidNavigateToExistingPage(
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 for (int i = 0; i < max_index; i++) { 1448 for (int i = 0; i < max_index; i++) {
1433 // When cloning a tab, copy all entries except interstitial pages 1449 // When cloning a tab, copy all entries except interstitial pages
1434 if (source.entries_[i].get()->GetPageType() != 1450 if (source.entries_[i].get()->GetPageType() !=
1435 content::PAGE_TYPE_INTERSTITIAL) { 1451 content::PAGE_TYPE_INTERSTITIAL) {
1436 entries_.insert(entries_.begin() + insert_index++, 1452 entries_.insert(entries_.begin() + insert_index++,
1437 linked_ptr<NavigationEntryImpl>( 1453 linked_ptr<NavigationEntryImpl>(
1438 new NavigationEntryImpl(*source.entries_[i]))); 1454 new NavigationEntryImpl(*source.entries_[i])));
1439 } 1455 }
1440 } 1456 }
1441 } 1457 }
OLDNEW
« no previous file with comments | « content/browser/web_contents/navigation_controller_impl.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698