Reputation: 770
I develop one Chrome extension and one Chrome app.
I launch Chrome extension with Chrome startup args "--load-extension" and also "--load-and-launch-app" for Chrome app, so I do not know the extension id of these two Chrome plug-ins. And extension on different machine may have different id.
Now I want to establish a connection between the extension and the app. I wanna use chrome.runtime.sendMessage, but I don't know how to get the id of Chrome extension in Chrome app or the id of Chrome app in Chrome extension.
How can I achieve this?
Upvotes: 2
Views: 5149
Reputation: 5659
If your chrome extension/app manifest file defined a specific key
key, it will have always the same ID.
For instance, let's say you've set a manifest file that looks like:
{
"manifest_version": 2,
"name": "My Chrome Extension",
"version": "1.0",
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC5Sq1NeTWSJlXL55lPcec6Fi5RBDBwjOsuvlypR8BkBsSN6e+nPiOBT432mA6xHDQT2SiAKK4jtoUcfdUrvR+4J5K1/3UmCrTqNQ0773sD14W+u9WDowsIwehh0Pso1jxTdoM31JRExRKBI8/w2Sup7zr40dLmV+bVAnT9ruwtuwIDAQAB",
...
}
Your Chrome Extension ID will always be fhbjgbiflinjbdggehcddcbncdddomop
.
You may want to read the official documentation at http://developer.chrome.com/extensions/manifest/key.html to learn more about it.
And if you really want to know how it works, you can also read Google Chrome - Alphanumeric hashes to identify extensions and http://blog.roomanna.com/12-14-2010/getting-an-extensions-id
Upvotes: 4