| Index: webkit/glue/webkit_glue.cc
|
| diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
|
| index 5e47fe4ee986e7a00b176f8b2b7f24db7f4e6fb7..ef2702af8e0320f98cfa411e66339699f9d0dd99 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_;
|
|
|