webappmanager
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
WebAppManager Class Reference

#include <WebAppManager.h>

Inheritance diagram for WebAppManager:
[legend]
Collaboration diagram for WebAppManager:
[legend]

Public Member Functions

virtual ~WebAppManager ()
 
virtual void run ()
 
Event::Orientation orientation () const
 
std::list< const ProcessBase * > runningApps ()
 
std::list< const ProcessBase * > runningApps (WindowType::Type winType)
 
WebAppBasefindApp (const QString &processId)
 
WebAppBasefindAppById (const QString &appId)
 
LSHandle * getStatsServiceHandle () const
 
void copiedToClipboard (const QString &appId)
 
void pastedFromClipboard (const QString &appId)
 
void closePageSoon (SysMgrWebBridge *page)
 
void closePageRequest (SysMgrWebBridge *page)
 
void onMessageReceived (const PIpcMessage &msg)
 
void onDisconnected ()
 
void setJavascriptFlags (const std::string &flags)
 
void sendAsyncMessage (PIpcMessage *msg)
 
void markUniversalSearchReady ()
 
void closeByProcessId (const std::string &processId)
 
const void setHostInfo (const HostInfo *hostInfo)
 
const HostInfo & getHostInfo () const
 
void reportAppLaunched (const QString &appId, const QString &processId)
 
void reportAppClosed (const QString &appId, const QString &processId)
 
int currentUiWidth ()
 
int currentUiHeight ()
 
bool isDevicePortraitType ()
 
void disableAppCaching (bool disable)
 
void setInSimulatedMouseEvent (bool val)
 
bool inSimulatedMouseEvent () const
 
void setActiveAppId (const std::string &id)
 
const std::string & getActiveAppId ()
 
- Public Member Functions inherited from SyncTask
 SyncTask ()
 
 SyncTask (GMainContext *ctxt)
 
virtual ~SyncTask ()
 
virtual void quit ()
 

Static Public Member Functions

static WebAppManagerinstance ()
 
static bool hasBeenInstanced ()
 
static const std::string getTimeZone ()
 
static SharedGlobalPropertiesglobalProperties ()
 

Protected Member Functions

void onLaunchUrl (const std::string &url, int winType, const std::string &appDesc, const std::string &procId, const std::string &args, const std::string &launchingAppId, const std::string &launchingProcId)
 
void onLaunchUrlChild (const std::string &url, int winType, const std::string &appDesc, const std::string &procId, const std::string &args, const std::string &launchingAppId, const std::string &launchingProcId, int &errorCode, bool isHeadless)
 
void onRelaunchApp (const std::string &procId, const std::string &args, const std::string &launchingAppId, const std::string &launchingProcId)
 
void onSetOrientation (int orient)
 
void onGlobalProperties (int key)
 
void onInspectByProcessId (const std::string &processId)
 
void performLowMemoryActions (const bool allowExpensive=false)
 
void monitorNativeProcessMemory (const pid_t pid, const int maxMemory, pid_t updateFromPid=0)
 
void clearWebkitCache ()
 
void enableDebugger (bool enable)
 
void onShutdownEvent ()
 
bool onKillApp (const std::string &appId)
 
void onSyncKillApp (const std::string &appId, bool *result)
 
void onProcMgrLaunch (const std::string &appDescString, const std::string &params, const std::string &launchingAppId, const std::string &launchingProcId)
 
void onProcMgrLaunchChild (const std::string &appDescString, const std::string &params, const std::string &launchingAppId, const std::string &launchingProcId, bool isHeadless, bool isParentPdk)
 
void onProcMgrLaunchBootTimApp (const std::string &appDescString)
 
void onListOfRunningAppsRequest (bool includeSysApps)
 
void onDeleteHTML5Database (const std::string &domain)
 
void inputEvent (int ipcKey, sptr< Event > e)
 
void onUiDimensionsChanged (int width, int height)
 
void onSuspendWebkitProcess (bool *result)
 
virtual void threadStarting ()
 
virtual void threadStopping ()
 
virtual void handleEvent (sptr< Event >)
 
virtual void windowedAppAdded (WindowedWebApp *app)
 
virtual void windowedAppKeyChanged (WindowedWebApp *app, int oldKey)
 
