mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 860782 - Move Android permission install to first run, from install. r=wesj, r=fabrice
This commit is contained in:
parent
b71ef09dc8
commit
a1f26cfb98
@ -258,6 +258,8 @@ this.DOMApplicationRegistry = {
|
||||
|
||||
// Install the permissions for this app, as if we were updating
|
||||
// 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) {
|
||||
let data = aResult[0];
|
||||
PermissionsInstaller.installPermissions({
|
||||
@ -268,6 +270,7 @@ this.DOMApplicationRegistry = {
|
||||
debug("Error installing permissions for " + aId);
|
||||
});
|
||||
}).bind(this));
|
||||
#endif
|
||||
},
|
||||
|
||||
updateOfflineCacheForApp: function updateOfflineCacheForApp(aId) {
|
||||
@ -1237,11 +1240,13 @@ this.DOMApplicationRegistry = {
|
||||
this._saveApps((function() {
|
||||
// Update the handlers and permissions for this app.
|
||||
this.updateAppHandlers(aOldManifest, aData, app);
|
||||
#ifdef MOZ_B2G
|
||||
PermissionsInstaller.installPermissions(
|
||||
{ manifest: aData,
|
||||
origin: app.origin,
|
||||
manifestURL: app.manifestURL },
|
||||
true);
|
||||
#endif
|
||||
this.broadcastMessage("Webapps:PackageEvent",
|
||||
{ type: "applied",
|
||||
manifestURL: app.manifestURL,
|
||||
@ -1462,13 +1467,14 @@ this.DOMApplicationRegistry = {
|
||||
this._writeFile(manFile, JSON.stringify(aNewManifest), function() { });
|
||||
manifest = new ManifestHelper(aNewManifest, app.origin);
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
// Update the permissions for this app.
|
||||
PermissionsInstaller.installPermissions({
|
||||
manifest: app.manifest,
|
||||
origin: app.origin,
|
||||
manifestURL: aData.manifestURL
|
||||
}, true);
|
||||
|
||||
#endif
|
||||
app.name = manifest.name;
|
||||
app.csp = manifest.csp || "";
|
||||
app.updateTime = Date.now();
|
||||
@ -2012,12 +2018,14 @@ this.DOMApplicationRegistry = {
|
||||
// For package apps, the permissions are not in the mini-manifest, so
|
||||
// don't update the permissions yet.
|
||||
if (!aData.isPackage) {
|
||||
#ifdef MOZ_B2G
|
||||
PermissionsInstaller.installPermissions({ origin: appObject.origin,
|
||||
manifestURL: appObject.manifestURL,
|
||||
manifest: jsonManifest },
|
||||
isReinstall, (function() {
|
||||
this.uninstall(aData, aData.mm);
|
||||
}).bind(this));
|
||||
#endif
|
||||
}
|
||||
|
||||
["installState", "downloadAvailable",
|
||||
@ -2075,12 +2083,13 @@ this.DOMApplicationRegistry = {
|
||||
app.downloadAvailable = false;
|
||||
this._saveApps((function() {
|
||||
this.updateAppHandlers(null, aManifest, appObject);
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
// Update the permissions for this app.
|
||||
PermissionsInstaller.installPermissions({ manifest: aManifest,
|
||||
origin: appObject.origin,
|
||||
manifestURL: appObject.manifestURL },
|
||||
true);
|
||||
#endif
|
||||
debug("About to fire Webapps:PackageEvent 'installed'");
|
||||
this.broadcastMessage("Webapps:PackageEvent",
|
||||
{ type: "installed",
|
||||
|
@ -8,6 +8,7 @@ let Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/PermissionsInstaller.jsm");
|
||||
|
||||
function pref(name, value) {
|
||||
return {
|
||||
@ -51,12 +52,22 @@ let WebAppRT = {
|
||||
let blocklist = Services.prefs.getCharPref("extensions.blocklist.url");
|
||||
blocklist = blocklist.replace(/%APP_ID%/g, "webapprt-mobile@mozilla.org");
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", blocklist);
|
||||
|
||||
this.getManifestFor(aUrl, function (aManifest, aManifestURL) {
|
||||
if (aManifest) {
|
||||
PermissionsInstaller.installPermissions(
|
||||
{ manifest: aManifest,
|
||||
origin: aUrl,
|
||||
manifestURL: aManifestURL },
|
||||
true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.findManifestUrlFor(aUrl, aCallback);
|
||||
},
|
||||
|
||||
findManifestUrlFor: function(aUrl, aCallback) {
|
||||
getManifestFor: function (aUrl, aCallback) {
|
||||
let request = navigator.mozApps.mgmt.getAll();
|
||||
request.onsuccess = function() {
|
||||
let apps = request.result;
|
||||
@ -64,35 +75,38 @@ let WebAppRT = {
|
||||
let app = apps[i];
|
||||
let manifest = new ManifestHelper(app.manifest, app.origin);
|
||||
|
||||
// First see if this url matches any manifests we have registered
|
||||
// If so, get the launchUrl from the manifest and we'll launch with that
|
||||
//let app = DOMApplicationRegistry.getAppByManifestURL(aUrl);
|
||||
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);
|
||||
// if this is a path to the manifest, or the launch path, then we have a hit.
|
||||
if (app.manifestURL == aUrl || manifest.fullLaunchPath() == aUrl) {
|
||||
aCallback(manifest, app.manifestURL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, just attempt to open the webapp as a normal web page
|
||||
aCallback(aUrl);
|
||||
// Otherwise, once we loop through all of them, we have a miss.
|
||||
aCallback(undefined);
|
||||
};
|
||||
|
||||
request.onerror = function() {
|
||||
// Attempt to open the webapp as a normal web page
|
||||
aCallback(aUrl);
|
||||
// Treat an error like a miss. We can't find the manifest.
|
||||
aCallback(undefined);
|
||||
};
|
||||
},
|
||||
|
||||
findManifestUrlFor: function(aUrl, aCallback) {
|
||||
this.getManifestFor(aUrl, function(aManifest, aManifestURL) {
|
||||
if (!aManifest) {
|
||||
// we can't find the manifest, so open it like a web page
|
||||
aCallback(aUrl);
|
||||
return;
|
||||
}
|
||||
|
||||
BrowserApp.manifest = aManifest;
|
||||
BrowserApp.manifestUrl = aManifestURL;
|
||||
|
||||
aCallback(aManifest.fullLaunchPath());
|
||||
});
|
||||
},
|
||||
|
||||
getDefaultPrefs: function() {
|
||||
// read default prefs from the disk
|
||||
try {
|
||||
@ -134,7 +148,7 @@ let WebAppRT = {
|
||||
|
||||
handleEvent: function(event) {
|
||||
let target = event.target;
|
||||
|
||||
|
||||
// walk up the tree to find the nearest link tag
|
||||
while (target && !(target instanceof HTMLAnchorElement)) {
|
||||
target = target.parentNode;
|
||||
@ -143,15 +157,15 @@ let WebAppRT = {
|
||||
if (!target || target.getAttribute("target") != "_blank") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let uri = Services.io.newURI(target.href, target.ownerDocument.characterSet, null);
|
||||
|
||||
|
||||
// Direct the URL to the browser.
|
||||
Cc["@mozilla.org/uriloader/external-protocol-service;1"].
|
||||
getService(Ci.nsIExternalProtocolService).
|
||||
getProtocolHandlerInfo(uri.scheme).
|
||||
launchWithURI(uri);
|
||||
|
||||
|
||||
// Prevent the runtime from loading the URL. We do this after directing it
|
||||
// to the browser to give the runtime a shot at handling the URL if we fail
|
||||
// to direct it to the browser for some reason.
|
||||
|
Loading…
Reference in New Issue
Block a user