mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 791039 part 1: Factorize code executed after system app install. (onAppsLoaded
function) [r=vingtetun]
--HG-- extra : rebase_source : e0fd524a16500c56c578945c1bee1084071eba2c
This commit is contained in:
parent
d4a35a86bb
commit
43e8222ee2
@ -176,88 +176,87 @@ let DOMApplicationRegistry = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Implements the core of bug 787439
|
// Implements the core of bug 787439
|
||||||
// 1. load the apps from the current registry.
|
// if at first run, go through these steps:
|
||||||
// 2. if at first run, go through these steps:
|
|
||||||
// a. load the core apps registry.
|
// a. load the core apps registry.
|
||||||
// b. uninstall any core app from the current registry but not in the
|
// b. uninstall any core app from the current registry but not in the
|
||||||
// new core apps registry.
|
// new core apps registry.
|
||||||
// c. for all apps in the new core registry, install them if they are not
|
// c. for all apps in the new core registry, install them if they are not
|
||||||
// yet in the current registry, and run installPermissions()
|
// yet in the current registry, and run installPermissions()
|
||||||
|
installSystemApps: function installSystemApps(aNext) {
|
||||||
|
let file;
|
||||||
|
try {
|
||||||
|
file = FileUtils.getFile("coreAppsDir", ["webapps", "webapps.json"], false);
|
||||||
|
} catch(e) { }
|
||||||
|
|
||||||
|
if (file && file.exists()) {
|
||||||
|
// a
|
||||||
|
this._loadJSONAsync(file, (function loadCoreRegistry(aData) {
|
||||||
|
if (!aData) {
|
||||||
|
aNext();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// b : core apps are not removable.
|
||||||
|
for (let id in this.webapps) {
|
||||||
|
if (id in aData || this.webapps[id].removable)
|
||||||
|
continue;
|
||||||
|
delete this.webapps[id];
|
||||||
|
// Remove the permissions, cookies and private data for this app.
|
||||||
|
let localId = this.webapps[id].localId;
|
||||||
|
let permMgr = Cc["@mozilla.org/permissionmanager;1"]
|
||||||
|
.getService(Ci.nsIPermissionManager);
|
||||||
|
permMgr.RemovePermissionsForApp(localId);
|
||||||
|
Services.cookies.removeCookiesForApp(localId, false);
|
||||||
|
this._clearPrivateData(localId, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
let appDir = FileUtils.getDir("coreAppsDir", ["webapps"], false);
|
||||||
|
// c
|
||||||
|
for (let id in aData) {
|
||||||
|
// Core apps have ids matching their domain name (eg: dialer.gaiamobile.org)
|
||||||
|
// Use that property to check if they are new or not.
|
||||||
|
if (!(id in this.webapps)) {
|
||||||
|
this.webapps[id] = aData[id];
|
||||||
|
this.webapps[id].basePath = appDir.path;
|
||||||
|
|
||||||
|
// Create a new localId.
|
||||||
|
this.webapps[id].localId = this._nextLocalId();
|
||||||
|
|
||||||
|
// Core apps are not removable.
|
||||||
|
if (this.webapps[id].removable === undefined) {
|
||||||
|
this.webapps[id].removable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aNext();
|
||||||
|
}).bind(this));
|
||||||
|
} else {
|
||||||
|
aNext();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
loadAndUpdateApps: function loadAndUpdateApps() {
|
loadAndUpdateApps: function loadAndUpdateApps() {
|
||||||
let runUpdate = AppsUtils.isFirstRun(Services.prefs);
|
let runUpdate = AppsUtils.isFirstRun(Services.prefs);
|
||||||
|
|
||||||
// 1.
|
let onAppsLoaded = (function onAppsLoaded() {
|
||||||
this.loadCurrentRegistry((function() {
|
if (runUpdate) {
|
||||||
#ifdef MOZ_WIDGET_GONK
|
// At first run, set up the permissions
|
||||||
// if first run, merge the system apps.
|
|
||||||
if (runUpdate) {
|
|
||||||
let file;
|
|
||||||
try {
|
|
||||||
file = FileUtils.getFile("coreAppsDir", ["webapps", "webapps.json"], false);
|
|
||||||
} catch(e) { }
|
|
||||||
|
|
||||||
if (file && file.exists()) {
|
|
||||||
// 2.a
|
|
||||||
this._loadJSONAsync(file, (function loadCoreRegistry(aData) {
|
|
||||||
if (!aData) {
|
|
||||||
this.registerAppsHandlers();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2.b : core apps are not removable.
|
|
||||||
for (let id in this.webapps) {
|
|
||||||
if (id in aData || this.webapps[id].removable)
|
|
||||||
continue;
|
|
||||||
delete this.webapps[id];
|
|
||||||
// Remove the permissions, cookies and private data for this app.
|
|
||||||
let localId = this.webapps[id].localId;
|
|
||||||
let permMgr = Cc["@mozilla.org/permissionmanager;1"]
|
|
||||||
.getService(Ci.nsIPermissionManager);
|
|
||||||
permMgr.RemovePermissionsForApp(localId);
|
|
||||||
Services.cookies.removeCookiesForApp(localId, false);
|
|
||||||
this._clearPrivateData(localId, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
let appDir = FileUtils.getDir("coreAppsDir", ["webapps"], false);
|
|
||||||
// 2.c
|
|
||||||
for (let id in aData) {
|
|
||||||
// Core apps have ids matching their domain name (eg: dialer.gaiamobile.org)
|
|
||||||
// Use that property to check if they are new or not.
|
|
||||||
if (!(id in this.webapps)) {
|
|
||||||
this.webapps[id] = aData[id];
|
|
||||||
this.webapps[id].basePath = appDir.path;
|
|
||||||
|
|
||||||
// Create a new localId.
|
|
||||||
this.webapps[id].localId = this._nextLocalId();
|
|
||||||
|
|
||||||
// Core apps are not removable.
|
|
||||||
if (this.webapps[id].removable === undefined) {
|
|
||||||
this.webapps[id].removable = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updatePermissionsForApp(id);
|
|
||||||
}
|
|
||||||
this.registerAppsHandlers();
|
|
||||||
}).bind(this));
|
|
||||||
} else {
|
|
||||||
// At first run, set up the permissions for eng builds.
|
|
||||||
for (let id in this.webapps) {
|
for (let id in this.webapps) {
|
||||||
this.updatePermissionsForApp(id);
|
this.updatePermissionsForApp(id);
|
||||||
}
|
}
|
||||||
this.registerAppsHandlers();
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.registerAppsHandlers();
|
this.registerAppsHandlers();
|
||||||
}
|
}).bind(this);
|
||||||
|
|
||||||
|
this.loadCurrentRegistry((function() {
|
||||||
|
#ifdef MOZ_WIDGET_GONK
|
||||||
|
// if first run, merge the system apps.
|
||||||
|
if (runUpdate)
|
||||||
|
this.installSystemApps(onAppsLoaded);
|
||||||
|
else
|
||||||
|
onAppsLoaded();
|
||||||
#else
|
#else
|
||||||
if (runUpdate) {
|
onAppsLoaded();
|
||||||
// At first run, set up the permissions for desktop builds.
|
|
||||||
for (let id in this.webapps) {
|
|
||||||
this.updatePermissionsForApp(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.registerAppsHandlers();
|
|
||||||
#endif
|
#endif
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user