Some mozApps helper should be accessible from C++ trough a XPCOM component

RESOLVED FIXED

Status

()

Core
DOM: Apps
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: mounir, Unassigned)

Tracking

Trunk
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [fixed by bug 754141])

(Reporter)

Description

5 years ago
It's currently not possible to read mozApps information from C++ which means stuff like Screen Orientation API that want to have a specific behavior for installed app can't do what we want.

We need a way to access these information from C++. At least, knowing if we are currently running in an installed application context or not.
(Reporter)

Updated

5 years ago
Blocks: 740192
(Reporter)

Updated

5 years ago
No longer blocks: 673922

Updated

5 years ago
Component: DOM → DOM: Mozilla Extensions
(Reporter)

Updated

5 years ago
Blocks: 746465
Fabrice or Ian - Any ideas?

Comment 2

5 years ago
I can't be much help here
I definitely don't think that "mozApps" in general needs or ought to be available to C++. We ought to expose specific queries like "am I running in app mode" more directly. Note that the implementation may be vastly different in different contexts, e.g. on Android we may end up using a single Firefox process to run all the webapps, so the question needs to be per-docshell or per-window or something like that.
(Reporter)

Comment 4

5 years ago
What should be accessible from C++ is the API. There is no reason to hide it in JS...
Other than it is implemented in JS, and doing extra work to make it available via C++ without a compelling usecase seems silly? We're implementing a lot of new APIs directly in JS. So let's solve the actual use case that we need to solve for C++ code, and not attempt to mirror the entire mozapps API into C++ in a generic way.
(Reporter)

Comment 6

5 years ago
(In reply to Benjamin Smedberg  [:bsmedberg] from comment #5)
> Other than it is implemented in JS, and doing extra work to make it
> available via C++ without a compelling usecase seems silly? We're
> implementing a lot of new APIs directly in JS. So let's solve the actual use
> case that we need to solve for C++ code, and not attempt to mirror the
> entire mozapps API into C++ in a generic way.

AFAIK, making the API available from C++ should be done trough a XPCOM service. Then, adding only one method or a few doesn't seem like a lot of work. If it is for some of them, I agree we shouldn't bother too much.

Comment 7

5 years ago
DOMApplicationRegistry's API will, I think, need to change quite a bit if the storage is changed (right now it's just a set of JSON files read somewhat synchronously), and I suspect other changes will also occur – which is okay at the moment because there are very few consumers of DOMApplicationRegistry.  I don't think it should be exposed any further in its current form as I don't think that API will show itself to be stable enough.  Exposing specific (and probably new) routines more publicly, including through C++, would seem to be a better route.
DOMApplicationRegistry is not a public API (also, it does no synchronous IO currently, even if I'd like to move the storage to indexedDB for other reasons), but I'm not sure that's what is needed here. Moreover, it should only be used in the parent process.

The mozApps API itself is implemented as an XPCOM component, so there's nothing preventing its use from c++, and using it is e10s compliant.
(In reply to Fabrice Desré [:fabrice] from comment #8)
> The mozApps API itself is implemented as an XPCOM component, so there's
> nothing preventing its use from c++, and using it is e10s compliant.

Mounir - Could you verify that you can access the mozapps API from C++ off of Fabrice's instructions? If you are able to do this, could you then resolve this bug as "WORKSFORME." If not, please provide more information on why you cannot access the mozapps API in C++.
(In reply to Jason Smith [:jsmith] from comment #9)
> (In reply to Fabrice Desré [:fabrice] from comment #8)
> > The mozApps API itself is implemented as an XPCOM component, so there's
> > nothing preventing its use from c++, and using it is e10s compliant.
> 
> Mounir - Could you verify that you can access the mozapps API from C++ off
> of Fabrice's instructions? If you are able to do this, could you then
> resolve this bug as "WORKSFORME." If not, please provide more information on
> why you cannot access the mozapps API in C++.

The API uses DOMRequests so you always need a window to access it. Is this the case?
(Reporter)

Comment 11

5 years ago
We would need something like:
  mozIDOMApplication getAppFromManifestURL(DOMString manifestURL);
Summary: mozApps should be accessible from C++ → Some mozApps helper should be accessible from C++ trough a XPCOM component
(Reporter)

Comment 12

5 years ago
I wrote a service for that in bug 754141.
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Whiteboard: [fixed by bug 754141]

Updated

5 years ago
Component: DOM: Mozilla Extensions → DOM: Apps
You need to log in before you can comment on or make changes to this bug.