浮动嵌入iframe Chrome应用 - 需要“app.window.alwaysOnTop”权限

时间:2018-03-12 21:44:54

标签: javascript google-chrome

清单

{
    "name": "EMBED",
    "version" : "1.0",
    "manifest_version" : 2,
    "app" : {
        "background": {
            "scripts":  ["background.js"]
        },
        "permissions": [
            "app.window.alwaysOnTop"
          ]
    }
}

BACKGROUND.JS

chrome.app.runtime.onLaunched.addListener(function() {
    chrome.app.window.create('embed.html', {      
      alwaysOnTop: true,
      id: 'mainWindow',
      frame: 'none',
      state: "normal",
      hidden: false,
      resizable: false,
    });
  });

HTML

<html>
  <body>
      <h1>hello</h1>
  </body>
</html>

我得到的错误:

Unchecked runtime.lastError while running app.window.create: The "app.window.alwaysOnTop" permission is required.
    at chrome-extension://fphjeingehfcjbabfanfbaifmhegaoic/background.js:52:23

所以它要求我在chrome.app.window之后准备一个权限。(权限应该在这里).create

我尝试了permissions: ["tabs", "alwaysOnTop", "window.app.alwaysOnTop"]

注意:在html中我想在不久的将来嵌入iframe。所以,如果还有其他需要调整的地方,请告诉我。

1 个答案:

答案 0 :(得分:0)

问题出在清单文件中。我把&#34;权限&#34;在&#34; app&#34;内部对象

错误

{
    "name": "EMBED",
    "version" : "1.0",
    "manifest_version" : 2,
    "app" : {
        "background": {
            "scripts":  ["background.js"]
        },
        "permissions": [
            "app.window.alwaysOnTop"
          ]
    }
}

CORRECT

{
    "name": "EMBED",
    "version" : "1.0",
    "manifest_version" : 2,
    "app" : {
        "background": {
            "scripts":  ["background.js"]
        }
    },
    "permissions": [
        "alwaysOnTopWindows"
      ]
}