summaryrefslogtreecommitdiffstats
path: root/mobile/android/components/BrowserCLH.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /mobile/android/components/BrowserCLH.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'mobile/android/components/BrowserCLH.js')
-rw-r--r--mobile/android/components/BrowserCLH.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/mobile/android/components/BrowserCLH.js b/mobile/android/components/BrowserCLH.js
new file mode 100644
index 000000000..4cbf03554
--- /dev/null
+++ b/mobile/android/components/BrowserCLH.js
@@ -0,0 +1,47 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+function BrowserCLH() {}
+
+BrowserCLH.prototype = {
+ /**
+ * Register resource://android as the APK root.
+ *
+ * Consumers can access Android assets using resource://android/assets/FILENAME.
+ */
+ setResourceSubstitutions: function () {
+ let registry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci["nsIChromeRegistry"]);
+ // Like jar:jar:file:///data/app/org.mozilla.fennec-2.apk!/assets/omni.ja!/chrome/chrome/content/aboutHome.xhtml
+ let url = registry.convertChromeURL(Services.io.newURI("chrome://browser/content/aboutHome.xhtml", null, null)).spec;
+ // Like jar:file:///data/app/org.mozilla.fennec-2.apk!/
+ url = url.substring(4, url.indexOf("!/") + 2);
+
+ let protocolHandler = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandler);
+ protocolHandler.setSubstitution("android", Services.io.newURI(url, null, null));
+ },
+
+ observe: function (subject, topic, data) {
+ switch (topic) {
+ case "app-startup":
+ this.setResourceSubstitutions();
+ break;
+ }
+ },
+
+ // QI
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
+
+ // XPCOMUtils factory
+ classID: Components.ID("{be623d20-d305-11de-8a39-0800200c9a66}")
+};
+
+var components = [ BrowserCLH ];
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);