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

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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/instant/instant_loader.h ('k') | chrome/browser/prerender/prerender_config.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/instant/instant_loader.cc
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index a3667bbaf562a707ea7a5681918cd2e468444759..460f34357a2588fc3f633f54fa76428f496d9b70 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -702,6 +702,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) {
@@ -733,14 +738,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;
}
@@ -864,9 +872,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 {
@@ -1111,6 +1124,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) {
@@ -1128,7 +1146,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
@@ -1144,8 +1163,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();
« no previous file with comments | « chrome/browser/instant/instant_loader.h ('k') | chrome/browser/prerender/prerender_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698