chrome.wallpaper.setWallpaper not working

chrome.wallpaper.setWallpaper not working

本文关键字:working not setWallpaper wallpaper chrome      更新时间:2023-09-26

我还在学习chrome扩展/应用程序,我有这个问题与chrome。壁纸的api。我想把背景换成另一个,但是不行。是的,我正在运行chrome os版本43。

这是我的代码:

chrome.runtime.onStartup.addListener(function() {
  chrome.wallpaper.setWallpaper({
    "url": "file:///home/chronos/u-f083140cd056ce74510f1290350a468fee3a9377/Downloads/1080bokeh.jpg",
    "layout": "CENTER_CROPPED",
    "filename": "1080bokeh"
  }, function() {});
});

我已经检查了文件位置是否存在。

在控制台上,我得到这个:

    Unchecked runtime.lastError while running wallpaper.setWallpaper: Downloading wallpaper 1080bokeh.jpg failed. The response code is -1.
at chrome-extension://jiojpobpcbdplpiiallkhpehcdohgfij/background.js:17:20
有人能指出我做错了什么吗?

我很确定你不允许在Chrome扩展中指向file:// url。尝试将图像放在扩展的文件夹中,并相对于扩展的根目录引用它。