| OLD | NEW |
| 1 <h1>Connect Apps with Web Intents</h1> | 1 <h1>Connect Apps with Web Intents</h1> |
| 2 | 2 |
| 3 | 3 |
| 4 <p> | 4 <p> |
| 5 <a href="http://webintents.org/">Web Intents</a> | 5 <a href="http://webintents.org/">Web Intents</a> |
| 6 allow your application to quickly communicate | 6 allow your application to quickly communicate |
| 7 with other applications on the user's system and inside their browser. | 7 with other applications on the user's system and inside their browser. |
| 8 Your application can register to handle specific user actions | 8 Your application can register to handle specific user actions |
| 9 such as editing images via the <code>manifest.json</code>; | 9 such as editing images via the <code>manifest.json</code>; |
| 10 your application can also invoke actions to be handled by other applications. | 10 your application can also invoke actions to be handled by other applications. |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 <h2 id="errors">Handling Errors and Exceptions</h2> | 191 <h2 id="errors">Handling Errors and Exceptions</h2> |
| 192 <p> | 192 <p> |
| 193 If your service application needs to signal to the client application | 193 If your service application needs to signal to the client application |
| 194 that an unrecoverable error has occurred, | 194 that an unrecoverable error has occurred, |
| 195 then your application will need | 195 then your application will need |
| 196 to call <code>postError</code> on the intent object. | 196 to call <code>postError</code> on the intent object. |
| 197 This will signal to the client’s onError callback | 197 This will signal to the client’s onError callback |
| 198 that something has gone wrong. | 198 that something has gone wrong. |
| 199 </p> | 199 </p> |
| 200 | 200 |
| 201 <h3>Client</h3> | 201 <h3 id="client">Client</h3> |
| 202 | 202 |
| 203 <pre> | 203 <pre> |
| 204 var intent = new WebKitIntent("http://webintents.org/edit", "image/png", "dataUr
i://"); | 204 var intent = new WebKitIntent("http://webintents.org/edit", "image/png", "dataUr
i://"); |
| 205 | 205 |
| 206 var onSuccess = function(data) {}; | 206 var onSuccess = function(data) {}; |
| 207 var onError = function() {}; | 207 var onError = function() {}; |
| 208 | 208 |
| 209 window.navigator.webkitStartActivity(intent, onSuccess, onError); | 209 window.navigator.webkitStartActivity(intent, onSuccess, onError); |
| 210 </pre> | 210 </pre> |
| 211 | 211 |
| 212 <h3>Service</h3> | 212 <h3 id="service">Service</h3> |
| 213 <pre> | 213 <pre> |
| 214 chrome.app.runtime.onLaunched(function(intent) { | 214 chrome.app.runtime.onLaunched(function(intent) { |
| 215 // App Launched | 215 // App Launched |
| 216 console.log(intent.action); | 216 console.log(intent.action); |
| 217 console.log(intent.type); | 217 console.log(intent.type); |
| 218 var data = intent.data; | 218 var data = intent.data; |
| 219 // Do something with the data; | 219 // Do something with the data; |
| 220 | 220 |
| 221 intent.postResult(newData); | 221 intent.postResult(newData); |
| 222 }); | 222 }); |
| 223 </pre> | 223 </pre> |
| 224 | 224 |
| 225 <p class="backtotop"><a href="#top">Back to top</a></p> | 225 <p class="backtotop"><a href="#top">Back to top</a></p> |
| OLD | NEW |