Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bug 766914 - Unable to play videos on mobile YouTube; redirection loo…

…p on 'Play' r=blassey a=blassey

--HG--
branch : MOBILE140_2012061216_RELBRANCH
  • Loading branch information...
commit 91540a02c13b7077c81e002349459668189a2d80 1 parent 9534306
@mfinkle mfinkle authored
Showing with 52 additions and 23 deletions.
  1. +52 −23 mobile/android/chrome/content/browser.js
View
75 mobile/android/chrome/content/browser.js
@@ -235,6 +235,7 @@ var BrowserApp = {
ActivityObserver.init();
WebappsUI.init();
RemoteDebugger.init();
+ UserAgent.init();
// Init LoginManager
Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
@@ -434,6 +435,7 @@ var BrowserApp = {
SearchEngines.uninit();
WebappsUI.uninit();
RemoteDebugger.uninit();
+ UserAgent.uninit();
},
// This function returns false during periods where the browser displayed document is
@@ -1432,6 +1434,56 @@ var NativeWindow = {
};
+var UserAgent = {
+ init: function ua_init() {
+ Services.obs.addObserver(this, "http-on-modify-request", false);
+ },
+
+ uninit: function ua_uninit() {
+ Services.obs.removeObserver(this, "http-on-modify-request");
+ },
+
+ getRequestLoadContext: function ua_getRequestLoadContext(aRequest) {
+ if (aRequest && aRequest.notificationCallbacks) {
+ try {
+ return aRequest.notificationCallbacks.getInterface(Ci.nsILoadContext);
+ } catch (ex) { }
+ }
+
+ if (aRequest && aRequest.loadGroup && aRequest.loadGroup.notificationCallbacks) {
+ try {
+ return aRequest.loadGroup.notificationCallbacks.getInterface(Ci.nsILoadContext);
+ } catch (ex) { }
+ }
+
+ return null;
+ },
+
+ getWindowForRequest: function ua_getWindowForRequest(aRequest) {
+ let loadContext = this.getRequestLoadContext(aRequest);
+ if (loadContext)
+ return loadContext.associatedWindow;
+ return null;
+ },
+
+ observe: function ua_observe(aSubject, aTopic, aData) {
+ if (!(aSubject instanceof Ci.nsIHttpChannel))
+ return;
+
+ let channel = aSubject.QueryInterface(Ci.nsIHttpChannel);
+ let channelWindow = this.getWindowForRequest(channel);
+ if (BrowserApp.getBrowserForWindow(channelWindow)) {
+ if (channel.URI.host.indexOf("youtube") != -1) {
+ let ua = Cc["@mozilla.org/network/protocol;1?name=http"].getService(Ci.nsIHttpProtocolHandler).userAgent;
+#expand let version = "__MOZ_APP_VERSION__";
+ ua += " Fennec/" + version;
+ channel.setRequestHeader("User-Agent", ua, false);
+ }
+ }
+ }
+};
+
+
function nsBrowserAccess() {
}
@@ -2511,29 +2563,6 @@ Tab.prototype = {
return zoom;
},
- getRequestLoadContext: function(aRequest) {
- if (aRequest && aRequest.notificationCallbacks) {
- try {
- return aRequest.notificationCallbacks.getInterface(Ci.nsILoadContext);
- } catch (ex) { }
- }
-
- if (aRequest && aRequest.loadGroup && aRequest.loadGroup.notificationCallbacks) {
- try {
- return aRequest.loadGroup.notificationCallbacks.getInterface(Ci.nsILoadContext);
- } catch (ex) { }
- }
-
- return null;
- },
-
- getWindowForRequest: function(aRequest) {
- let loadContext = this.getRequestLoadContext(aRequest);
- if (loadContext)
- return loadContext.associatedWindow;
- return null;
- },
-
observe: function(aSubject, aTopic, aData) {
switch (aTopic) {
case "before-first-paint":
Please sign in to comment.
Something went wrong with that request. Please try again.