virtual void windowedAppRemoved (WindowedWebApp *app)
 

Friends

class SysMgrWebBridge
 
class SysMgrWebPage
 
class WebAppBase
 
class WindowedWebApp
 
class MemoryWatcher
 
class PalmSystem
 
class CardWebApp
 
class AlertWebApp
 
class DashboardWebApp
 
class ProcessManager
 

Detailed Description

Manages running web apps

Constructor & Destructor Documentation

WebAppManager::~WebAppManager ( )
virtual

Shuts down and cleans up this process's instance of WebAppManager

Closes all web apps managed by this WebAppManager.

Todo:
Confirm this.

Member Function Documentation

void WebAppManager::clearWebkitCache ( )
protected

Clears the global system WebKit cache

See Also
Palm::WebGlobal::clearDOMCache()
void WebAppManager::closeByProcessId ( const std::string &  processId)

Finds an app by its process ID and closes it

Parameters
processIdProcess ID of the app to close.
void WebAppManager::closePageRequest ( SysMgrWebBridge page)

Request that the given page be closed.

Todo:
Expand on documentation of this.
void WebAppManager::closePageSoon ( SysMgrWebBridge page)

Close a page after processing events

Queues up an event to close the given page so that once the event queue finishes processing all current events it goes through and closes all pages which WebAppManager has been asked to close by then.

Parameters
pagePage to queue up to close.
void WebAppManager::copiedToClipboard ( const QString &  appId)

Adds a banner to indicate that text has been copied to the clipboard

Todo:
Document this more fully once BannerMessageEvent and BannerMessageEventFactory are documented
Parameters
appIdApp ID of the app that copied text to the clipboard.
int WebAppManager::currentUiHeight ( )
inline

Gets the height of the UI in pixels

Todo:
Document this once WebAppManager::onUiDimensionsChanged() is documented.
See Also
WebAppManager::onUiDimensionsChanged()
Returns
Height of UI.
int WebAppManager::currentUiWidth ( )
inline

Gets the width of the UI in pixels

Todo:
Document this once WebAppManager::onUiDimensionsChanged() is documented.
See Also
WebAppManager::onUiDimensionsChanged()
Returns
Width of UI.
void WebAppManager::disableAppCaching ( bool  disable)

Disables/enables caching of apps when they're closed

By default under certain circumstances apps can be cached when they're closed. This allows you to disable/enable that functionality.

Todo:
Document this a bit more fully once WebAppBase::freezeInCache() is fully documented.
Parameters
disabletrue to disable app caching, false to enable it.
void WebAppManager::enableDebugger ( bool  enable)
protected

Enables the debugger

Current just a wrapper for Palm::WebGlobal::enableDebugger().

See Also
Palm::WebGlobal::enableDebugger()
Todo:
Document this more fully once Palm::WebGlobal::enableDebugger() is publicly documented.
WebAppBase * WebAppManager::findApp ( const QString &  processId)

Find an app by process ID

Parameters
processIDProcess ID of the app to look for.
Returns
The app itself, if found.
WebAppBase * WebAppManager::findAppById ( const QString &  appId)

Find an app by app ID

Parameters
appIDApp ID of the app to look for.
Returns
The app itself, if found.
const std::string& WebAppManager::getActiveAppId ( )
inline
const HostInfo & WebAppManager::getHostInfo ( ) const

Gets the cached host device information structure

Retrieves the cached HostInfo structure if it has already been stored using WebAppManager::setHostInfo().

See Also
WebAppManager::setHostInfo()
Returns
Cached host device info.
LSHandle * WebAppManager::getStatsServiceHandle ( ) const

Gets a Luna Service handle to talk to the statistics service

Gets a handle to the statistics service used to report memory statistics to Luna.

Todo:
Document this a bit more thoroughly once LSPalmService is documented.
See Also
LSPalmService
Returns
Handle to the statistics service.
const std::string WebAppManager::getTimeZone ( )
static

Gets the time zone from the last time the clock was checked

Returns
System's current time zone.
SharedGlobalProperties * WebAppManager::globalProperties ( )
static

Unknown at this time.

