Bug 1021156 - Re-enable activity handlers for OMA downloads. r=vingtetun
authorAntonio M. Amaya <amac@tid.es>
Tue, 17 Jun 2014 09:44:00 -0400
changeset 210166 7c41391a9bc7cdbbed3a2cc054676b1d162aaeb6
parent 210165 bfc6270f98fe47d8be2caad04b642b5988d44d75
child 210167 9f9558ad73e9c46b603b9c670aa5909e6d13f945
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvingtetun
bugs1021156
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1021156 - Re-enable activity handlers for OMA downloads. r=vingtetun
b2g/components/B2GComponents.manifest
b2g/components/OMAContentHandler.js
b2g/components/moz.build
b2g/installer/package-manifest.in
--- a/b2g/components/B2GComponents.manifest
+++ b/b2g/components/B2GComponents.manifest
@@ -32,16 +32,20 @@ contract @mozilla.org/dom/apps/inter-app
 component {2846f034-e614-11e3-93cd-74d02b97e723} SystemMessageGlue.js
 contract @mozilla.org/dom/messages/system-message-glue;1 {2846f034-e614-11e3-93cd-74d02b97e723}
 
 # ProcessGlobal.js
 component {1a94c87a-5ece-4d11-91e1-d29c29f21b28} ProcessGlobal.js
 contract @mozilla.org/b2g-process-global;1 {1a94c87a-5ece-4d11-91e1-d29c29f21b28}
 category app-startup ProcessGlobal service,@mozilla.org/b2g-process-global;1
 
+# OMAContentHandler.js
+component {a6b2ab13-9037-423a-9897-dde1081be323} OMAContentHandler.js
+contract @mozilla.org/uriloader/content-handler;1?type=application/vnd.oma.drm.message {a6b2ab13-9037-423a-9897-dde1081be323}
+
 # PaymentGlue.js
 component {8b83eabc-7929-47f4-8b48-4dea8d887e4b} PaymentGlue.js
 contract @mozilla.org/payment/ui-glue;1 {8b83eabc-7929-47f4-8b48-4dea8d887e4b}
 
 # TelProtocolHandler.js
 component {782775dd-7351-45ea-aff1-0ffa872cfdd2} TelProtocolHandler.js
 contract @mozilla.org/network/protocol;1?name=tel {782775dd-7351-45ea-aff1-0ffa872cfdd2}
 
new file mode 100644
--- /dev/null
+++ b/b2g/components/OMAContentHandler.js
@@ -0,0 +1,57 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
+
+"use strict";
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cr = Components.results;
+const Cu = Components.utils;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
+  return Cc["@mozilla.org/childprocessmessagemanager;1"]
+           .getService(Ci.nsIMessageSender);
+});
+
+function debug(aMsg) {
+  //dump("--*-- OMAContentHandler: " + aMsg + "\n");
+}
+
+const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
+
+function OMAContentHandler() {
+}
+
+OMAContentHandler.prototype = {
+  classID: Components.ID("{a6b2ab13-9037-423a-9897-dde1081be323}"),
+
+  _xpcom_factory: {
+    createInstance: function createInstance(outer, iid) {
+      if (outer != null) {
+        throw Cr.NS_ERROR_NO_AGGREGATION;
+      }
+      return new OMAContentHandler().QueryInterface(iid);
+    }
+  },
+
+  handleContent: function handleContent(aMimetype, aContext, aRequest) {
+    if (!(aRequest instanceof Ci.nsIChannel)) {
+      throw NS_ERROR_WONT_HANDLE_CONTENT;
+    }
+
+    let detail = {
+      "type": aMimetype,
+      "url": aRequest.URI.spec
+    };
+    cpmm.sendAsyncMessage("content-handler", detail);
+
+    aRequest.cancel(Cr.NS_BINDING_ABORTED);
+  },
+
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentHandler])
+}
+
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([OMAContentHandler]);
--- a/b2g/components/moz.build
+++ b/b2g/components/moz.build
@@ -11,16 +11,17 @@ EXTRA_COMPONENTS += [
     'AlertsService.js',
     'B2GAboutRedirector.js',
     'ContentPermissionPrompt.js',
     'FilePicker.js',
     'HelperAppDialog.js',
     'InterAppCommUIGlue.js',
     'MailtoProtocolHandler.js',
     'MobileIdentityUIGlue.js',
+    'OMAContentHandler.js',
     'PaymentGlue.js',
     'ProcessGlobal.js',
     'SmsProtocolHandler.js',
     'SystemMessageGlue.js',
     'TelProtocolHandler.js',
     'WebappsUpdateTimer.js',
     'YoutubeProtocolHandler.js',
 ]
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -798,17 +798,17 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DL
 @BINPATH@/components/ContentPermissionPrompt.js
 #ifdef MOZ_UPDATER
 @BINPATH@/components/UpdatePrompt.js
 #endif
 @BINPATH@/components/WebappsUpdateTimer.js
 @BINPATH@/components/DirectoryProvider.js
 @BINPATH@/components/ActivitiesGlue.js
 @BINPATH@/components/ProcessGlobal.js
-@BINPATH@/components/ContentHandler.js
+@BINPATH@/components/OMAContentHandler.js
 @BINPATH@/components/PaymentGlue.js
 @BINPATH@/components/YoutubeProtocolHandler.js
 @BINPATH@/components/RecoveryService.js
 @BINPATH@/components/MailtoProtocolHandler.js
 @BINPATH@/components/SmsProtocolHandler.js
 @BINPATH@/components/TelProtocolHandler.js
 @BINPATH@/components/B2GAboutRedirector.js
 @BINPATH@/components/FilePicker.js