Hi Mikhail,
Thanks for your response and suggestion.
Registering events at first launch time looks a good idea, while my concerns 
upon this method include, 

1. About 'onLaunched' API. I'm afraid the event manager has to execute 
application main document after receiving 'onLaunched' event, no matter whether 
application main document contains 'onLaunched' event listener or not. 
In detail, a typical launch procedure of a terminated application is, 
- A system level service (eg. Application service from shared mode model) sends 
'onLaunched' event to event manager.
- Event manager gets supported event list of the specified application, checks 
whether 'onLaunched' event is in the list. If 'onLaunched' event is in the 
list, then event manager runs main document to launch the application, 
otherwise the 'onLaunched' event is ignored and nothing happens.
As a result, it is an issue of chicken and egg. We want to register system 
events when firstly executing main document. However, the main document could 
not be executed because 'onLaunched' system event is not in the event list yet.

2. We could not implement installation time API such as 'onInstalled'.
 http://developer.chrome.com/extensions/runtime.html#event-onInstalled

Thanks,
Changbin

> -----Original Message-----
> From: Pozdnyakov, Mikhail
> Sent: Monday, November 25, 2013 11:42 PM
> To: Shao, Changbin; [email protected]
> Subject: RE: Intent to implement : [Runtime Model] System event
> 
> Hi,
> 
> Can the app register its events when it is launched for the first time? (no
> enforced main document loading after the installation)
> 
> BR,
> Mikhail
> 
> ________________________________________
> From: Crosswalk-dev [[email protected]]
> on behalf of Shao, Changbin [[email protected]]
> Sent: Friday, November 22, 2013 8:38 AM
> To: [email protected]
> Subject: [Crosswalk-dev] Intent to implement : [Runtime Model] System
> event
> 
> Summary:
>   A system event is an event sent by the system. This event type does not
> originate from the DOM itself and thus lives outside of the main document's
> lifetime. A system event can wake up a terminated application. For example,
> "OnAlarm" event is one of this kind, it can launch a terminated app's main
> document (AKA event page), when the alarm time is scheduled. Then the
> main document can determine which view to show.
> 
> The overall design of Runtime Model event system,
> https://docs.google.com/document/d/1cDb54Cs1wjbNQPb7W44_4aj1bzPI9
> dqsb2aRDkZmDTE/edit#heading=h.v1w5rrn37icm
> 
> Spec: http://www.w3.org/2012/sysapps/app-lifecycle/
> 
> Affected component: xwalk/application
> 
> Related feature in Jira: https://crosswalk-project.org/jira/browse/XWALK-1
> 
> Target Release: Crosswalk-4
> 
> Target Platform: N/A
> 
> Implementation details:
> 
> I plan to register system events at application install time. The system 
> events
> information is saved in system database during installation, so that a system
> level service is able to get the system events list for a specified 
> application
> and wake up the application if it is terminated.
> 
> There are two options to implement this feature,
> 
> 1. 'Run main document to register event after complete installation'. This is
> like Chromium extension way. In detail, crosswalk installs application
> package first, after that it loads and executes the main document if the main
> document exists. As a result, render process is able to get events list
> information of main document, then notifies browser process to write these
> events information into database. One of the disadvantage is there may be
> side effect. For example, if main document directly calls 'window.open()', a
> window will pop up during installation.
> 
> 2. 'Write copy of system events information in manifest file'.  In detail,
> application developer must writes manually into manifest file with the
> system events information of the main document. Therefore, during
> installation the events information will be obtained from the manifest data
> and then is written into database. The disadvantage of this way is developer
> has to add copy of events info in manifest file, this is troublesome for
> application update, and also this method is not able to support add/remove
> system event dynamically in the main document.
> 
> I prefer option 1, the side effect could be alleviated by good programming
> style. For instance, developer should use 'onLaunch' event callback in the
> main document to open application window.
> 
> Thanks
> Changbin
> _______________________________________________
> Crosswalk-dev mailing list
> [email protected]
> https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-dev
_______________________________________________
Crosswalk-dev mailing list
[email protected]
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-dev

Reply via email to