summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webkit_glue.cc
diff options
context:
space:
mode:
authoryuzo@chromium.org <yuzo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 05:43:00 +0000
committeryuzo@chromium.org <yuzo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 05:43:00 +0000
commit528cdac52a855644b621a0bcedf3c0684805091c (patch)
treec4eac10ebcf7928435e504402d8c6a18ee0c8253 /webkit/glue/webkit_glue.cc
parentee61137f403470aebd9793c8ab047a7422b21554 (diff)
downloadchromium_src-528cdac52a855644b621a0bcedf3c0684805091c.zip
chromium_src-528cdac52a855644b621a0bcedf3c0684805091c.tar.gz
chromium_src-528cdac52a855644b621a0bcedf3c0684805091c.tar.bz2
Work around wrong UA sniffing by Yahoo! JAPAN
Some Yahoo! JAPAN pages sniff UA wrongly and reject Chrome, misjudging that Silverlight is not supported. Work around this issue by spoofing the UA as Safari on Mac and Firefox on Win for the pages. See the bug below for the justification. This workaround should be removed once the pages are fixed. BUG=104426 TEST=Open the URLs listed in the bug Review URL: http://codereview.chromium.org/8590022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111877 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webkit_glue.cc')
-rw-r--r--webkit/glue/webkit_glue.cc66
1 files changed, 53 insertions, 13 deletions
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
index 5e47fe4..ef2702a 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.cc
@@ -350,8 +350,8 @@ 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_;
+ // The UA string when we're pretending to be Mac Safari or Win Firefox.
+ mutable std::string user_agent_for_spoofing_hack_;
mutable bool user_agent_requested_;
bool user_agent_is_overridden_;
@@ -384,6 +384,44 @@ void UserAgentState::Set(const std::string& user_agent, bool overriding) {
user_agent_ = user_agent;
}
+bool IsMicrosoftSiteThatNeedsSpoofingForSilverlight(const GURL& url) {
+#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
+ if (url.host() == "www.microsoft.com" &&
+ StartsWithASCII(url.path(), "/getsilverlight", false)) {
+ return true;
+ }
+#endif
+ return false;
+}
+
+bool IsYahooSiteThatNeedsSpoofingForSilverlight(const GURL& url) {
+ // The following Yahoo! JAPAN pages erroneously judge that Silverlight does
+ // not support Chromium. Until the pages are fixed, spoof the UA.
+ // http://crbug.com/104426
+ if (url.host() == "headlines.yahoo.co.jp" &&
+ StartsWithASCII(url.path(), "/videonews/", true)) {
+ return true;
+ }
+#if defined(OS_MACOSX)
+ if ((url.host() == "downloads.yahoo.co.jp" &&
+ StartsWithASCII(url.path(), "/docs/silverlight/", true)) ||
+ url.host() == "gyao.yahoo.co.jp") {
+ return true;
+ }
+#elif defined(OS_WIN)
+ if ((url.host() == "weather.yahoo.co.jp" &&
+ StartsWithASCII(url.path(), "/weather/zoomradar/", true)) ||
+ url.host() == "promotion.shopping.yahoo.co.jp") {
+ return true;
+ }
+#endif
+ return false;
+}
+
const std::string& UserAgentState::Get(const GURL& url) const {
base::AutoLock auto_lock(lock_);
user_agent_requested_ = true;
@@ -392,20 +430,22 @@ const std::string& UserAgentState::Get(const GURL& url) const {
// Workarounds for sites that use misguided UA sniffing.
if (!user_agent_is_overridden_) {
+ if (IsMicrosoftSiteThatNeedsSpoofingForSilverlight(url) ||
+ IsYahooSiteThatNeedsSpoofingForSilverlight(url)) {
+ if (user_agent_for_spoofing_hack_.empty()) {
#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");
+ user_agent_for_spoofing_hack_ =
+ BuildUserAgentFromProduct("Version/5.1.1 Safari/534.51.22");
+#elif defined(OS_WIN)
+ // Pretend to be Firefox. Silverlight doesn't support Win Safari.
+ base::StringAppendF(
+ &user_agent_for_spoofing_hack_,
+ "Mozilla/5.0 (%s) Gecko/20100101 Firefox/8.0",
+ webkit_glue::BuildOSCpuInfo().c_str());
+#endif
}
- return mimic_mac_safari_user_agent_;
+ return user_agent_for_spoofing_hack_;
}
-#endif
}
return user_agent_;