“拒绝加载图片”在Chrome应用中

时间:2015-05-30 08:32:02

标签: dart google-chrome-app content-security-policy

我在飞镖中有这个问题

  

拒绝加载图片'https://**.png',因为它违反了   遵循内容安全策略指令:“img-src'self'数据:   铬扩展资源:”

尝试在图像元素

中设置src时
ImageButtonInputElement button = new ImageButtonInputElement();
button.className="button_element";
button.src=el["imageUrl"]; //like "https://**.png"

使用manifest.json

"content_security_policy":"img-src https://server.example.org"

有人会知道帮帮我吗?

由于

抱歉我的英文不好

修改

我遇到同样的问题

<iframe id="iframe" src="https://server.example.org/example.html"></iframe>
  

拒绝框架   https://server.example.org/example.html   因为它违反了以下内容安全策略指令:   “frame-src'self'数据:chrome-extension-resource:”。

2 个答案:

答案 0 :(得分:3)

这是我最终采用的解决方案:

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();

答案 1 :(得分:2)

应用cannot override the CSP。该清单键仅用于扩展。

See documentation用于加载远程内容以供显示。

同样,您必须在Chrome应用中使用<webview>而不是iframe。