externally_connectable
マニフェスト プロパティは、runtime.connect と runtime.sendMessage を介して拡張機能に接続できる拡張機能、アプリ、ウェブページを宣言します。
メッセージの受け渡しに関するチュートリアルについては、クロス拡張とアプリ メッセージングとウェブページからのメッセージの送信をご覧ください。
external_connectable を使用しない接続
拡張機能のマニフェストで externally_connectable
が宣言されていない場合、すべての拡張機能とアプリは接続できますが、ウェブページは接続できません。そのため、externally_connectable
を使用するようにマニフェストを更新する際に、"ids": ["*"]
が指定されていない場合、他の拡張機能やアプリは拡張機能に接続できなくなります。これは意図しない結果である可能性があるため、念頭に置いてください。
manifest.json の例
{
"name": "My externally connectable extension",
"externally_connectable": {
// Extension and app IDs. If this field is not specified, no
// extensions or apps can connect.
"ids": [
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
...
// Alternatively, to match all extensions and apps, specify only
// "*".
"*"
],
// Match patterns for web pages. Does not affect content scripts.
// If this field is not specified, no webpages can connect.
"matches": [
"https://*.google.com/*",
"*://*.chromium.org/*",
...
],
// Indicates that the extension would like to make use of the TLS
// channel ID of the web page connecting to it. The web page must
// also opt to send the TLS channel ID to the extension via setting
// includeTlsChannelId to true in runtime.connect's connectInfo
// or runtime.sendMessage's options.
"accepts_tls_channel_id": false
},
...
}
リファレンス
external_connectable マニフェスト キーのプロパティは次のとおりです。
ids
(文字列の配列) - 省略可接続が許可されている拡張機能またはアプリの ID。空または未指定の場合、拡張機能やアプリは接続できません。
ワイルドカード
"*"
を使用すると、すべての拡張機能とアプリの接続が許可されます。matches
(文字列の配列) - 省略可接続が許可されているウェブページの URL パターン。コンテンツ スクリプトには影響しません。空白または未指定の場合、どのウェブページも接続できません。
パターンには、ワイルドカード ドメインや、(有効な)トップレベル ドメインのサブドメインを含めることはできません。
*://google.com/*
とhttp://*.chromium.org/*
は有効ですが、<all_urls>
、http://*/*
、*://*.com/*
、さらにhttp://*.appspot.com/*
は有効ではありません。accepts_tls_channel_id
(ブール値) - 省略可true
の場合、runtime.connect または runtime.sendMessage を介して送信されたメッセージにより、runtime.MessageSender.tlsChannelId が設定されます。false
の場合、いかなる状況でも runtime.MessageSender.tlsChannelId が設定されることはありません。