My favorites | Sign in
Project Logo
             
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">

<!--
Copyright 2007, Google Inc.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of Google Inc. nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<html>
<head>
<title>Desktop API</title>
<link rel="stylesheet" type="text/css" href="gears.css" />
</head>

<body>

<h1>Desktop API</h1>

<div id="pagecontent">

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

<h4>Permission</h4>

<p>Does not require user permission.</p>


<h2 id="example">Example</h2>

<pre><code>&lt;script type="text/javascript" src="<a href='tools.html#gears_init'>gears_init.js</a>"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
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');

function openFilesCallback(files) {
alert('User selected ' + files.length + ' files.');
}
desktop.openFiles(openFilesCallback);
&lt;/script&gt;</code></pre>


<h2 id="interfaces">Interfaces</h2>

<pre><code><a href="#Desktop">Desktop class</a>
void <b>createShortcut</b>(name, url, icons, [description])
Object <b>extractMetaData</b>(blob)
Object <b>getDragData</b>(event, flavor)
void <b>openFiles</b>(callback, [options])
void <b>setDropEffect</b>(event, dropEffect)</code></pre>

<pre><code><a href="#OpenFilesCallback">OpenFilesCallback</a>(<a
href="#File">File</a>[] files)</code></pre>

<pre><code><a href="#OpenFileOptions">OpenFileOptions class</a>
attribute bool <b>singleFile</b>
attribute string[] <b>filter</b></code></pre>

<pre><code><a href="#File">File class</a>
readonly attribute string <b>name</b>
readonly attribute Blob <b>blob</b></code></pre>


<h2 id="Desktop">Desktop class</h2>

<h3>Methods</h3>

<table>
<tr class="odd">
<th colspan="2"><code>createShortcut(name, url, icons,
[description])</code></th>
</tr>
<tr class="odd">
<td width="113">Summary:</td>
<td width="550" class="odd">
Creates a desktop shortcut for launching a web application.
</td>
</tr>
<tr class="odd">
<td>Parameters:</td>
<td class="odd">
<code>name</code> - The user-visible name of the shortcut. It cannot contain any of these characters:
<code>"\/:*?&lt;&gt;|</code>
<!-- " This fixes syntax highlighting problems caused by the unmatched
quotation mark above. -->
<br>
<code>url</code> - The address to launch when the user opens the shortcut.
The URL must be in the same origin as the calling page.
Note that for technical reasons, on Windows Mobile, any query parameters
are stripped from the URL.
<br>
<code>icons</code> - An object containing one or more of these named
properties: <code>128x128</code>, <code>48x48</code>,
<code>32x32</code>, <code>16x16</code>. The value of each property must
be the URL of a PNG-formatted image with dimensions matching the
property name. A <a
href="http://en.wikipedia.org/wiki/Data:_URI_scheme">data URL</a>
containing base64-encoded PNG data can also be used.
<br>
<code>description</code> - Optional. Additional text to display in the
confirmation dialog.
</td>
</tr>
<tr class="odd">
<td>Details:</td>
<td class="odd">
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.
<br><br>
The shortcut will launch the same web browser that created the shortcut.
<br><br>
The <code>url</code> and <code>icons</code> values can be relative or
absolute URLs. Relative URLs are resolved using the caller's location.
<br><br>
Calling this API will trigger a confirmation dialog. The dialog will
use the 32x32 icon if it exists, or else the closest size available.
<br><br>
Users can choose to never allow a particular named shortcut for a given
origin, in which case the dialog will not be displayed.
<br><br>
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.
<br><br>
Any query in the shortcut URL must not contain literal percent symbols,
encoded (%25) or otherwise. Any such characters will be stripped from the
URL.
</td>
</tr>
</table>

