2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
|
|
|
|
2009-12-01 15:34:27 +00:00
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
2010-07-13 14:36:09 +00:00
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
2010-06-30 21:29:22 +00:00
|
|
|
|
2011-10-15 20:27:03 +00:00
|
|
|
function BrowserCLH() {}
|
2009-12-01 15:34:27 +00:00
|
|
|
|
|
|
|
BrowserCLH.prototype = {
|
2014-07-23 04:41:53 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-12-01 15:34:27 +00:00
|
|
|
// QI
|
2016-07-21 01:43:34 +00:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
2009-12-01 15:34:27 +00:00
|
|
|
|
|
|
|
// XPCOMUtils factory
|
2011-10-15 20:27:03 +00:00
|
|
|
classID: Components.ID("{be623d20-d305-11de-8a39-0800200c9a66}")
|
2009-12-01 15:34:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var components = [ BrowserCLH ];
|
2012-10-31 16:13:28 +00:00
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
|