พร็อพเพอร์ตี้ไฟล์ Manifest externally_connectable
จะประกาศว่าส่วนขยาย แอป และหน้าเว็บใดที่สามารถ
เชื่อมต่อกับแอปของคุณผ่าน runtime.connect
และ runtime.sendMessage
สำหรับบทแนะนำเกี่ยวกับการส่งผ่านข้อความ โปรดดูที่ข้อความสำหรับส่วนขยายข้ามเครือข่ายและการรับส่งข้อความในแอปและการส่งข้อความจากหน้าเว็บ
กำลังเชื่อมต่อโดยไม่สามารถเชื่อมต่อภายนอกได้
หากไม่ได้ประกาศ externally_connectable
ในไฟล์ Manifest ของแอป ส่วนขยายและแอปทั้งหมดจะเชื่อมต่อได้ แต่จะไม่มีหน้าเว็บใดเชื่อมต่อได้ ดังนั้น เมื่ออัปเดตไฟล์ Manifest เพื่อใช้ 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
},
...
}
ข้อมูลอ้างอิง
คีย์ไฟล์ Manifest ที่เชื่อมต่อภายนอกได้จะมีพร็อพเพอร์ตี้ดังต่อไปนี้
ids
(อาร์เรย์ของสตริง) - ไม่บังคับรหัสของส่วนขยายหรือแอปที่ได้รับอนุญาตให้เชื่อมต่อ หากเว้นว่างไว้หรือไม่ได้ระบุ จะไม่มีส่วนขยายหรือแอปที่เชื่อมต่อได้
ไวลด์การ์ด
"*"
จะอนุญาตให้ส่วนขยายและแอปทั้งหมดเชื่อมต่อได้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
ในทุกกรณี