-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FB] PWA | Save data to external file
- Loading branch information
1 parent
f9014e5
commit 8616ea7
Showing
4 changed files
with
202 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
browser/components/ssb/SiteSpecificBrowserExternalFileService.jsm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* 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"; | ||
|
||
const EXPORTED_SYMBOLS = ["SiteSpecificBrowserExternalFileService"]; | ||
|
||
let SiteSpecificBrowserExternalFileService = { | ||
get _saveFile() { | ||
return PathUtils.join(PathUtils.profileDir, "ssb.json"); | ||
}, | ||
|
||
async getCurrentSsbData() { | ||
let fileExists = await IOUtils.exists(this._saveFile); | ||
if (!fileExists) { | ||
IOUtils.writeJSON(this._saveFile, {}); | ||
return {}; | ||
}; | ||
|
||
let result = await IOUtils.readJSON( | ||
this._saveFile | ||
); | ||
|
||
return result; | ||
}, | ||
|
||
async saveSsbData(ssbData) { | ||
await IOUtils.writeJSON(this._saveFile, ssbData); | ||
}, | ||
|
||
get _saveSsbMap() { | ||
return PathUtils.join(PathUtils.profileDir, "ssb-map.json"); | ||
}, | ||
|
||
async ssbMapFileExists() { | ||
let fileExists = await IOUtils.exists(this._saveSsbMap); | ||
return fileExists; | ||
}, | ||
|
||
async getSsbMapData() { | ||
let fileExists = await IOUtils.exists(this._saveSsbMap); | ||
if (!fileExists) { | ||
IOUtils.writeJSON(this._saveSsbMap, {}); | ||
return null; | ||
}; | ||
|
||
let result = await IOUtils.readUTF8( | ||
this._saveSsbMap | ||
); | ||
|
||
return result; | ||
}, | ||
|
||
async saveSsbMapData(ssbMapData) { | ||
await IOUtils.writeJSON(this._saveSsbMap, ssbMapData); | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters