供封装应用用于指定应用想要拦截和处理的网址格式。应用可以在此清单条目下定义多个网址处理程序,每个网址处理程序具有标识符、网址格式和标题。以下示例展示了如何指定 url_handlers
:
"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"
}
}
应用只能注册处理其拥有的网域内的网址格式,也就是说,可以证明对 Chrome 应用商店的所有权。如果应用违反此要求,并尝试注册以处理外部网址,则会在上传时被 Chrome 应用商店拒绝。
这自动意味着,应始终为 matches
下的所有格式指定至少一个完整网域。否则,无法验证所有权。
成功注册和安装后,系统会针对浏览器标签页和其他应用内所有匹配的导航启动应用。应用将收到一种新种类的 app.runtime.onLaunched 事件,其 launchData 对象包含所匹配处理程序的标识符(例如上面的“view_foo_presentation”)、要导航到的网址以及引荐来源网址的网址。
title
字段已预留,以供日后在所有相关界面元素中使用。它应该描述应用使用此类网址处理程序启动时执行的操作。