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

Unified Diff: webkit/glue/webkit_glue.cc

Issue 8590022: Work around wrong UA sniffing by Yahoo! JAPAN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 5e47fe4ee986e7a00b176f8b2b7f24db7f4e6fb7..79919e4bb834ea19d5517e2b5a519fb20d7a70a3 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.cc
@@ -350,8 +350,11 @@ class UserAgentState {
private:
mutable std::string user_agent_;
- // The UA string when we're pretending to be Mac Safari.
- mutable std::string mimic_mac_safari_user_agent_;
+
+#if defined(OS_MACOSX) || defined(OS_WIN)
stuartmorgan 2011/11/17 09:59:17 Don't needlessly if-def things that are meaningful
Yuzo 2011/11/17 10:32:02 I have no strong opinions about this. If Tony also
stuartmorgan 2011/11/17 10:50:38 The concept of a UA hack is meaningful on Linux (a
tony 2011/11/17 18:13:06 I agree with Stuart. Fewer #ifs are better.
Yuzo 2011/11/18 07:31:44 Done.
+ // The UA string when we're pretending to be Mac Safari or Win Firefox.
+ mutable std::string user_agent_for_spoofing_hack_;
+#endif
mutable bool user_agent_requested_;
bool user_agent_is_overridden_;
@@ -384,6 +387,33 @@ void UserAgentState::Set(const std::string& user_agent, bool overriding) {
user_agent_ = user_agent;
}
+#if defined(OS_MACOSX) || defined(OS_WIN)
+bool ShouldSpoofUAHack(const GURL& url) {
+ return
stuartmorgan 2011/11/17 09:59:17 Breaking the statement into a bunch of ifdef'd pie
Yuzo 2011/11/17 10:32:02 I have no strong opinion on this either. Let's wai
tony 2011/11/17 18:13:06 I agree with Stuart here too. The current form is
Yuzo 2011/11/18 07:31:44 Done.
+#if defined(OS_MACOSX)
+ // The landing page for updating Silverlight gives a confusing experience
+ // in browsers that Silverlight doesn't officially support; spoof as
+ // Safari to reduce the chance that users won't complete updates.
+ // Should be removed if the sniffing is removed: http://crbug.com/88211
+ (url.host() == "www.microsoft.com" &&
+ StartsWithASCII(url.path(), "/getsilverlight", false)) ||
+
+ // The following Yahoo! JAPAN pages erroneously judge that Chromium does
+ // not support Silverlight. Until the pages are fixed, spoof the UA.
+ // http://crbug.com/104426
+ (url.host() == "downloads.yahoo.co.jp" &&
+ StartsWithASCII(url.path(), "/docs/silverlight/", true)) ||
+ url.host() == "gyao.yahoo.co.jp" ||
+#elif defined(OS_WIN)
+ (url.host() == "weather.yahoo.co.jp" &&
+ StartsWithASCII(url.path(), "/weather/zoomradar/", true)) ||
+ url.host() == "promotion.shopping.yahoo.co.jp" ||
+#endif
+ (url.host() == "headlines.yahoo.co.jp" &&
+ StartsWithASCII(url.path(), "/videonews/", true));
stuartmorgan 2011/11/17 09:59:17 So... on Windows you spoof this page as Windows Fi
Yuzo 2011/11/17 10:32:02 Silverlight is not supported on Linux. I don't kno
stuartmorgan 2011/11/17 10:50:38 Please add a comment explaining why you are using
Yuzo 2011/11/18 07:31:44 Done.
+}
+#endif
+
const std::string& UserAgentState::Get(const GURL& url) const {
base::AutoLock auto_lock(lock_);
user_agent_requested_ = true;
@@ -392,18 +422,18 @@ const std::string& UserAgentState::Get(const GURL& url) const {
// Workarounds for sites that use misguided UA sniffing.
if (!user_agent_is_overridden_) {
+#if defined(OS_MACOSX) || defined(OS_WIN)
+ if (ShouldSpoofUAHack(url)) {
stuartmorgan 2011/11/17 09:59:17 I really don't like adding code that appears to be
Yuzo 2011/11/17 10:32:02 I'm not pretending anything -- I've just extracted
stuartmorgan 2011/11/17 10:50:38 My point is that the refactoring suggests that the
Yuzo 2011/11/18 07:31:44 Done.
+ if (user_agent_for_spoofing_hack_.empty()) {
+ user_agent_for_spoofing_hack_ =
#if defined(OS_MACOSX)
- if (url.host() == "www.microsoft.com" &&
- StartsWithASCII(url.path(), "/getsilverlight", false)) {
- // The landing page for updating Silverlight gives a confusing experience
- // in browsers that Silverlight doesn't officially support; spoof as
- // Safari to reduce the chance that users won't complete updates.
- // Should be removed if the sniffing is removed: http://crbug.com/88211
- if (mimic_mac_safari_user_agent_.empty()) {
- mimic_mac_safari_user_agent_ =
BuildUserAgentFromProduct("Version/5.0.4 Safari/533.20.27");
+#elif defined(OS_WIN)
+ "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 "
+ "Firefox/8.0";
tony 2011/11/17 18:13:06 Does Safari Win not work?
Yuzo 2011/11/18 07:31:44 No, it doesn't. Added a comment.
+#endif
}
- return mimic_mac_safari_user_agent_;
+ return user_agent_for_spoofing_hack_;
}
#endif
}
« 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