- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / docs / templates / articles / manifest / url_handlers.html
1 <h1 id="url_handlers">url_handlers</h1>
2
3 <p>
4 Used by <a href="../app_lifecycle.html#eventpage">packaged apps</a>
5 to specify URL patterns the app wants to intercept and handle. An app can
6 have multiple <code>url_handlers</code>, with each one having an identifier,
7 a URL pattern, and a title. Here's an example of how to specify URL handlers:
8 </p>
9
10 <pre data-filename="manifest.json">
11 "url_handlers": {
12   "view_foo_presentation": {
13     "matches": [
14       "https://www.foo.com/presentation/view/*"
15     ],
16     "title": "View Foo presentation"
17   },
18   "view_bar_presentation": {
19     "matches": [
20       "https://www.bar.com/view/slideshow/*"
21     ],
22     "title": "View bar presentation"
23   },
24   "edit_spreadsheet": {
25     "matches": [
26       "https://www.foo.com/spreadsheet/edit/*",
27       "https://www.bar.com/spreadsheet/edit/*"
28     ],
29     "title": "Edit spreadsheet"
30   }
31 }</pre>
32
33 <p>
34 Apps can only register to handle URL patterns within domains that they own,
35 that is, can prove ownership of as determined by the
36 <a href="https://chrome.google.com/webstore">Chrome Web Store</a>.
37 Apps that violate this requirement and attempt to register for handling external
38 URLs will be rejected by the Chrome Web Store on upload.
39 </p>
40 <p>
41 This automatically means that at least a complete domain should always be
42 specified for all the patterns under <code>matches</code> (otherwise ownership
43 cannot be verified).
44 </p>
45 <p>
46 Upon successful registration and installation, an app will be launched for all
47 matching navigations inside browser tabs as well as other apps. The app will
48 receive a new kind of the
49 <a href="../app_runtime.html#event-onLaunched">app.runtime.onLaunched</a>
50 event, with the launchData
51 object containing the matched handler's identifier (such as "view_foo_presentation"
52 above), the URL being navigated to, and the referrer's URL.
53 </p>
54 <p>
55 The <code>title</code> field is reserved for future use in all relevant UI elements.
56 It should describe the action that the app performs when launched with this type
57 of URL handler.
58 </p>