Managing the Browser Lifecycle

The QNX Web Browser supports a Persistent Publish/Subscribe (PPS) interface that allows the main HMI process (or another privileged process) to manage the browser’s lifecycle. To use this interface, the HMI creates a PPS object and then issues PPS messages that tell the browser to run in the foreground or background, to load a URL, or to close.

To connect the QNX Web Browser to the lifecyle interface, use the --qnx-lifecycle-pps-object=pps_object_path command-line option. The browser will then listen for browser_state::value messages that the HMI sends to the PPS object specified in the pps_object_path argument.

The browser_state::value message can contain one of the following values:

Value Description
backgrounded

Minimize the browser window and run the browser in the background.

This option minimizes CPU and memory usage, blocks cursor and touch events, and prevents the browser from rendering to the screen. It's useful, for example, when running a game or a site that consumes many resources.

foregrounded Run the browser in the foreground, making it visible and active.
loadurl Tell the browser to load the specified URL.
closed Tell the browser to close itself in an orderly fashion.

See the Testing section, below, for examples of browser_state::value messages.

When it starts up, the QNX Web Browser queries the PPS object for the current browser state value. If the value is backgrounded, the browser will, upon starting, switch immediately to background mode. Note, however, that if the value is closed, the browser will start and then close immediately!

Note: To learn how to create PPS objects, see the Persistent Publish/Subscribe Developer's Guide.

Security considerations

If you're running the QNX Web Browser in a production system, the browser and the system's HMI process should, for security reasons, be the only processes allowed to write to the PPS object.

Testing

You can test the lifecycle management feature by creating a PPS object and sending PPS messages to it. For instance, if you create the object under the pps/services/lifecycle/control/ directory, you could open a terminal console and issue messages like the following:

./content_shell --qnx-lifecycle-pps-object=/pps/services/lifecycle/control &
echo "browser_state::backgrounded" > /pps/services/lifecycle/control
echo "browser_state::foregrounded" > /pps/services/lifecycle/control
echo "browser_state::loadurl\nurl::http://www.qnx.com" > /pps/services/lifecycle/control
echo "browser_state::closed" > /pps/services/lifecycle/control