зеркало из https://github.com/mozilla/gecko-dev.git
Bug 948465 - Part 1: Register resource://android/ pointing to Fennec APK root. r=mfinkle
Consumers can access Android assets (and resources) by using resource://android/assets/FILENAME. The resource substitution is registered at app-startup time so that the substitution is in place before any add-on has started up: as documented at [1], "[an] add-on will not receive xpcom-startup or app-startup notifications". [1] https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Guide/Receiving_startup_notifications
This commit is contained in:
Родитель
5117d11359
Коммит
16a27e624a
|
@ -119,8 +119,33 @@ 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.nsICommandLineHandler]),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler,
|
||||
Ci.nsIObserver]),
|
||||
|
||||
// XPCOMUtils factory
|
||||
classID: Components.ID("{be623d20-d305-11de-8a39-0800200c9a66}")
|
||||
|
|
|
@ -66,6 +66,7 @@ category wakeup-request PromptService @mozilla.org/embedcomp/prompt-service;1,ns
|
|||
component {be623d20-d305-11de-8a39-0800200c9a66} BrowserCLH.js application={aa3c5121-dab2-40e2-81ca-7ea25febc110}
|
||||
contract @mozilla.org/browser/browser-clh;1 {be623d20-d305-11de-8a39-0800200c9a66}
|
||||
category command-line-handler x-browser @mozilla.org/browser/browser-clh;1
|
||||
category app-startup BrowserCLH @mozilla.org/browser/browser-clh;1
|
||||
|
||||
# ContentDispatchChooser.js
|
||||
component {5a072a22-1e66-4100-afc1-07aed8b62fc5} ContentDispatchChooser.js
|
||||
|
|
Загрузка…
Ссылка в новой задаче