зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1437940 - fix where we look for a 'Local State' file for non-release Chrome data, r=dthayer
MozReview-Commit-ID: CXghkKKhHfx --HG-- extra : rebase_source : 8050e98033da4b265c61b7f612f906828b9241e9
This commit is contained in:
Родитель
21074e3307
Коммит
7dd5677adc
|
@ -12,8 +12,6 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
var ChromeMigrationUtils = {
|
||||
_chromeUserDataPath: null,
|
||||
|
||||
_extensionVersionDirectoryNames: {},
|
||||
|
||||
// The cache for the locale strings.
|
||||
|
@ -173,12 +171,13 @@ var ChromeMigrationUtils = {
|
|||
|
||||
/**
|
||||
* Get the local state file content.
|
||||
* @param {String} dataPath the type of Chrome data we're looking for (Chromium, Canary, etc.)
|
||||
* @returns {Object} The JSON-based content.
|
||||
*/
|
||||
async getLocalState() {
|
||||
async getLocalState(dataPath = "Chrome") {
|
||||
let localState = null;
|
||||
try {
|
||||
let localStatePath = OS.Path.join(this.getChromeUserDataPath(), "Local State");
|
||||
let localStatePath = OS.Path.join(this.getDataPath(dataPath), "Local State");
|
||||
let localStateJson = await OS.File.read(localStatePath, { encoding: "utf-8" });
|
||||
localState = JSON.parse(localStateJson);
|
||||
} catch (ex) {
|
||||
|
@ -194,26 +193,16 @@ var ChromeMigrationUtils = {
|
|||
* @returns {String} The path of Chrome extension directory.
|
||||
*/
|
||||
getExtensionPath(profileId) {
|
||||
return OS.Path.join(this.getChromeUserDataPath(), profileId, "Extensions");
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the path of the Chrome user data directory.
|
||||
* @returns {String} The path of the Chrome user data directory.
|
||||
*/
|
||||
getChromeUserDataPath() {
|
||||
if (!this._chromeUserDataPath) {
|
||||
this._chromeUserDataPath = this.getDataPath("Chrome");
|
||||
}
|
||||
return this._chromeUserDataPath;
|
||||
return OS.Path.join(this.getDataPath(), profileId, "Extensions");
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the path of an application data directory.
|
||||
* @param {String} chromeProjectName - The Chrome project name, e.g. "Chrome", "Chromium" or "Canary".
|
||||
* @param {String} chromeProjectName - The Chrome project name, e.g. "Chrome", "Canary", etc.
|
||||
* Defaults to "Chrome".
|
||||
* @returns {String} The path of application data directory.
|
||||
*/
|
||||
getDataPath(chromeProjectName) {
|
||||
getDataPath(chromeProjectName = "Chrome") {
|
||||
const SUB_DIRECTORIES = {
|
||||
win: {
|
||||
Chrome: ["Google", "Chrome"],
|
||||
|
|
|
@ -160,7 +160,7 @@ ChromeProfileMigrator.prototype.getSourceProfiles =
|
|||
|
||||
let profiles = [];
|
||||
try {
|
||||
let localState = await ChromeMigrationUtils.getLocalState();
|
||||
let localState = await ChromeMigrationUtils.getLocalState(this._chromeUserDataPathSuffix);
|
||||
let info_cache = localState.profile.info_cache;
|
||||
for (let profileFolderName in info_cache) {
|
||||
profiles.push({
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
ChromeUtils.import("resource:///modules/ChromeMigrationUtils.jsm");
|
||||
|
||||
// Setup chrome user data path for all platforms.
|
||||
ChromeMigrationUtils.getChromeUserDataPath = () => {
|
||||
ChromeMigrationUtils.getDataPath = () => {
|
||||
return do_get_file("Library/Application Support/Google/Chrome/").path;
|
||||
};
|
||||
|
||||
|
|
|
@ -52,19 +52,6 @@ add_task(async function test_getDataPath_function() {
|
|||
}
|
||||
});
|
||||
|
||||
add_task(async function test_getChromeUserDataPath_function() {
|
||||
let chromeUserDataPath = ChromeMigrationUtils.getChromeUserDataPath();
|
||||
let expectedPath;
|
||||
if (AppConstants.platform == "win") {
|
||||
expectedPath = OS.Path.join(getRootPath(), "Google", "Chrome", "User Data");
|
||||
} else if (AppConstants.platform == "macosx") {
|
||||
expectedPath = OS.Path.join(getRootPath(), "Application Support", "Google", "Chrome");
|
||||
} else {
|
||||
expectedPath = OS.Path.join(getRootPath(), ".config", "google-chrome");
|
||||
}
|
||||
Assert.equal(chromeUserDataPath, expectedPath, "Should get the path of Chrome user data directory.");
|
||||
});
|
||||
|
||||
add_task(async function test_getExtensionPath_function() {
|
||||
let extensionPath = ChromeMigrationUtils.getExtensionPath("Default");
|
||||
let expectedPath;
|
||||
|
|
Загрузка…
Ссылка в новой задаче