| OLD | NEW |
| 1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc.
Note: | 1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc.
Note: |
| 2 1) The <head> information in this page is significant, should be uniform | 2 1) The <head> information in this page is significant, should be uniform |
| 3 across api docs and should be edited only with knowledge of the | 3 across api docs and should be edited only with knowledge of the |
| 4 templating mechanism. | 4 templating mechanism. |
| 5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a | 5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a |
| 6 browser, it will be re-generated from the template, json schema and | 6 browser, it will be re-generated from the template, json schema and |
| 7 authored overview content. | 7 authored overview content. |
| 8 4) The <body>.innerHTML is also generated by an offline step so that this | 8 4) The <body>.innerHTML is also generated by an offline step so that this |
| 9 page may easily be indexed by search engines. | 9 page may easily be indexed by search engines. |
| 10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> | 10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 <pre>"intents": { | 254 <pre>"intents": { |
| 255 "http://webintents.org/view" : [{ | 255 "http://webintents.org/view" : [{ |
| 256 "title" : "RSS Feed Reader", | 256 "title" : "RSS Feed Reader", |
| 257 "type" : ["application/atom+xml", "application/rss+xml"] | 257 "type" : ["application/atom+xml", "application/rss+xml"] |
| 258 }] | 258 }] |
| 259 } | 259 } |
| 260 </pre> | 260 </pre> |
| 261 <p> | 261 <p> |
| 262 Your application will receive intent payload through the <code>onLaunched</code>
event. | 262 Your application will receive intent payload through the <code>onLaunched</code>
event. |
| 263 </p> | 263 </p> |
| 264 <pre>chrome.experimental.app.onLaunched(function(intent) { | 264 <pre>chrome.app.runtime.onLaunched(function(intent) { |
| 265 // App Launched | 265 // App Launched |
| 266 if(intent.action == "http://webinents.org/view" && | 266 if(intent.action == "http://webinents.org/view" && |
| 267 intent.type == "application/atom+xml") { | 267 intent.type == "application/atom+xml") { |
| 268 // obtain the ATOM feed data. | 268 // obtain the ATOM feed data. |
| 269 var data = intent.data; | 269 var data = intent.data; |
| 270 } | 270 } |
| 271 }); | 271 }); |
| 272 </pre> | 272 </pre> |
| 273 <h2 id="launching">Launching an app with a file</h2> | 273 <h2 id="launching">Launching an app with a file</h2> |
| 274 <p> | 274 <p> |
| 275 If your app handles the <code>view</code> intent, | 275 If your app handles the <code>view</code> intent, |
| 276 it is possible to launch it from the command line with a file as a parameter. | 276 it is possible to launch it from the command line with a file as a parameter. |
| 277 </p> | 277 </p> |
| 278 <pre>chrome.exe --app-id [app_id] [path_to_file] | 278 <pre>chrome.exe --app-id [app_id] [path_to_file] |
| 279 </pre> | 279 </pre> |
| 280 <p> | 280 <p> |
| 281 This will implicity launch your application with an intent payload populated | 281 This will implicity launch your application with an intent payload populated |
| 282 with the action set to "http://webintents.org/view", the type set to the | 282 with the action set to "http://webintents.org/view", the type set to the |
| 283 mime-type of the file and the data as a <code>FileEntry</code> object. | 283 mime-type of the file and the data as a <code>FileEntry</code> object. |
| 284 </p> | 284 </p> |
| 285 <pre>chrome.experimental.app.onLaunched(function(intent) { | 285 <pre>chrome.app.runtime.onLaunched(function(intent) { |
| 286 // App Launched | 286 // App Launched |
| 287 var data = intent.data; | 287 var data = intent.data; |
| 288 }); | 288 }); |
| 289 </pre> | 289 </pre> |
| 290 <h2 id="launching">Manipulating the file</h2> | 290 <h2 id="launching">Manipulating the file</h2> |
| 291 <p> | 291 <p> |
| 292 When your application is launched with a file as the parameter | 292 When your application is launched with a file as the parameter |
| 293 on the command-line, | 293 on the command-line, |
| 294 the <code>intent.data</code> property is a <code>FileEntry</code>. | 294 the <code>intent.data</code> property is a <code>FileEntry</code>. |
| 295 This is really cool because now you have a direct reference back to the physic
al | 295 This is really cool because now you have a direct reference back to the physic
al |
| 296 file on the disk, | 296 file on the disk, |
| 297 and you can write data back to it. | 297 and you can write data back to it. |
| 298 </p> | 298 </p> |
| 299 <pre>chrome.experimental.app.onLaunched(function(intent) { | 299 <pre>chrome.app.runtime.onLaunched(function(intent) { |
| 300 // App Launched | 300 // App Launched |
| 301 var data = intent.data; | 301 var data = intent.data; |
| 302 if(data instanceof FileEntry) { | 302 if(data instanceof FileEntry) { |
| 303 data.createWriter(function(writer) { | 303 data.createWriter(function(writer) { |
| 304 writer.onwriteend = function(e) { | 304 writer.onwriteend = function(e) { |
| 305 console.log('Write completed.'); | 305 console.log('Write completed.'); |
| 306 }; | 306 }; |
| 307 writer.onerror = function(e) { | 307 writer.onerror = function(e) { |
| 308 console.log('Write failed: ' + e.toString()); | 308 console.log('Write failed: ' + e.toString()); |
| 309 }; | 309 }; |
| 310 // Create a new Blob and write it to log.txt. | 310 // Create a new Blob and write it to log.txt. |
| 311 var bb = new BlobBuilder(); // Note: window.WebKitBlobBuilder in Chrome 12
. | 311 var bb = new BlobBuilder(); // Note: window.WebKitBlobBuilder in Chrome 12
. |
| 312 bb.append('Lorem Ipsum'); | 312 bb.append('Lorem Ipsum'); |
| 313 writer.write(bb.getBlob('text/plain')); | 313 writer.write(bb.getBlob('text/plain')); |
| 314 }); | 314 }); |
| 315 } | 315 } |
| 316 }); | 316 }); |
| 317 </pre> | 317 </pre> |
| 318 <h2 id="return">Returning data to calling application</h2> | 318 <h2 id="return">Returning data to calling application</h2> |
| 319 <p> | 319 <p> |
| 320 Lots of applications want to cooperate | 320 Lots of applications want to cooperate |
| 321 with the app that invoked them. | 321 with the app that invoked them. |
| 322 It's easy to send data back to the calling client | 322 It's easy to send data back to the calling client |
| 323 using <code>intent.postResult</code>: | 323 using <code>intent.postResult</code>: |
| 324 </p> | 324 </p> |
| 325 <pre>chrome.experimental.app.onLaunched(function(intent) { | 325 <pre>chrome.app.runtime.onLaunched(function(intent) { |
| 326 // App Launched | 326 // App Launched |
| 327 console.log(intent.action); | 327 console.log(intent.action); |
| 328 console.log(intent.type); | 328 console.log(intent.type); |
| 329 var data = intent.data; | 329 var data = intent.data; |
| 330 // Do something with the data; | 330 // Do something with the data; |
| 331 intent.postResult(newData); | 331 intent.postResult(newData); |
| 332 }); | 332 }); |
| 333 </pre> | 333 </pre> |
| 334 <h2 id="localize">Localizing your app title</h2> | 334 <h2 id="localize">Localizing your app title</h2> |
| 335 <p> | 335 <p> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 This will signal to the client’s onError callback | 369 This will signal to the client’s onError callback |
| 370 that something has gone wrong. | 370 that something has gone wrong. |
| 371 </p> | 371 </p> |
| 372 <a name="H3-8"></a><h3>Client</h3> | 372 <a name="H3-8"></a><h3>Client</h3> |
| 373 <pre>var intent = new WebKitIntent("http://webintents.org/edit", "image/png", "d
ataUri://"); | 373 <pre>var intent = new WebKitIntent("http://webintents.org/edit", "image/png", "d
ataUri://"); |
| 374 var onSuccess = function(data) {}; | 374 var onSuccess = function(data) {}; |
| 375 var onError = function() {}; | 375 var onError = function() {}; |
| 376 window.navigator.webkitStartActivity(intent, onSuccess, onError); | 376 window.navigator.webkitStartActivity(intent, onSuccess, onError); |
| 377 </pre> | 377 </pre> |
| 378 <a name="H3-9"></a><h3>Service</h3> | 378 <a name="H3-9"></a><h3>Service</h3> |
| 379 <pre>chrome.experimental.app.onLaunched(function(intent) { | 379 <pre>chrome.app.runtime.onLaunched(function(intent) { |
| 380 // App Launched | 380 // App Launched |
| 381 console.log(intent.action); | 381 console.log(intent.action); |
| 382 console.log(intent.type); | 382 console.log(intent.type); |
| 383 var data = intent.data; | 383 var data = intent.data; |
| 384 // Do something with the data; | 384 // Do something with the data; |
| 385 intent.postResult(newData); | 385 intent.postResult(newData); |
| 386 }); | 386 }); |
| 387 </pre> | 387 </pre> |
| 388 <p class="backtotop"><a href="#top">Back to top</a></p> | 388 <p class="backtotop"><a href="#top">Back to top</a></p> |
| 389 </div> | 389 </div> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 _uff=0; | 428 _uff=0; |
| 429 urchinTracker(); | 429 urchinTracker(); |
| 430 } | 430 } |
| 431 catch(e) {/* urchinTracker not available. */} | 431 catch(e) {/* urchinTracker not available. */} |
| 432 </script> | 432 </script> |
| 433 <!-- end analytics --> | 433 <!-- end analytics --> |
| 434 </div> | 434 </div> |
| 435 </div> <!-- /gc-footer --> | 435 </div> <!-- /gc-footer --> |
| 436 </div> <!-- /gc-container --> | 436 </div> <!-- /gc-container --> |
| 437 </body></html> | 437 </body></html> |
| OLD | NEW |