Closed Bug 725397 Opened 12 years ago Closed 12 years ago

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

Categories

(Core Graveyard :: DOM: Apps, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mounir, Unassigned)

References

Details

(Whiteboard: [fixed by bug 754141])

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.
Blocks: 740192
No longer blocks: 673922
Component: DOM → DOM: Mozilla Extensions
Blocks: 746465
Fabrice or Ian - Any ideas?
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.
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.
(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.
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?
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
I wrote a service for that in bug 754141.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: [fixed by bug 754141]
Component: DOM: Mozilla Extensions → DOM: Apps
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.