Skip to content

Commit

Permalink
general improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Ponchale committed Mar 17, 2024
1 parent 20e37b4 commit 2b8e431
Show file tree
Hide file tree
Showing 30 changed files with 2,054 additions and 1,910 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
/* 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/. */

"use strict";

/* global ExtensionAPI, ExtensionCommon, Services, XPCOMUtils */

const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);

this.BrowserInfo = class extends ExtensionAPI {
getAPI(context) {
const EventManager = ExtensionCommon.EventManager;

return {
BrowserInfo: {
async getDisplayVersion() {
return AppConstants.MOZ_APP_VERSION_DISPLAY;
},
async getAppExecutablePath() {
return Services.dirsvc.get(
"XREExeF",
Ci.nsIFile
).path;
},
async getAppExecutableDirPath() {
return Services.dirsvc.get(
"XREExeF",
Ci.nsIFile
).parent.path;
},
},
};
}
};
/* 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/. */

"use strict";

/* global ExtensionAPI, ExtensionCommon, Services, XPCOMUtils */

const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm",
);

this.BrowserInfo = class extends ExtensionAPI {
getAPI(context) {
const EventManager = ExtensionCommon.EventManager;

return {
BrowserInfo: {
async getDisplayVersion() {
return AppConstants.MOZ_APP_VERSION_DISPLAY;
},
async getAppExecutablePath() {
return Services.dirsvc.get("XREExeF", Ci.nsIFile).path;
},
async getAppExecutableDirPath() {
return Services.dirsvc.get("XREExeF", Ci.nsIFile).parent.path;
},
},
};
}
};
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
[
{
"namespace": "BrowserInfo",
"description": "Get browser info",
"functions": [
{
"name": "getDisplayVersion",
"type": "function",
"description": "Get display version",
"parameters": [],
"async": true
},
{
"name": "getAppExecutablePath",
"type": "function",
"description": "Get app executable path",
"parameters": [],
"async": true
},
{
"name": "getAppExecutableDirPath",
"type": "function",
"description": "Get app executable directory path",
"parameters": [],
"async": true
}
]
}
]
[
{
"namespace": "BrowserInfo",
"description": "Get browser info",
"functions": [
{
"name": "getDisplayVersion",
"type": "function",
"description": "Get display version",
"parameters": [],
"async": true
},
{
"name": "getAppExecutablePath",
"type": "function",
"description": "Get app executable path",
"parameters": [],
"async": true
},
{
"name": "getAppExecutableDirPath",
"type": "function",
"description": "Get app executable directory path",
"parameters": [],
"async": true
}
]
}
]
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
/* 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/. */

"use strict";

/* global ExtensionAPI, ExtensionCommon, Services, XPCOMUtils */

this.IOFile = class extends ExtensionAPI {
getAPI(context) {
const EventManager = ExtensionCommon.EventManager;

Cu.importGlobalProperties(["IOUtils"]);

return {
IOFile: {
async createEmptyFile(path) {
await IOUtils.writeUTF8(path, "");
},
async createDir(path) {
return IOUtils.makeDirectory(path);
},
async exists(path) {
return IOUtils.exists(path);
},
async copyFile(srcPath, destPath) {
return IOUtils.copy(srcPath, destPath);
},
async copyDir(srcPath, destPath) {
return IOUtils.copy(srcPath, destPath, { recursive: true });
},
async move(srcPath, destPath) {
return IOUtils.move(srcPath, destPath);
},
async removeFile(path) {
return IOUtils.remove(path);
},
async removeDir(path) {
return IOUtils.remove(path, { recursive: true });
},
},
};
}
};
/* 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/. */

"use strict";

/* global ExtensionAPI, ExtensionCommon, Services, XPCOMUtils */

this.IOFile = class extends ExtensionAPI {
getAPI(context) {
const EventManager = ExtensionCommon.EventManager;

Cu.importGlobalProperties(["IOUtils"]);

return {
IOFile: {
async createEmptyFile(path) {
await IOUtils.writeUTF8(path, "");
},
async createDir(path) {
return IOUtils.makeDirectory(path);
},
async exists(path) {
return IOUtils.exists(path);
},
async copyFile(srcPath, destPath) {
return IOUtils.copy(srcPath, destPath);
},
async copyDir(srcPath, destPath) {
return IOUtils.copy(srcPath, destPath, { recursive: true });
},
async move(srcPath, destPath) {
return IOUtils.move(srcPath, destPath);
},
async removeFile(path) {
return IOUtils.remove(path);
},
async removeDir(path) {
return IOUtils.remove(path, { recursive: true });
},
},
};
}
};
Loading

0 comments on commit 2b8e431

Please sign in to comment.