From 02654b49de7a091294a599e9e74606d1ebd88e48 Mon Sep 17 00:00:00 2001 From: Mark Finkle Date: Fri, 1 Feb 2013 15:21:37 -0500 Subject: [PATCH] Bug 837215 - YouTube video's redirect on play; broken on tablets r=bnicholson --- mobile/android/chrome/content/browser.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index 7512dacd7fd5..a94dc13f08b1 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -2577,6 +2577,7 @@ var LightWeightThemeWebInstaller = { var UserAgent = { DESKTOP_UA: null, + YOUTUBE_DOMAIN: /\.?youtube\.com$/, init: function ua_init() { Services.obs.addObserver(this, "DesktopMode:Change", false); @@ -2633,10 +2634,11 @@ var UserAgent = { if (tab == null) break; - if (/\.?youtube\.com$/.test(channel.URI.host)) { + if (this.YOUTUBE_DOMAIN.test(channel.URI.host)) { let ua = Cc["@mozilla.org/network/protocol;1?name=http"].getService(Ci.nsIHttpProtocolHandler).userAgent; - if (ua.indexOf("Android; Tablet;") !== -1) { - ua = ua.replace("Android; Tablet;", "Android; Mobile;"); + // Send the phone UA to youtube if this is a tablet + if (ua.indexOf("Android; Mobile;") === -1) { + ua = ua.replace("Android;", "Android; Mobile;"); channel.setRequestHeader("User-Agent", ua, false); } }