mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 12:55:46 +00:00
Bug 914843 - fix b2g DirectoryProvider on desktop r=gwagner
This commit is contained in:
parent
6425689436
commit
62fd805ab4
@ -322,6 +322,9 @@ var shell = {
|
||||
ppmm.addMessageListener("mail-handler", this);
|
||||
ppmm.addMessageListener("app-notification-send", AlertsHelper);
|
||||
ppmm.addMessageListener("file-picker", this);
|
||||
ppmm.addMessageListener("getProfD", function(message) {
|
||||
return Services.dirsvc.get("ProfD", Ci.nsIFile).path;
|
||||
});
|
||||
},
|
||||
|
||||
stop: function shell_stop() {
|
||||
|
@ -28,6 +28,10 @@ XPCOMUtils.defineLazyServiceGetter(Services, "volumeService",
|
||||
"@mozilla.org/telephony/volume-service;1",
|
||||
"nsIVolumeService");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsISyncMessageSender");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gExtStorage", function dp_gExtStorage() {
|
||||
return Services.env.get("EXTERNAL_STORAGE");
|
||||
});
|
||||
@ -50,6 +54,8 @@ DirectoryProvider.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider]),
|
||||
_xpcom_factory: XPCOMUtils.generateSingletonFactory(DirectoryProvider),
|
||||
|
||||
_profD: null,
|
||||
|
||||
getFile: function dp_getFile(prop, persistent) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
let localProps = ["cachePDir", "webappsDir", "PrefD", "indexedDBPDir",
|
||||
@ -88,6 +94,31 @@ DirectoryProvider.prototype = {
|
||||
// of the sdcard.
|
||||
return this.getUpdateDir(persistent, FOTA_DIR);
|
||||
}
|
||||
#else
|
||||
// In desktop builds, coreAppsDir is the same as the profile directory.
|
||||
// We just need to get the path from the parent, and it is then used to
|
||||
// build jar:remoteopenfile:// uris.
|
||||
if (prop == "coreAppsDir") {
|
||||
let appsDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
appsDir.append("webapps");
|
||||
persistent.value = true;
|
||||
return appsDir;
|
||||
} else if (prop == "ProfD") {
|
||||
let inParent = Cc["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Ci.nsIXULRuntime)
|
||||
.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
if (inParent) {
|
||||
// Just bail out to use the default from toolkit.
|
||||
return null;
|
||||
}
|
||||
if (!this._profD) {
|
||||
this._profD = cpmm.sendSyncMessage("getProfD", {})[0];
|
||||
}
|
||||
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
||||
file.initWithPath(this._profD);
|
||||
persistent.value = true;
|
||||
return file;
|
||||
}
|
||||
#endif
|
||||
return null;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user