mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 860782 - Move Android permission install to first run, from install. r=wesj, r=fabrice
* * * Bug 860782 - Use app when requesting permissions. r=mfinkle * * * Bug 860782 - Disable permissions tests on platforms where they shouldn't work. r=mfinkle
This commit is contained in:
parent
7771020b67
commit
fd318a565f
@ -258,6 +258,8 @@ this.DOMApplicationRegistry = {
|
|||||||
|
|
||||||
// Install the permissions for this app, as if we were updating
|
// Install the permissions for this app, as if we were updating
|
||||||
// to cleanup the old ones if needed.
|
// to cleanup the old ones if needed.
|
||||||
|
// TODO It's not clear what this should do when there are multiple profiles.
|
||||||
|
#ifdef MOZ_B2G
|
||||||
this._readManifests([{ id: aId }], (function(aResult) {
|
this._readManifests([{ id: aId }], (function(aResult) {
|
||||||
let data = aResult[0];
|
let data = aResult[0];
|
||||||
PermissionsInstaller.installPermissions({
|
PermissionsInstaller.installPermissions({
|
||||||
@ -268,6 +270,7 @@ this.DOMApplicationRegistry = {
|
|||||||
debug("Error installing permissions for " + aId);
|
debug("Error installing permissions for " + aId);
|
||||||
});
|
});
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
|
#endif
|
||||||
},
|
},
|
||||||
|
|
||||||
updateOfflineCacheForApp: function updateOfflineCacheForApp(aId) {
|
updateOfflineCacheForApp: function updateOfflineCacheForApp(aId) {
|
||||||
@ -1237,11 +1240,13 @@ this.DOMApplicationRegistry = {
|
|||||||
this._saveApps((function() {
|
this._saveApps((function() {
|
||||||
// Update the handlers and permissions for this app.
|
// Update the handlers and permissions for this app.
|
||||||
this.updateAppHandlers(aOldManifest, aData, app);
|
this.updateAppHandlers(aOldManifest, aData, app);
|
||||||
|
#ifdef MOZ_B2G
|
||||||
PermissionsInstaller.installPermissions(
|
PermissionsInstaller.installPermissions(
|
||||||
{ manifest: aData,
|
{ manifest: aData,
|
||||||
origin: app.origin,
|
origin: app.origin,
|
||||||
manifestURL: app.manifestURL },
|
manifestURL: app.manifestURL },
|
||||||
true);
|
true);
|
||||||
|
#endif
|
||||||
this.broadcastMessage("Webapps:PackageEvent",
|
this.broadcastMessage("Webapps:PackageEvent",
|
||||||
{ type: "applied",
|
{ type: "applied",
|
||||||
manifestURL: app.manifestURL,
|
manifestURL: app.manifestURL,
|
||||||
@ -1462,13 +1467,14 @@ this.DOMApplicationRegistry = {
|
|||||||
this._writeFile(manFile, JSON.stringify(aNewManifest), function() { });
|
this._writeFile(manFile, JSON.stringify(aNewManifest), function() { });
|
||||||
manifest = new ManifestHelper(aNewManifest, app.origin);
|
manifest = new ManifestHelper(aNewManifest, app.origin);
|
||||||
|
|
||||||
|
#ifdef MOZ_B2G
|
||||||
// Update the permissions for this app.
|
// Update the permissions for this app.
|
||||||
PermissionsInstaller.installPermissions({
|
PermissionsInstaller.installPermissions({
|
||||||
manifest: app.manifest,
|
manifest: app.manifest,
|
||||||
origin: app.origin,
|
origin: app.origin,
|
||||||
manifestURL: aData.manifestURL
|
manifestURL: aData.manifestURL
|
||||||
}, true);
|
}, true);
|
||||||
|
#endif
|
||||||
app.name = manifest.name;
|
app.name = manifest.name;
|
||||||
app.csp = manifest.csp || "";
|
app.csp = manifest.csp || "";
|
||||||
app.updateTime = Date.now();
|
app.updateTime = Date.now();
|
||||||
@ -2012,12 +2018,14 @@ this.DOMApplicationRegistry = {
|
|||||||
// For package apps, the permissions are not in the mini-manifest, so
|
// For package apps, the permissions are not in the mini-manifest, so
|
||||||
// don't update the permissions yet.
|
// don't update the permissions yet.
|
||||||
if (!aData.isPackage) {
|
if (!aData.isPackage) {
|
||||||
|
#ifdef MOZ_B2G
|
||||||
PermissionsInstaller.installPermissions({ origin: appObject.origin,
|
PermissionsInstaller.installPermissions({ origin: appObject.origin,
|
||||||
manifestURL: appObject.manifestURL,
|
manifestURL: appObject.manifestURL,
|
||||||
manifest: jsonManifest },
|
manifest: jsonManifest },
|
||||||
isReinstall, (function() {
|
isReinstall, (function() {
|
||||||
this.uninstall(aData, aData.mm);
|
this.uninstall(aData, aData.mm);
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
["installState", "downloadAvailable",
|
["installState", "downloadAvailable",
|
||||||
@ -2075,12 +2083,13 @@ this.DOMApplicationRegistry = {
|
|||||||
app.downloadAvailable = false;
|
app.downloadAvailable = false;
|
||||||
this._saveApps((function() {
|
this._saveApps((function() {
|
||||||
this.updateAppHandlers(null, aManifest, appObject);
|
this.updateAppHandlers(null, aManifest, appObject);
|
||||||
|
#ifdef MOZ_B2G
|
||||||
// Update the permissions for this app.
|
// Update the permissions for this app.
|
||||||
PermissionsInstaller.installPermissions({ manifest: aManifest,
|
PermissionsInstaller.installPermissions({ manifest: aManifest,
|
||||||
origin: appObject.origin,
|
origin: appObject.origin,
|
||||||
manifestURL: appObject.manifestURL },
|
manifestURL: appObject.manifestURL },
|
||||||
true);
|
true);
|
||||||
|
#endif
|
||||||
debug("About to fire Webapps:PackageEvent 'installed'");
|
debug("About to fire Webapps:PackageEvent 'installed'");
|
||||||
this.broadcastMessage("Webapps:PackageEvent",
|
this.broadcastMessage("Webapps:PackageEvent",
|
||||||
{ type: "installed",
|
{ type: "installed",
|
||||||
|
@ -28,7 +28,7 @@ MOCHITEST_BROWSER_FILES := \
|
|||||||
page_privatestorageevent.html
|
page_privatestorageevent.html
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
ifeq (,$(filter-out Linux WINNT,$(OS_ARCH)))
|
ifdef MOZ_B2G
|
||||||
MOCHITEST_BROWSER_FILES += \
|
MOCHITEST_BROWSER_FILES += \
|
||||||
browser_webapps_permissions.js \
|
browser_webapps_permissions.js \
|
||||||
test-webapp.webapp \
|
test-webapp.webapp \
|
||||||
|
@ -8,6 +8,7 @@ let Cu = Components.utils;
|
|||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||||
|
Cu.import("resource://gre/modules/PermissionsInstaller.jsm");
|
||||||
|
|
||||||
function pref(name, value) {
|
function pref(name, value) {
|
||||||
return {
|
return {
|
||||||
@ -42,21 +43,23 @@ let WebAppRT = {
|
|||||||
// prevent offering to use helper apps for things that this app handles
|
// prevent offering to use helper apps for things that this app handles
|
||||||
// i.e. don't show the "Open in market?" popup when we're showing the market app
|
// i.e. don't show the "Open in market?" popup when we're showing the market app
|
||||||
let uri = Services.io.newURI(aUrl, null, null);
|
let uri = Services.io.newURI(aUrl, null, null);
|
||||||
Services.perms.add(uri, "native-intent", Ci.nsIPermissionManager.DENY_ACTION);
|
|
||||||
Services.perms.add(uri, "offline-app", Ci.nsIPermissionManager.ALLOW_ACTION);
|
|
||||||
Services.perms.add(uri, "indexedDB", Ci.nsIPermissionManager.ALLOW_ACTION);
|
|
||||||
Services.perms.add(uri, "indexedDB-unlimited", Ci.nsIPermissionManager.ALLOW_ACTION);
|
|
||||||
|
|
||||||
// update the blocklist url to use a different app id
|
// update the blocklist url to use a different app id
|
||||||
let blocklist = Services.prefs.getCharPref("extensions.blocklist.url");
|
let blocklist = Services.prefs.getCharPref("extensions.blocklist.url");
|
||||||
blocklist = blocklist.replace(/%APP_ID%/g, "webapprt-mobile@mozilla.org");
|
blocklist = blocklist.replace(/%APP_ID%/g, "webapprt-mobile@mozilla.org");
|
||||||
Services.prefs.setCharPref("extensions.blocklist.url", blocklist);
|
Services.prefs.setCharPref("extensions.blocklist.url", blocklist);
|
||||||
|
|
||||||
|
this.getManifestFor(aUrl, function (aManifest, aApp) {
|
||||||
|
if (aManifest) {
|
||||||
|
PermissionsInstaller.installPermissions(aApp, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.findManifestUrlFor(aUrl, aCallback);
|
this.findManifestUrlFor(aUrl, aCallback);
|
||||||
},
|
},
|
||||||
|
|
||||||
findManifestUrlFor: function(aUrl, aCallback) {
|
getManifestFor: function (aUrl, aCallback) {
|
||||||
let request = navigator.mozApps.mgmt.getAll();
|
let request = navigator.mozApps.mgmt.getAll();
|
||||||
request.onsuccess = function() {
|
request.onsuccess = function() {
|
||||||
let apps = request.result;
|
let apps = request.result;
|
||||||
@ -64,35 +67,38 @@ let WebAppRT = {
|
|||||||
let app = apps[i];
|
let app = apps[i];
|
||||||
let manifest = new ManifestHelper(app.manifest, app.origin);
|
let manifest = new ManifestHelper(app.manifest, app.origin);
|
||||||
|
|
||||||
// First see if this url matches any manifests we have registered
|
// if this is a path to the manifest, or the launch path, then we have a hit.
|
||||||
// If so, get the launchUrl from the manifest and we'll launch with that
|
if (app.manifestURL == aUrl || manifest.fullLaunchPath() == aUrl) {
|
||||||
//let app = DOMApplicationRegistry.getAppByManifestURL(aUrl);
|
aCallback(manifest, app);
|
||||||
if (app.manifestURL == aUrl) {
|
|
||||||
BrowserApp.manifest = app.manifest;
|
|
||||||
BrowserApp.manifestUrl = aUrl;
|
|
||||||
aCallback(manifest.fullLaunchPath());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, see if the apps launch path is this url
|
|
||||||
if (manifest.fullLaunchPath() == aUrl) {
|
|
||||||
BrowserApp.manifest = app.manifest;
|
|
||||||
BrowserApp.manifestUrl = app.manifestURL;
|
|
||||||
aCallback(aUrl);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, just attempt to open the webapp as a normal web page
|
// Otherwise, once we loop through all of them, we have a miss.
|
||||||
aCallback(aUrl);
|
aCallback(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
request.onerror = function() {
|
request.onerror = function() {
|
||||||
// Attempt to open the webapp as a normal web page
|
// Treat an error like a miss. We can't find the manifest.
|
||||||
aCallback(aUrl);
|
aCallback(undefined);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
findManifestUrlFor: function(aUrl, aCallback) {
|
||||||
|
this.getManifestFor(aUrl, function(aManifest, aApp) {
|
||||||
|
if (!aManifest) {
|
||||||
|
// we can't find the manifest, so open it like a web page
|
||||||
|
aCallback(aUrl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BrowserApp.manifest = aManifest;
|
||||||
|
BrowserApp.manifestUrl = aApp.manifestURL;
|
||||||
|
|
||||||
|
aCallback(aManifest.fullLaunchPath());
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
getDefaultPrefs: function() {
|
getDefaultPrefs: function() {
|
||||||
// read default prefs from the disk
|
// read default prefs from the disk
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user