externally_connectable
マニフェスト プロパティでは、runtime.connect
と runtime.sendMessage
を介してアプリに接続できる拡張機能、アプリ、ウェブページを宣言します。
メッセージの受け渡しに関するチュートリアルについては、クロス拡張とアプリ メッセージングとウェブページからのメッセージの送信をご覧ください。
external_connectable を使用しない接続
アプリのマニフェストで externally_connectable
が宣言されていない場合、すべての拡張機能とアプリは接続できますが、ウェブページは接続できません。そのため、externally_connectable
を使用するようにマニフェストを更新する際に、"ids": ["*"]
を指定していない場合、他の拡張機能やアプリはアプリに接続できなくなります。これは意図しない結果である可能性があるため、注意してください。
manifest.json の例
{
"name": "My externally connectable app",
"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/*
とhttps://*.chromium.org/*
は有効ですが、<all_urls>
、https://*/*
、*://*.com/*
、さらにhttps://*.appspot.com/*
は有効ではありません。accepts_tls_channel_id
(ブール値) - 省略可true
の場合、runtime.connect
またはruntime.sendMessage
経由で送信されたメッセージでruntime.MessageSender.tlsChannelId
が設定されます(これらのメソッドがリクエストしている場合)。false
の場合、いかなる状況でもruntime.MessageSender.tlsChannelId
は設定されません。