OLD | NEW |
1 <h1>Connect Apps with Web Intents</h1> | 1 <h1>Connect Apps with Web Intents</h1> |
2 | 2 |
3 <p class="warning"> | 3 <p class="warning"> |
4 <b>Warning: </b> | 4 <b>Warning: </b> |
5 Deprecated in Chrome 24. | 5 Deprecated in Chrome 24. |
6 Web intents are no longer supported. | 6 Web intents are no longer supported. |
7 </p> | 7 </p> |
8 | 8 |
9 <p> | 9 <p> |
10 <a href="http://webintents.org/">Web Intents</a> | 10 <a href="http://webintents.org/">Web Intents</a> |
11 allow your application to quickly communicate | 11 allow your application to quickly communicate |
12 with other applications on the user's system and inside their browser. | 12 with other applications on the user's system and inside their browser. |
13 Your application can register to handle specific user actions | 13 Your application can register to handle specific user actions |
14 such as editing images via the <code>manifest.json</code>; | 14 such as editing images via the <code>manifest.json</code>; |
15 your application can also invoke actions to be handled by other applications. | 15 your application can also invoke actions to be handled by other applications. |
16 </p> | 16 </p> |
17 | 17 |
18 <p>Chrome Apps use Web Intents as their primary mechanism for inter-app | 18 <p>Chrome Apps use Web Intents as their primary mechanism for inter-app |
19 communication.</p> | 19 communication.</p> |
20 | 20 |
21 <p class="note"> | 21 <p class="note"> |
22 <b>API Samples: </b> | 22 <b>API Samples: </b> |
23 Want to play with the code? | 23 Want to play with the code? |
24 Check out the | 24 Check out the |
25 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/webinten
ts">webintents</a> sample. | 25 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/
webintents">webintents</a> sample. |
26 </p> | 26 </p> |
27 | 27 |
28 <h2 id="register">Register your app to handle an action</h2> | 28 <h2 id="register">Register your app to handle an action</h2> |
29 | 29 |
30 <p class="warning"> | 30 <p class="warning"> |
31 <b>Warning: </b> | 31 <b>Warning: </b> |
32 Deprecated in Chrome 24. | 32 Deprecated in Chrome 24. |
33 Web intents are no longer supported. | 33 Web intents are no longer supported. |
34 </p> | 34 </p> |
35 | 35 |
36 <p> | 36 <p> |
37 You must supply the intent in the manifest: | 37 You must supply the intent in the manifest: |
38 </p> | 38 </p> |
39 | 39 |
40 <pre data-filename="manifest.json"> | 40 <pre data-filename="manifest.json"> |
41 "intents":{ | 41 "intents":{ |
42 "http://webintents.org/edit" : [{ | 42 "http://webintents.org/edit" : [{ |
43 "title" : "Best Image editing app", | 43 "title" : "Best Image editing app", |
44 "type" : ["image/*"] | 44 "type" : ["image/*"] |
45 }] | 45 }] |
46 } | 46 } |
47 </pre> | 47 </pre> |
48 | 48 |
49 <p> | 49 <p> |
50 Unlike extensions and hosted apps, Chrome applications do not | 50 Unlike extensions and hosted apps, Chrome applications do not |
51 need a "href" attribute in the manifest declaration, this is | 51 need a "href" attribute in the manifest declaration, this is |
52 because Chrome Apps have a single entry point for | 52 because Chrome Apps have a single entry point for |
53 launch - the <code>onLaunched</code> event. | 53 launch - the <code>onLaunched</code> event. |
54 </p> | 54 </p> |
55 | 55 |
56 <h2 id="content">Handling content types</h2> | 56 <h2 id="content">Handling content types</h2> |
57 | 57 |
58 <p class="warning"> | 58 <p class="warning"> |
59 <b>Warning: </b> | 59 <b>Warning: </b> |
60 Deprecated in Chrome 24. | 60 Deprecated in Chrome 24. |
61 Web intents are no longer supported. | 61 Web intents are no longer supported. |
62 </p> | 62 </p> |
63 | 63 |
64 <p> | 64 <p> |
65 Your application can be the user's preferred choice for handling a file type. | 65 Your application can be the user's preferred choice for handling a file type. |
66 For example, your application could handle viewing images or viewing pdfs. | 66 For example, your application could handle viewing images or viewing pdfs. |
67 You must supply the intent in the manifest | 67 You must supply the intent in the manifest |
68 and use the "http://webintents.org/view" action: | 68 and use the "http://webintents.org/view" action: |
69 </p> | 69 </p> |
70 <p>To be able declare your application's ability to view RSS and ATOM | 70 <p>To be able declare your application's ability to view RSS and ATOM |
71 feeds, you would add the following to your manifest. | 71 feeds, you would add the following to your manifest. |
72 </p> | 72 </p> |
73 <pre data-filename="manifest.json"> | 73 <pre data-filename="manifest.json"> |
74 "intents": { | 74 "intents": { |
75 "http://webintents.org/view" : [{ | 75 "http://webintents.org/view" : [{ |
76 "title" : "RSS Feed Reader", | 76 "title" : "RSS Feed Reader", |
77 "type" : ["application/atom+xml", "application/rss+xml"] | 77 "type" : ["application/atom+xml", "application/rss+xml"] |
78 }] | 78 }] |
79 } | 79 } |
80 </pre> | 80 </pre> |
(...skipping 23 matching lines...) Expand all Loading... |
104 | 104 |
105 <p> | 105 <p> |
106 If your app handles the <code>view</code> intent, | 106 If your app handles the <code>view</code> intent, |
107 it is possible to launch it from the command line with a file as a parameter. | 107 it is possible to launch it from the command line with a file as a parameter. |
108 </p> | 108 </p> |
109 <pre> | 109 <pre> |
110 chrome.exe --app-id [app_id] [path_to_file] | 110 chrome.exe --app-id [app_id] [path_to_file] |
111 </pre> | 111 </pre> |
112 <p> | 112 <p> |
113 This will implicity launch your application with an intent payload populated | 113 This will implicity launch your application with an intent payload populated |
114 with the action set to "http://webintents.org/view", the type set to the | 114 with the action set to "http://webintents.org/view", the type set to the |
115 mime-type of the file and the data as a <code>FileEntry</code> object. | 115 mime-type of the file and the data as a <code>FileEntry</code> object. |
116 </p> | 116 </p> |
117 <pre> | 117 <pre> |
118 chrome.app.runtime.onLaunched(function(intent) { | 118 chrome.app.runtime.onLaunched(function(intent) { |
119 // App Launched | 119 // App Launched |
120 var data = intent.data; | 120 var data = intent.data; |
121 }); | 121 }); |
122 </pre> | 122 </pre> |
123 | 123 |
124 <h2 id="launching">Manipulating the file</h2> | 124 <h2 id="launching">Manipulating the file</h2> |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 console.log(intent.action); | 272 console.log(intent.action); |
273 console.log(intent.type); | 273 console.log(intent.type); |
274 var data = intent.data; | 274 var data = intent.data; |
275 // Do something with the data; | 275 // Do something with the data; |
276 | 276 |
277 intent.postResult(newData); | 277 intent.postResult(newData); |
278 }); | 278 }); |
279 </pre> | 279 </pre> |
280 | 280 |
281 <p class="backtotop"><a href="#top">Back to top</a></p> | 281 <p class="backtotop"><a href="#top">Back to top</a></p> |
OLD | NEW |