| <h1 id="url_handlers">url_handlers</h1> |
| |
| <p> |
| Used by <a href="../app_lifecycle#eventpage">packaged apps</a> |
| to specify URL patterns the app wants to intercept and handle. An app can |
| define multiple URL handlers under this manifest entry, each having an identifier, |
| a URL pattern, and a title. |
| Here's an example of how to specify <code>url_handlers</code>: |
| </p> |
| |
| <pre data-filename="manifest.json"> |
| "url_handlers": { |
| "view_foo_presentation": { |
| "matches": [ |
| "https://www.foo.com/presentation/view/*" |
| ], |
| "title": "View Foo presentation" |
| }, |
| "view_bar_presentation": { |
| "matches": [ |
| "https://www.bar.com/view/slideshow/*" |
| ], |
| "title": "View bar presentation" |
| }, |
| "edit_spreadsheet": { |
| "matches": [ |
| "https://www.foo.com/spreadsheet/edit/*", |
| "https://www.bar.com/spreadsheet/edit/*" |
| ], |
| "title": "Edit spreadsheet" |
| } |
| }</pre> |
| |
| <p> |
| Apps can only register to handle URL patterns within domains that they own, |
| that is, can prove ownership of as determined by the |
| <a href="https://chrome.google.com/webstore">Chrome Web Store</a>. |
| Apps that violate this requirement and attempt to register for handling external |
| URLs will be rejected by the Chrome Web Store on upload. |
| </p> |
| <p> |
| This automatically means that at least a complete domain should always be |
| specified for all the patterns under <code>matches</code> (otherwise ownership |
| cannot be verified). |
| </p> |
| <p> |
| Upon successful registration and installation, an app will be launched for all |
| matching navigations inside browser tabs as well as other apps. The app will |
| receive a new kind of the |
| <a href="../app_runtime#event-onLaunched">app.runtime.onLaunched</a> |
| event, with the launchData |
| object containing the matched handler's identifier (such as "view_foo_presentation" |
| above), the URL being navigated to, and the referrer's URL. |
| </p> |
| <p> |
| The <code>title</code> field is reserved for future use in all relevant UI elements. |
| It should describe the action that the app performs when launched with this type |
| of URL handler. |
| </p> |