2012-10-10 48 views
8

我正在开发一个Chrome插件,其中从几个域加载外部脚本。我已经查阅了关于如何允许这些域的文档和一些教程。如何在Chrome插件中将多个域添加到content_security_policy?

的文档我检查:

这一切说了同样的,从中我创造了manifest.json的规则:

{ 
    // .. general settings 
    "content_security_policy": "script-src 'self' https://ajax.googleapis.com http://mysite.com; object-src 'self'" 
} 

对此回应铬如下:

Could not load extension from '/Users/itarato/Desktop/DRC Tutorial Client'. 
Invalid value for 'content_security_policy': Both 'script-src' and 'object-src' directives must be specified (either explicitly, or implicitly via 'default-src'), and both must whitelist only secure resources. 
You may include any of the following sources: "'self'", "'unsafe-eval'", "http://127.0.0.1", "http://localhost", or any "https://" or "chrome-extension://" origin. 
For more information, see http://developer.chrome.com/extensions/contentSecurityPolicy.html 

当然,我已经试过几种组合,但所有失败了。它只适用于我只使用一个域。我如何添加更多?

回答

12

您拥有的语法很好,问题在于您的http://mysite.com源不安全。 Chrome错误消息的“仅白名单安全资源”部分就是指这一点。您需要使用https://mysite.com

+0

非常感谢你:)完全错过了它是指https。 – itarato

相关问题