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

Unified Diff: chrome/browser/instant/instant_loader.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: Moved override state to DocumentState 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/instant/instant_loader.cc
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index 9cd55d3a5dfcc19be658c623a785a2cc405c300a..0b1ab8355e5e5bc0b96f52cc472a6d7c07208297 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -698,6 +698,11 @@ bool InstantLoader::Update(TabContents* tab_contents,
if (created_preview_contents)
CreatePreviewContents(tab_contents);
+ // Carry over the user agent override setting to the new entry.
+ content::NavigationEntry* entry =
+ tab_contents->web_contents()->GetController().GetActiveEntry();
+ bool override_user_agent = entry && entry->GetIsOverridingUserAgent();
+
if (template_url) {
DCHECK(template_url_id_ == template_url->id());
if (!created_preview_contents) {
@@ -729,14 +734,17 @@ bool InstantLoader::Update(TabContents* tab_contents,
complete_suggested_text_.substr(user_text_.size());
}
} else {
- LoadInstantURL(template_url, transition_type, user_text_, verbatim);
+ LoadInstantURL(template_url, transition_type, user_text_, verbatim,
+ override_user_agent);
}
} else {
DCHECK(template_url_id_ == 0);
preview_tab_contents_delegate_->PrepareForNewLoad();
frame_load_observer_.reset(NULL);
- preview_contents_->web_contents()->GetController().LoadURL(
- url_, content::Referrer(), transition_type, std::string());
+
+ preview_contents_->web_contents()->GetController().
+ LoadURLWithUserAgentOverride(url_, content::Referrer(), transition_type,
+ false, std::string(), override_user_agent);
}
return true;
}
@@ -860,9 +868,14 @@ void InstantLoader::MaybeLoadInstantURL(TabContents* tab_contents,
if (preview_contents_.get())
return;
+ // Carry over the user agent override setting to the new entry.
+ content::NavigationEntry* entry =
+ tab_contents->web_contents()->GetController().GetActiveEntry();
+ bool override_user_agent = entry && entry->GetIsOverridingUserAgent();
+
CreatePreviewContents(tab_contents);
LoadInstantURL(template_url, content::PAGE_TRANSITION_GENERATED, string16(),
- true);
+ true, override_user_agent);
}
bool InstantLoader::IsNavigationPending() const {
@@ -1107,6 +1120,11 @@ void InstantLoader::SetupPreviewContents(TabContents* tab_contents) {
gfx::Rect tab_bounds;
tab_contents->web_contents()->GetView()->GetContainerBounds(&tab_bounds);
preview_contents_->web_contents()->GetView()->SizeContents(tab_bounds.size());
+
+ // Carry over the user agent override string.
+ const std::string& override =
+ tab_contents->web_contents()->GetUserAgentOverride();
+ preview_contents_->web_contents()->SetUserAgentOverride(override);
}
void InstantLoader::CreatePreviewContents(TabContents* tab_contents) {
@@ -1124,7 +1142,8 @@ void InstantLoader::CreatePreviewContents(TabContents* tab_contents) {
void InstantLoader::LoadInstantURL(const TemplateURL* template_url,
content::PageTransition transition_type,
const string16& user_text,
- bool verbatim) {
+ bool verbatim,
+ bool override_user_agent) {
preview_tab_contents_delegate_->PrepareForNewLoad();
// Load the instant URL. We don't reflect the url we load in url() as
@@ -1140,8 +1159,11 @@ void InstantLoader::LoadInstantURL(const TemplateURL* template_url,
CommandLine* cl = CommandLine::ForCurrentProcess();
if (cl->HasSwitch(switches::kInstantURL))
instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL));
- preview_contents_->web_contents()->GetController().LoadURL(
- instant_url, content::Referrer(), transition_type, std::string());
+
+ preview_contents_->web_contents()->GetController().
+ LoadURLWithUserAgentOverride(instant_url, content::Referrer(),
+ transition_type, false, std::string(), override_user_agent);
+
RenderViewHost* host = preview_contents_->web_contents()->GetRenderViewHost();
preview_contents_->web_contents()->HideContents();

Powered by Google App Engine
This is Rietveld 408576698