Todo:
Document this once SharedGlobalProperties is documented.
See Also
SharedGlobalProperties
Returns
Unknown at this time.
void WebAppManager::handleEvent ( sptr< Event e)
protectedvirtual

Handles a GLib event from the event queue

Currently the only event we handle is InputEvent, which is sent by us internally when WebAppManager::inputEvent() is called.

Doesn't appear to be used anymore.

Todo:
See if the functionality of this can be removed along with WebAppManager::inputEvent().
Parameters
eventThe event to handle.

Reimplemented from SyncTask.

bool WebAppManager::hasBeenInstanced ( )
static

Checks whether or not a WebAppManager instance has been constructed for this process

Return value indicates whether or not WebAppManager::instance() has been called yet for this process.

See Also
WebAppManager::instance()
Returns
Whether or not a WebAppManager instance has been constructed for this process.
void WebAppManager::inputEvent ( int  ipcKey,
sptr< Event e 
)
protected

Posts an event to the event queue to be dispatched to a given app

This used to be used by WebAppManager::onInputEvent(), but since that has been commented out, this is probably unnecessary to have around anymore.

Todo:
Figure out if we should remove this and associated functionality.
Parameters
ipcKeyIPC key of the app to dispatch the event to.
eEvent to dispatch.
bool WebAppManager::inSimulatedMouseEvent ( ) const
inline

Unknown at this time

Todo:

See if this is actually used anywhere and for what.

See if we can remove this.

Returns
Unknown at this time.
WebAppManager * WebAppManager::instance ( )
static

Gets this process's WebAppManager instance

WebAppManager is designed as a singleton and can only be constructed once per process. This method returns the allowed instance of WebAppManager for this process and constructs one if one has not yet been created.

Returns
This process's instance of WebAppManager.
bool WebAppManager::isDevicePortraitType ( )
inline

Returns whether, in the current device orientation, the rotated screen is taller than wide

Checks to see, with the host device info structure and current orientation, if the screen is being held in such a way that the "vertical" direction is taller than the "horizontal" direction.

Returns
true if the device is currently in a portrait orientation, false if in landscape mode.
void WebAppManager::markUniversalSearchReady ( )

Lets the bootup screen know that Universal Search is ready

The boot process waits until Universal Search is available before it considers itself "done". This lets it know that Universal Search is all set and ready to use.

See Also
WebAppManager::bootFinished()
void WebAppManager::monitorNativeProcessMemory ( const pid_t  pid,
const int  maxMemory,
pid_t  updateFromPid = 0 
)
protected

Missing implementation

Can't seem to find an implementation of this. Without that, it's unknown what this does.

Parameters
pidUnknown.
maxMemoryUnknown.
updateFromPidUnknown.
void WebAppManager::onDeleteHTML5Database ( const std::string &  domain)
protected

Handles an IPC message asking us to delete all HTML5 localStorage data for a given domain

Since we're managing web apps, it's quite possible they will store data in localStorage. This IPC call gives other processes a canonical way to delete that.

Could be quite dangerous, actually, if this is exposed to non-system apps. At this point, it's unknown if that is the case or not.

See Also
Palm::WebGlobal::deleteDatabasesForDomain()
Todo:

Confirm details of this once Palm::WebGlobal::deleteDatabasesForDomain() is publicly documented.

Ensure this IPC call is not exposed to non-system apps.

Parameters
domainThe domain to delete localStorage for.
void WebAppManager::onDisconnected ( )

Logs a message indicating that a remote server disconnected

Todo:

Figure out the purpose for this.

See if this can be removed entirely.

void WebAppManager::onGlobalProperties ( int  key)
protected

Unknown at the moment

Both the purpose and function of this are currently unknown.

Parameters
keyUnknown.
void WebAppManager::onInspectByProcessId ( const std::string &  processId)
protected

Calls WebAppBase::inspect() for an app

Unknown exactly what the function of this is.

Todo:
Document this fully once WebAppBase::inspect() is fully documented.
Parameters
processIdProcess ID of the app to inspect.
bool WebAppManager::onKillApp ( const std::string &  appId)
protected

Handles an IPC message to close an app

Closes all instances of a given app in response to something else asking us (via InterProcess Communication message) to close an app.

