Using chrome extension API in a outer webpage.

22 views
Skip to first unread message

unread,
Jul 18, 2016, 5:05:14 AM7/18/16
to Chromium-Apps-Announce
Hi,everybody:

    I have a chrome extension. In this chrome extension,I visit a webpage that out of this extension using window.open function. What I want to do is using chrome.management in the webpage. But chrome.management API could only be used in a chrome extension and need  declaration in manifest.json file. Is there a way to use chrome.management API in a webpage that being visited by a chrome extension(this webpage is out of extension).

    Thanks!

    wangzhao
 
    

Devlin Cronin

unread,
Jul 18, 2016, 4:53:07 PM7/18/16
to Chromium-Apps-Announce
There's no way of doing this directly from the webpage for security reasons (we don't want to expose many extension APIs directly to web pages).  The workaround would be to use chrome.runtime.sendMessage (one of the few APIs we do expose) to send a message from the web page to the extension, and then have the extension act on it.  Note that if you do this, you should absolutely check the sender property in runtime.onMessageExternal and validate that the message is something you expect.  Otherwise you could open a big security hole for your users.

unread,
Jul 18, 2016, 9:10:05 PM7/18/16
to Chromium-Apps-Announce
Thanks.

在 2016年7月19日星期二 UTC+8上午4:53:07,Devlin Cronin写道:
Reply all
Reply to author
Forward
0 new messages