问题
I have this problem in dart
Refused to load the image 'https://**.png' because it violates the following Content Security Policy directive: "img-src 'self' data: chrome-extension-resource:".
when try to set src in image element
ImageButtonInputElement button = new ImageButtonInputElement();
button.className="button_element";
button.src=el["imageUrl"]; //like "https://**.png"
whit this manifest.json
"content_security_policy":"img-src https://server.example.org"
Someone would know help me?
Thanks
Sorry for my bad English
EDIT
I have the same problem with
<iframe id="iframe" src="https://server.example.org/example.html"></iframe>
Refused to frame https://server.example.org/example.html because it violates the following Content Security Policy directive: "frame-src 'self' data: chrome-extension-resource:".
回答1:
This is the solution I have adopted in the end:
var imgRequest = new HttpRequest();
imgRequest.open('GET', url);
imgRequest.responseType = 'blob';
imgRequest.onReadyStateChange.listen((var request){
if (imgRequest.readyState == HttpRequest.DONE &&
imgRequest.status == 200) {
FileReader reader = new FileReader();
reader.onLoad.listen((fe) {
button.src = reader.result;
});
reader.readAsDataUrl(imgRequest.response);
}
});
imgRequest.send();
回答2:
Apps cannot override the CSP. That manifest key is only for extensions.
See documentation for loading remote content for display.
Likewise, you have to use <webview> instead of iframes in a Chrome App.
来源:https://stackoverflow.com/questions/30544033/refused-to-load-the-image-in-a-chrome-app