Parameters
appIdApp ID of the app to close.
Returns
true if one or more instances of the given app were open and have now been closed or false if the app was not already open.
void WebAppManager::onLaunchUrl ( const std::string &  url,
int  winType,
const std::string &  appDesc,
const std::string &  procId,
const std::string &  args,
const std::string &  launchingAppId,
const std::string &  launchingProcId 
)
protected

Handle an IPC message asking us to open a URL

This method is run whenever the Palm InterProcess Communication hands us a message from another process asking us to open a URL.

Parameters
urlURL to open.
winTypeType of window to open.
procIdProcess ID to use for the new WebPage being opened.
launchingAppIdApp ID of the app launching this URL.
launchingProcIdProcess ID of the app launching this URL.
void WebAppManager::onLaunchUrlChild ( const std::string &  url,
int  winType,
const std::string &  appDesc,
const std::string &  procId,
const std::string &  args,
const std::string &  launchingAppId,
const std::string &  launchingProcId,
int &  errorCode,
bool  isHeadless 
)
protected

Handle an IPC message asking us to launch a URL as a child window of another process

This method is run whenever the Palm InterProcess Communication hands us a message from another process asking us to open a URL as a child of another window.

Todo:
Document isHeadless parameter if we can find a reason for it to exist.
Parameters
urlURL to open.
winTypeType of window to open.
procIdProcess ID to use for the new WebPage being opened.
launchingAppIdApp ID of the app launching this URL.
launchingProcIdProcess ID of the app launching this URL.
errorCodeVariable (passed by reference) for this method to return an error code into if something goes wrong.
isHeadlessIgnored, at the moment. Purpose is currently unclear.
void WebAppManager::onListOfRunningAppsRequest ( bool  includeSysApps)
protected

Handles an IPC message asking for a list of all running processes

Sends back an IPC ViewHost_ListOfRunningAppsResponse with a single parameter - a JSON string laid out as follows:

{
running : [
{ id : [App ID], processid : [Process ID] },
...
],
returnValue : true
}
Parameters
includeSysAppsWhether or not to include system app processes (those without an app ID) in the list.
void WebAppManager::onMessageReceived ( const PIpcMessage &  msg)

Dispatch an InterProcess Communication message to the correct spot

Dispatches an IPC message to an app or to one of the onSomething methods of this class depending on the type of message.

Parameters
msgIPC message to process.
void WebAppManager::onProcMgrLaunch ( const std::string &  appDescString,
const std::string &  params,
const std::string &  launchingAppId,
const std::string &  launchingProcId 
)
protected

Handles an IPC message asking us to launch an app