<table>
<tr class="odd">
<th colspan="2"><code>extractMetaData(blob)</code></th>
</tr>
<tr class="odd">
<td width="113">Summary:</td>
<td width="550" class="odd">
Calculates metadata (such as MIME type) from a Blob's contents. For
example, if the Blob contains image data in a well-known encoding (such
as PNG or JPEG), this will return the image's width and height.
</td>
</tr>
<tr class="odd">
<td>Parameters:</td>
<td class="odd">
<code>blob</code> - The Blob to examine.
<br>
</td>
</tr>
<tr class="odd">
<td>Return value:</td>
<td class="odd">
A JavaScript Object (i.e. a key-value map). Currently, four keys are
provided (although all keys are optional -- no key is guaranteed to be
present on all Blobs):
<ul>
<li>&quot;mimeType&quot;, which can have values such as
&quot;image/jpeg&quot;, &quot;image/png&quot;, or
&quot;application/octet-stream&quot;.
<li>&quot;imageWidth&quot;, only defined for Blobs that contain image
data, will have an integer value that is the width of that image.
<li>&quot;imageHeight&quot; is similar to &quot;imageWidth&quot;.
<li>&quot;exifOrientation&quot;, only defined for Blobs that contain
JPEG image data that have Exif metadata. The value is an integer
between 1 and 8 (inclusive), as per the
<a href="http://www.exif.org/Exif2-2.PDF">Exif 2.2 specification</a>
(section 4.6.4.A under "Orientation").
</ul>
</td>
</tr>
</table>

<table>
<tr class="odd">
<th colspan="2"><code>getDragData(event, flavor)</code></th>
</tr>
<tr class="odd">
<td width="113">Summary:</td>
<td width="550" class="odd">
Returns the data that is on the OS's drag-and-drop clipboard. This
method is valid to call only during processing of a drag-and-drop event
(such as during ondragenter, ondragover, ondragleave or ondrop). This
method is analogous to HTML5's DataTransfer.getData method.
</td>
</tr>
<tr class="odd">
<td>Parameters:</td>
<td class="odd">
<code>event</code> - The drag-and-drop event. Typically, just pass
window.event. On Firefox, pass the event that is given as an argument
of the event handler.
<br>
<code>flavor</code> - The flavor of data requested. Currently, the only
supported flavor is &quot;application/x-gears-files&quot;, to get
File data.
<br>
</td>
</tr>
<tr class="odd">
<td>Return value:</td>
<td class="odd">
A JavaScript Object (i.e. a key-value map). One such key is
&quot;count&quot;, which is the number of objects being dragged.
Another key, only present during an ondrop event and not other events,
is &quot;files&quot;, which will return the actual File objects being
drag-and-dropped.
</td>
</tr>
</table>

<table>
<tr class="odd">
<th colspan="2"><code>openFiles(callback, [options])</code></th>
</tr>
<tr class="odd">
<td width="113">Summary:</td>
<td width="550" class="odd">
Provides user-driven access to files on the client machine.
Presents the user with a file selection dialog for choosing files
to make available to the application.
</td>
</tr>
<tr class="odd">
<td>Parameters:</td>
<td class="odd">
<code>callback</code> - After the user has selected files, this function
is invoked with an array of the files that were selected.
This function must conform to the
<a href="#OpenFilesCallback">OpenFilesCallback</a> interface.
<br><br>
<code>options</code> - An optional parameter of type
<a href="#OpenFileOptions">OpenFileOptions</a>.
Provides control over file selection options.
<br>
</td>
</tr>
<tr class="odd">
<td>Details:</td>
<td class="odd">
The <code>openFiles</code> call will immediately return after presenting
a file selection dialog to the user. It does not wait for the user to
select files, nor does it wait for the dialog to be closed.
<br><br>
Once the user has selected files, the callback is invoked with an array
of the files which were selected.
<br><br>
If the user cancels the dialog without selecting any files, the
callback is invoked with an empty array.
</td>
</tr>
</table>

