Re: Using externally_connectable to Send Data from WWW to Chrome Extension

806 views
Skip to first unread message
Message has been deleted

Ben McCann

unread,
Sep 8, 2013, 3:13:10 PM9/8/13
to chromium-...@chromium.org
Did you figure this out?  I'm having quite a bit of trouble as well.


On Thursday, August 22, 2013 3:25:37 AM UTC-7, eversonjw wrote:
I was provided this as a solution to send data/messages from WWW to a Chrome Extension (for storage in LocalStorage). However, it appears to not be working - any ideas/suggestions?

manifest.json

"externally_connectable": {
  "matches": ["*://*.example.com/*"]
}
content_script.js

chrome.runtime.sendMessage("your extension id will be here", 
                           {data: { anyDataKey : "example"}});
background.js

chrome.runtime.onMessageExternal.addListener(
  function(request, sender, sendResponse) {
    if (request.data)
      alert("Hi, there is message from the website");
      var data = request.data;
      // now the data is on your extension side, just save it to extension's localstorage.
  });

Ben McCann

unread,
Sep 8, 2013, 3:21:09 PM9/8/13
to chromium-...@chromium.org
If I inspect my background view then I see:

    Port: Could not establish connection. Receiving end does not exist. 


--
You received this message because you are subscribed to a topic in the Google Groups "Chromium-extensions" group.
To unsubscribe from this topic, visit https://groups.google.com/a/chromium.org/d/topic/chromium-extensions/ZDckH5Qj0uI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/eb018bbe-a96a-49d9-a416-5b02fa9f8d61%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/groups/opt_out.



--
about.me/benmccann
Message has been deleted

Ben McCann

unread,
Sep 8, 2013, 4:31:58 PM9/8/13
to chromium-...@chromium.org
I figured out my problem. It's because I'm using sendMessage from an iframe. I started a new thread on that here:

-Ben


On Sunday, September 8, 2013 12:25:56 PM UTC-7, eversonjw wrote:
No sorry, I abandoned this in favour of on-domain localStorage and a custom API.

If you do ever manage to figure it out I'd be interested to see a code example.
Reply all
Reply to author
Forward
0 new messages