Launches a web app given its App ID. Pretty simple. See ProcessManager::launch() for more information (it's actually quite well-documented already.

See Also
ProcessManager::launch()
Parameters
appDescStringApp ID of the web app to launch.
paramsJSON launch parameters to pass to the new app.
launchingAppIdApp ID of the app asking us to launch this new app.
launchingProcIdProcess ID of the app asking us to launch this new app (can be NULL).
void WebAppManager::onProcMgrLaunchBootTimApp ( const std::string &  appDescString)
protected

Appears to handles an IPC message asking us to launch a headless app at boot time

See Also
ProcessManager::launchBootTimeApp()
Todo:

Document this more fully once ProcessManager::launchBootTimeApp() is fully documented.

Add the missing "e" into the name so it matches ProcessManager.

Parameters
appDescStringApp ID of the app to launch.
void WebAppManager::onProcMgrLaunchChild ( const std::string &  appDescString,
const std::string &  params,
const std::string &  launchingAppId,
const std::string &  launchingProcId,
bool  isHeadless,
bool  isParentPdk 
)
protected

Handles an IPC message asking us to launch an app as a modal child of another app

Launches a web app given its App ID. Differs from WebAppManager::onProcMgrLaunch() in that the new app is set up as a child of the given launching parent and is launched in a modal configuration where it must be dismissed in some way before returning to the parent.

See Also
ProcessManager::launchModal()
Parameters
appDescStringApp ID of the web app to launch.
paramsJSON launch parameters to pass to the new app.
launchingAppIdApp ID of the app asking us to launch this new app.
launchingProcIdProcess ID of the app asking us to launch this new app (can be NULL).
isHeadlesstrue to create an app with no visible window, false to create a modal child app.
isParentPdkPass in true if the parent is a PDK app instead of a web app, false otherwise.
void WebAppManager::onRelaunchApp ( const std::string &  procId,
const std::string &  args,
const std::string &  launchingAppId,
const std::string &  launchingProcId 
)
protected

Finds an app and relaunches it

Unsure at the moment why an app would need to be relaunched.

Todo:
Document this further once WebAppBase::relaunch() is documented.
See Also
WebAppBase::relaunch()
Parameters
procIdProcess ID of the app to relaunch.
argsLaunch arguments to pass to the app when it relaunches.
launchingAppIdApp ID of the app requesting the relaunch.
launchingProcIdProcess ID of the app requesting the relaunch.
void WebAppManager::onSetOrientation ( int  orient)
protected

Run when device orientation has changed

Lets all open WebApps know that "up" has changed direction and that their displays need to rotate to match the screen's direction.

Parameters
orientNew orientation - one of Event::Orientation_Up, Event::Orientation_Down, Event::Orientation_Left, Event::Orientation_Right.
void WebAppManager::onShutdownEvent ( )
protected

Handles an IPC message to close all apps

If TARGET_DESKTOP is defined, this method deletes all open apps from memory then runs the garbage collector to clean up memory.

Either way, it then closes down the GLib main loop and returns.

void WebAppManager::onSuspendWebkitProcess ( bool *  result)
protected

Handle an IPC message from the SysMgr process telling us our process is going to be suspended

The SysMgr process is suspending this process. As soon as we return from this function the process will be suspended.

Parameters
resultVariable to place a result into to return to the caller. Always set to true in our implementation.
void WebAppManager::onSyncKillApp ( const std::string &  appId,
bool *  result 
)
protected

Handles an IPC message to close an app and notify the caller when done

Closes all instances of a given app in response to something else asking us (via InterProcess Communication message) to close an app.

Differs from WebAppManager::onKillApp() in that this one returns a result back to the caller to let them know that, yes, we did close everything asked of us.

See Also
WebAppManager::onKillApp()
Parameters
appIdApp ID of the app to close.
resultWhere to store the result of closing apps. Value will be set to true if one or more instances of the given app were open and have now been closed or false if the app was not already open.
void WebAppManager::onUiDimensionsChanged ( int  width,
int  height 
)
protected

Handle an IPC message telling us that output dimensions have changed

Todo:
Document this fully once we figure out what calls this so we can figure out what it's used for to figure out what it does.
Parameters
widthNew width.
heightNew height.
Event::Orientation WebAppManager::orientation ( ) const

Gets the device's current orientation

Returns which side of the display is currently facing up.

Returns
Current display orientation.
void WebAppManager::pastedFromClipboard ( const QString &  appId)

Doesn't do anything

Doesn't do anything right now.

Parameters
appIdApp ID of the app that pasted text from the clipboard.
void WebAppManager::performLowMemoryActions ( const bool  allowExpensive = false)
protected

Ask MemoryWatcher and the main SysMgr process to perform low memory actions

Todo:
Document this fully once MemoryWatcher::doLowMemActions() and SysMgr's low memory actions are fully documented.
Parameters
allowExpensiveGuessing this is whether or not to spend additional time to clean up memory due to running really low.
void WebAppManager::reportAppClosed ( const QString &  appId,
const QString &  processId 
)

Reports to the Luna statistics service that an app has been closed

Todo:
Figure out where this is being used and document this in a bit more detail so we know why it's needed.
Parameters
appIdApp ID of the app which has been closed.
processIdProcess ID of the app which has been closed.
void WebAppManager::reportAppLaunched ( const QString &  appId,
const QString &  processId 
)

Reports to the Luna statistics service that an app has been launched

Todo:
Figure out where this is being used and document this in a bit more detail so we know why it's needed.
Parameters
appIdApp ID of the app which has been launched.
processIdProcess ID of the app which has been launched.
void WebAppManager::run ( )
virtual

Reimplemented from SyncTask.

std::list< const ProcessBase * > WebAppManager::runningApps ( )

Get a list of process information for all running web apps

This class manages web apps running on the system. It tracks all apps and stores information about them. This method returns system information about them, such as their process IDs.

Returns
List of information about running web app processes.
std::list< const ProcessBase * > WebAppManager::runningApps ( WindowType::Type  winType)

Get a list of process information for all running web apps filtered to only those of a certain type

This class manages web apps running on the system. It tracks all apps and stores information about them. This method returns system information about them, such as their process IDs, but only those of a given type.

Parameters
winTypeType of app to look for.
Returns
List of information about running web app processes of the requested type.
void WebAppManager::sendAsyncMessage ( PIpcMessage *  msg)

Sends an InterProcess Communication message

Todo:
Document this once PIpcClient and PIpcChannelListener are publicly documented, since it appears this method uses functionality from one of them.
Parameters
msgIPC message to dispatch.
void WebAppManager::setActiveAppId ( const std::string &  id)
inline
const void WebAppManager::setHostInfo ( const HostInfo *  hostInfo)

Caches a version of the host device information structure

This structure contains information about the device that LunaSysMgr is running on, and is quite useful for checking what size the screen is. By caching it here, it doesn't have to be looked up every time it's used.

This can be retrieved from HostBase::instance()->getInfo().

See Also
HostBase::getInfo()
Parameters
hostInfoHost device info to cache.
void WebAppManager::setInSimulatedMouseEvent ( bool  val)
inline

Unknown at this time

Todo:

See if this is actually used anywhere and for what.

See if we can remove this.

Parameters
valUnknown at this time.
void WebAppManager::setJavascriptFlags ( const std::string &  flags)

Sets options in Palm::WebGlobal

Todo:
Document this once Palm::WebGlobal is publicly documented.
Parameters
flagsCommand-line-style flags to process (currently only –timeout_script_execution and –notimeout_script_execution seem to be specifically supported).
void WebAppManager::threadStarting ( )
protectedvirtual

Initializes WebAppManager

Initializes the various components of WebAppManager:

  • Reads in browser preferences from /etc/palm/browser.conf and /etc/palm/browser-platform.conf
  • Starts up BackupManager and starts listening for events from it.
  • Disables the garbage collector for two minutes to give us a chance to start up first.
  • Disables JavaScript timeouts until after we're done booting.
  • Sets the system locale from the value in Preferences::locale().
  • Connects to the Luna statistics reporting service.
  • Asks Luna stats to call WebAppManager::systemServiceConnectCallback() when com.palm.systemservice changes status.
  • Asks Luna stats to call WebAppManager::displayManagerConnectCallback() when com.palm.display changes status.
Todo:

Figure out why this isn't just put into WebAppManager::run(), since that appears to be the only place it's used, at least unless this class is derived from someplace.

can locale change without restarting sysmgr?

void WebAppManager::threadStopping ( )
protectedvirtual

Clean up WebAppManager as much as possible in preparation for having our thread stopped

Doesn't currently do anything.

void WebAppManager::windowedAppAdded ( WindowedWebApp app)
protectedvirtual

Add an already-launched app to the group of apps we're managing

Used internally by WebAppManager::launchUrl() and WebAppManager::launchUrlChild().

Parameters
appNew already-launched app to manage.
void WebAppManager::windowedAppKeyChanged ( WindowedWebApp app,
int  oldKey 
)
protectedvirtual

Lets us know that an app's key has changed

See Also
WindowedWebApp::getKey()
Todo:
Document this more fully once WindowedWebApp::getKey() is fully documented.
Parameters
appThe app that changed keys.
oldKeyThe key it used to use before the change.
void WebAppManager::windowedAppRemoved ( WindowedWebApp app)
protectedvirtual

Remove an app from the list of apps we're managing

Tells us not to manage an app anymore. Essentially just removes the tracking link between it and us.

Parameters
appApp that we should no longer manage.

Friends And Related Function Documentation

friend class AlertWebApp
friend
friend class CardWebApp
friend
friend class DashboardWebApp
friend
friend class MemoryWatcher
friend
friend class PalmSystem
friend
friend class ProcessManager
friend
friend class SysMgrWebBridge
friend
friend class SysMgrWebPage
friend
friend class WebAppBase
friend
friend class WindowedWebApp
friend

The documentation for this class was generated from the following files: