Desktop API

The Desktop module provides an interface for accessing desktop related functionality, such as creating shortcuts.

Permission

Does not require user permission.

Example

<script type="text/javascript" src="gears_init.js"></script>
<script type="text/javascript">
var desktop = google.gears.factory.create('beta.desktop');
desktop.createShortcut("Test Application",
                       "http://example.com/index.html",
                       {"128x128": "http://example.com/icon128x128.png",
                        "48x48": "http://example.com/icon48x48.png",
                        "32x32": "http://example.com/icon32x32.png",
                        "16x16": "http://example.com/icon16x16.png"},
                        "An application at http://example.com/index.html");
</script>

Classes

Desktop class
    bool createShortcut(name, url, icons, [description])


Desktop class

Methods

createShortcut(name, url, icons, [description])
Summary: Creates a desktop shortcut for launching a web application.
Parameters: name - The user-visible name of the shortcut. It cannot contain any of these characters: "\/:*?<>|
url - The address to launch when the user opens the shortcut. The URL must be in the same origin as the calling page.
icons - An object containing one or more of these named properties: 128x128, 48x48, 32x32, 16x16. The value of each property must be the URL of a PNG-formatted image with dimensions matching the property name. A data URL containing base64-encoded PNG data can also be used.
description - Optional. Additional text to display in the confirmation dialog.
Details: The icon sizes were chosen to meet the needs of a variety of platforms. If an application wants its icons to look as good as possible on all platforms, it should provide all valid sizes.

The shortcut will launch the same web browser that created the shortcut.

The url and icons values can be relative or absolute URLs. Relative URLs are resolved using the caller's location.

Calling this API will trigger a confirmation dialog. The dialog will use the 32x32 icon if it exists, or else the closest size available.

Users can choose to never allow a particular named shortcut for a given origin, in which case the dialog will not be displayed.

Shortcuts created through this API cannot overwrite an existing shortcut with the same name, and such attempts fail silently. This restriction may be relaxed in a future version of Gears.