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

Unified Diff: webkit/glue/webkit_glue.cc

Issue 340016: Spoof UA as Chrome 1.0 when loading URLs from *.pointroll.com. (Closed)
Patch Set: Nits addressed, good to go. Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webkit_glue.cc
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
index 63bc486ae7b192e7c32a8de74a9c6f5ed49ceb21..9a2d1fd2d508d8213f677f366c09adf99921e179 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.cc
@@ -68,6 +68,7 @@ static const char kDataUrlPattern[] = "data:";
static const std::string::size_type kDataUrlPatternSize =
arraysize(kDataUrlPattern) - 1;
static const char kFileTestPrefix[] = "(file test):";
+static const char kChrome1ProductString[] = "Chrome/1.0.154.53";
}
@@ -322,6 +323,7 @@ struct UserAgentState {
}
std::string user_agent;
+ std::string mimic_chrome1_user_agent;
bool user_agent_requested;
bool user_agent_is_overridden;
};
@@ -381,7 +383,7 @@ std::string BuildOSCpuInfo() {
return os_cpu;
}
-void BuildUserAgent(std::string* result) {
+void BuildUserAgent(bool mimic_chrome1, std::string* result) {
const char kUserAgentPlatform[] =
#if defined(OS_WIN)
"Windows";
@@ -403,13 +405,17 @@ void BuildUserAgent(std::string* result) {
// maximally compatible with Safari, we hope!!
std::string product;
- scoped_ptr<FileVersionInfo> version_info(
- FileVersionInfo::CreateFileVersionInfoForCurrentModule());
- if (version_info.get()) {
- product = "Chrome/" + WideToASCII(version_info->product_version());
+ if (mimic_chrome1) {
+ product = kChrome1ProductString;
} else {
- DLOG(WARNING) << "Unknown product version";
- product = "Chrome/0.0.0.0";
+ scoped_ptr<FileVersionInfo> version_info(
+ FileVersionInfo::CreateFileVersionInfoForCurrentModule());
+ if (version_info.get()) {
+ product = "Chrome/" + WideToASCII(version_info->product_version());
+ } else {
+ DLOG(WARNING) << "Unknown product version";
+ product = "Chrome/0.0.0.0";
+ }
}
// Derived from Safari's UA string.
@@ -430,7 +436,7 @@ void BuildUserAgent(std::string* result) {
}
void SetUserAgentToDefault() {
- BuildUserAgent(&g_user_agent->user_agent);
+ BuildUserAgent(false, &g_user_agent->user_agent);
}
} // namespace
@@ -449,6 +455,18 @@ const std::string& GetUserAgent(const GURL& url) {
if (g_user_agent->user_agent.empty())
SetUserAgentToDefault();
g_user_agent->user_agent_requested = true;
+ if (!g_user_agent->user_agent_is_overridden) {
+ // For cnn.com, which uses pointroll.com to serve their front door promo,
+ // we must spoof Chrome 1.0 in order to avoid blank page due to mis-sniffing
+ // of the UA on the server side (http://crbug.com/25934)
+ // TODO(dglazkov): Remove this once CNN's front door promo is over or when
+ // pointroll fixes their sniffing.
+ if (MatchPattern(url.host(), "*.pointroll.com")) {
+ if (g_user_agent->mimic_chrome1_user_agent.empty())
+ BuildUserAgent(true, &g_user_agent->mimic_chrome1_user_agent);
+ return g_user_agent->mimic_chrome1_user_agent;
+ }
+ }
return g_user_agent->user_agent;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698