Closed Bug 1017420 Opened 7 years ago Closed 7 years ago

Add support for certified apps to get the list of apps matching an activity request

Categories

(Core :: DOM: Core & HTML, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32
feature-b2g 2.0

People

(Reporter: fabrice, Assigned: fabrice)

References

Details

(Whiteboard: ft:loop)

Attachments

(1 file, 1 obsolete file)

Attached patch activities-enumeration.patch (obsolete) — Splinter Review
This is better solution than the one asked for in Bug 1017031.

Calling an activity with:
var activity = new MozActivity({ name: "view",
		                 data: { url: "http://foo.com" },
		                 getFilterResults: true });
activity.onsuccess = function(e) {
	console.log("** "+ JSON.stringify(activity.result) + " **");
}
activity.onerror = function(e) {
	console.log(e.error.name);
}

will just return the data that is usually sent to the activity picker.


Security wise, we check both in the child and the parent that the application is certified.
Attachment #8430532 - Flags: review?(jonas)
No longer blocks: loop_security_change
feature-b2g: --- → 2.0
Comment on attachment 8430532 [details] [diff] [review]
activities-enumeration.patch

Review of attachment 8430532 [details] [diff] [review]:
-----------------------------------------------------------------

looks good, though ping me before landing so we can look at the question below.

::: dom/activities/src/ActivitiesService.jsm
@@ +282,5 @@
> +        // Certified apps can ask to just get the picker data.
> +        caller.mm.sendAsyncMessage("Activity:FireSuccess",
> +          {
> +            "id": aMsg.id,
> +            "result": aResults.options

Still digging through code to try to understand what format these are in. It's not terribly important as I'm sure that there's enough data here to render the UI that we need. But I'd still like to understand the format.
Attachment #8430532 - Flags: review?(jonas) → review+
The result is an array of {manifest, icon, {activity description}}. We can filter out the "description" part I guess.

[
 {"manifest":"app://wallpaper.gaiamobile.org/manifest.webapp",
  "icon":"app://wallpaper.gaiamobile.org/style/icons/64/Wallpaper.png",
  "description":{"filters":{"type":"wallpaper"},"disposition":"inline","returnValue":true,"href":"app://wallpaper.gaiamobile.org/pick.html"}},

 {"manifest":"app://gallery.gaiamobile.org/manifest.webapp",
  "icon":"app://gallery.gaiamobile.org/style/icons/Gallery_120.png",
  "description":{"filters":{"type":["image/*","image/jpeg","image/png"]},"disposition":"inline","returnValue":true,"href":"app://gallery.gaiamobile.org/index.html#pick"}},

 {"manifest":"app://camera.gaiamobile.org/manifest.webapp",
  "icon":"app://camera.gaiamobile.org/style/icons/Camera_120.png",
   "description":{"filters":{"type":["image/*","image/jpeg","video/*","video/3gpp"]},"returnValue":true,"disposition":"inline","href":"app://camera.gaiamobile.org/index.html#pick"}}
]
Can we add the application name?
Now return an array of { manifestURL, iconURL, appName }, where appName is the correct localized name of the app.
Attachment #8430532 - Attachment is obsolete: true
Attachment #8431194 - Flags: review?(jonas)
Comment on attachment 8431194 [details] [diff] [review]
activities-enumeration.patch v2

Review of attachment 8431194 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/activities/src/ActivitiesService.jsm
@@ +290,5 @@
> +        let reg = DOMApplicationRegistry;
> +        let ids = [];
> +        aResults.options.forEach((aItem) => {
> +          ids.push({ id: reg._appIdForManifestURL(aItem.manifest) });
> +        });

Nit:

let ids = aResults.options.map((aItem) => {
  { id: reg._appIdForManifestURL(aItem.manifest) }
});

@@ +293,5 @@
> +          ids.push({ id: reg._appIdForManifestURL(aItem.manifest) });
> +        });
> +
> +        reg._readManifests(ids).then(
> +          function(aManifests) {

Nit: Maybe use arrow-function syntax here too?
Attachment #8431194 - Flags: review?(jonas) → review+
https://hg.mozilla.org/mozilla-central/rev/0ad306bee50e
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.