<table>
<tr class="odd">
<th colspan="2"><code>setDropEffect(event, dropEffect)</code></th>
</tr>
<tr class="odd">
<td width="113">Summary:</td>
<td width="550" class="odd">
Sets the dropEffect (i.e. the cursor) in response to a drag-and-drop
event. This method is valid to call only during processing of a
drag-and-drop event (such as during ondragenter, ondragover, ondragleave
or ondrop). This method is analogous to HTML5's DataTransfer.dropEffect
setter.
</td>
</tr>
<tr class="odd">
<td>Parameters:</td>
<td class="odd">
<code>event</code> - The drag-and-drop event. Typically, just pass
window.event. On Firefox, pass the event that is given as an argument
of the event handler.
<br>
<code>dropEffect</code> - Either the value &quot;copy&quot;, or
&quot;none&quot;.
<br>
</td>
</tr>
</table>


<h2 id="OpenFilesCallback">OpenFilesCallback interface</h2>

<table>
<tr class="odd">
<th colspan="2"><code>void OpenFilesCallback(<a
href="#File">File</a>[] files)</code></th>
</tr>
<tr class="odd">
<td width="113">Summary:</td>
<td width="550" class="odd">
A method matching this signature should be passed as the first argument
to openFiles. It will be invoked with an array of the files which were
selected.
</td>
</tr>
<tr class="odd">
<td>Parameters:</td>
<td class="odd">
<code>files</code> - An array containing the files that have been
selected. If the user dismisses the file selection dialog without
choosing any files, this array will be empty.
</td>
</tr>
</table>


<h2 id="OpenFileOptions">OpenFileOptions class</h2>

<h3>Attributes</h3>

<table>
<tr class="odd">
<th width="158">Attribute</th>
<th width="109">Type</th>
<th width="432">Description</th>
</tr>
<tr class="odd">
<td><strong>singleFile</strong></td>
<td class="odd">bool</td>
<td class="odd">By default, the user may select multiple files. If
true, the user is limited to selecting only one file.</td>
</tr>
<tr class="odd">
<td><strong>filter</strong></td>
<td class="odd">string[]</td>
<td class="odd">By default, all files on the local disk are selectable.
If a filter is provided, only files matching the filter are selectable.
The user can turn the filter off, so be aware that selected files
may not match the filter. The filter is an array of internet
content types and/or file extensions.<br><br>
Example: <code>['text/html', 'text/plain', '.mov']</code><br><br>
Partial content types like 'image/*' are not currently supported.</td>
</tr>
</table>


<h2 id="File">File class</h2>

<h3>Attributes</h3>

<table>
<tr class="odd">
<th width="158">Attribute</th>
<th width="109">Type</th>
<th width="432">Description</th>
</tr>
<tr class="odd">
<td><strong>name</strong></td>
<td class="odd">readonly string</td>
<td class="odd">The name of the file, excluding the path.</td>
</tr>
<tr class="odd">
<td><strong>blob</strong></td>
<td class="odd">readonly Blob</td>
<td class="odd">The contents of the file.</td>
</tr>
</table>


</div>
</body>
</html>
Show details Hide details

Change log

r3411 by gears.daemon on Nov 22, 2009   Diff
[Author: nigeltao]

API documentation updates for
canvas.rotate and Exif orientation.

PRESUBMIT=passed
R=noel
CC=gears-eng@googlegroups.com
DELTA=78  (75 added, 0 deleted, 3 changed)
OCL=13535083
SCL=13663276
Go to: 
Project members, sign in to write a code review

Older revisions

r3355 by gears.daemon on Jun 10, 2009   Diff
[Author: nigeltao]

SDK documentation update for 0.5.21.

PRESUBMIT=passed
...
r3215 by gears.daemon on Feb 13, 2009   Diff
[Author: steveblock]

Escapes percent symbols in shortcut
URLs when they are not already part of
an escape sequence.
...
r2907 by gears.daemon on Oct 17, 2008   Diff
[Author: steveblock]

Strips '?' and following characters
from shortcut URLs on WinCE. This is
to prevent possible exploits due to
...
All revisions of this file

File info

Size: 14008 bytes, 393 lines

File properties

svn:mime-type
text/html
Hosted by Google Code