2012-10-10 59 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

相關問題