bug 777400 - disable mozApps.installPackage API in Firefox for Desktop and Android; r=fabrice, sr=sicking

This commit is contained in:
Myk Melez 2012-09-11 13:53:42 -07:00
Родитель 589178c8cd
Коммит d7947a3d5a
7 изменённых файлов: 91 добавлений и 28 удалений

Просмотреть файл

@ -12,10 +12,13 @@ include $(DEPTH)/config/autoconf.mk
EXTRA_COMPONENTS = \
AppsService.js \
AppsService.manifest \
Webapps.js \
Webapps.manifest \
$(NULL)
EXTRA_PP_COMPONENTS = \
Webapps.js \
$(NULL)
EXTRA_PP_JS_MODULES += \
Webapps.jsm \
AppsServiceChild.jsm \

Просмотреть файл

@ -33,7 +33,19 @@ WebappsRegistry.prototype = {
__proto__: DOMRequestIpcHelper.prototype,
__exposedProps__: {
install: 'r',
#ifdef MOZ_PHOENIX
# Firefox Desktop: installPackage not implemented
#elifdef ANDROID
#ifndef MOZ_WIDGET_GONK
# Firefox Android (Fennec): installPackage not implemented
#else
# B2G Gonk: installPackage implemented
installPackage: 'r',
#endif
#else
# B2G Desktop and others: installPackage implementation status varies
installPackage: 'r',
#endif
getSelf: 'r',
getInstalled: 'r',
mgmt: 'r'
@ -167,6 +179,18 @@ WebappsRegistry.prototype = {
return request;
},
get mgmt() {
if (!this._mgmt)
this._mgmt = new WebappsApplicationMgmt(this._window);
return this._mgmt;
},
uninit: function() {
this._mgmt = null;
},
// mozIDOMApplicationRegistry2 implementation
installPackage: function(aPackageURL, aParams) {
let request = this.createRequest();
let requestID = this.getRequestId(request);
@ -185,16 +209,6 @@ WebappsRegistry.prototype = {
return request;
},
get mgmt() {
if (!this._mgmt)
this._mgmt = new WebappsApplicationMgmt(this._window);
return this._mgmt;
},
uninit: function() {
this._mgmt = null;
},
// nsIDOMGlobalPropertyInitializer implementation
init: function(aWindow) {
this.initHelper(aWindow, ["Webapps:Install:Return:OK", "Webapps:Install:Return:KO",
@ -207,11 +221,39 @@ WebappsRegistry.prototype = {
classID: Components.ID("{fff440b3-fae2-45c1-bf03-3b5a2e432270}"),
QueryInterface: XPCOMUtils.generateQI([Ci.mozIDOMApplicationRegistry, Ci.nsIDOMGlobalPropertyInitializer]),
QueryInterface: XPCOMUtils.generateQI([Ci.mozIDOMApplicationRegistry,
#ifdef MOZ_PHOENIX
# Firefox Desktop: installPackage not implemented
#elifdef ANDROID
#ifndef MOZ_WIDGET_GONK
# Firefox Android (Fennec): installPackage not implemented
#else
# B2G Gonk: installPackage implemented
Ci.mozIDOMApplicationRegistry2,
#endif
#else
# B2G Desktop and others: installPackage implementation status varies
Ci.mozIDOMApplicationRegistry2,
#endif
Ci.nsIDOMGlobalPropertyInitializer]),
classInfo: XPCOMUtils.generateCI({classID: Components.ID("{fff440b3-fae2-45c1-bf03-3b5a2e432270}"),
contractID: "@mozilla.org/webapps;1",
interfaces: [Ci.mozIDOMApplicationRegistry],
interfaces: [Ci.mozIDOMApplicationRegistry,
#ifdef MOZ_PHOENIX
# Firefox Desktop: installPackage not implemented
#elifdef ANDROID
#ifndef MOZ_WIDGET_GONK
# Firefox Android (Fennec): installPackage not implemented
#else
# B2G Gonk: installPackage implemented
Ci.mozIDOMApplicationRegistry2,
#endif
#else
# B2G Desktop and others: installPackage implementation status varies
Ci.mozIDOMApplicationRegistry2,
#endif
],
flags: Ci.nsIClassInfo.DOM_OBJECT,
classDescription: "Webapps Registry"})
}

Просмотреть файл

@ -17,6 +17,7 @@ GRE_MODULE = 1
XPIDLSRCS = \
mozIApplication.idl \
nsIDOMApplicationRegistry.idl \
nsIDOMApplicationRegistry2.idl \
nsIAppsService.idl \
nsIDOMMozApplicationEvent.idl \
$(NULL)

Просмотреть файл

@ -73,7 +73,7 @@ interface mozIDOMApplicationMgmt : nsISupports
attribute nsIDOMEventListener onuninstall;
};
[scriptable, uuid(8ce06dd2-4c2e-4523-8ea1-960f4a7f0456)]
[scriptable, uuid(dd9a044c-1073-4d2b-a17d-c9b5834b3420)]
interface mozIDOMApplicationRegistry : nsISupports
{
/**
@ -99,18 +99,5 @@ interface mozIDOMApplicationRegistry : nsISupports
*/
nsIDOMDOMRequest getInstalled();
/**
* Install a packaged web app.
*
* @param packageUrl : the URL of the webapps manifest.
* @param parameters : A structure with optional information.
* {
* receipts: ... Will be used to specify the payment receipts for this installation.
* categories: ... Will be used to specify the categories of the webapp.
* }
* @returns : A DOMRequest object, returning the app object in |result| if install succeeds.
*/
nsIDOMDOMRequest installPackage(in DOMString packageUrl, [optional] in jsval parameters);
readonly attribute mozIDOMApplicationMgmt mgmt;
};

Просмотреть файл

@ -0,0 +1,24 @@
/* 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/. */
#include "nsIDOMApplicationRegistry.idl"
interface nsIDOMDOMRequest;
[scriptable, uuid(34498a66-3aee-4b80-8b8b-a9c5d5ba32b6)]
interface mozIDOMApplicationRegistry2 : mozIDOMApplicationRegistry
{
/**
* Install a packaged web app.
*
* @param packageUrl : the URL of the webapps manifest.
* @param parameters : A structure with optional information.
* {
* receipts: ... Will be used to specify the payment receipts for this installation.
* categories: ... Will be used to specify the categories of the webapp.
* }
* @returns : A DOMRequest object, returning the app object in |result| if install succeeds.
*/
nsIDOMDOMRequest installPackage(in DOMString packageUrl, [optional] in jsval parameters);
};

Просмотреть файл

@ -24,6 +24,7 @@ var steps = [
invalidManifest,
permissionDenied,
invalidContent,
installPackageNotImplemented,
];
runAll(steps);
@ -96,5 +97,11 @@ function invalidContent(next) {
};
}
function installPackageNotImplemented(next) {
ok(!("installPackage" in navigator.mozApps),
"installPackage not in navigator.mozApps");
next();
}
</script>
</window>

Просмотреть файл

@ -23,7 +23,6 @@ var props = {
getInstalled: "function",
getSelf: "function",
install: "function",
installPackage: "function",
mgmt: "object",
};