I have a Chrome Kiosk App where i would like to use the chrome.networking.onc
API to let my users change WiFi networks.
There is no chrome.networking.onc
API available to the app neither in the app background script or the app window while running in a kiosk session.
According to the chrome.networking.onc
documentation it should be available to apps while in kiosk mode.
I've added networking.onc
to my permissions
in my app manifest.
https://developer.chrome.com/apps/networking_onc
https://developer.chrome.com/apps/declare_permissions
The kiosk app is force installed to the users Chromebooks using a G Suite Chrome device management policy.
{
"manifest_version": 2,
"name": "Kiosk networking.onc",
"version": "1.0",
"permissions": ["networking.onc"],
"kiosk_enabled": true,
"kiosk_only": true,
"app": {
"background": {
"scripts": ["background.js"]
}
}
}
chrome.app.runtime.onLaunched.addListener(function(launchData) {
// send a list of available chrome APIs to the app window to be displayed
chrome.app.window.create(`window/main.html?chrome=${Object.keys(chrome).join(",")}&kiosk=${launchData.isKioskSession}`);
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Chrome app</title>
</head>
<body>
<p>
<h1>Background <code>chrome</code> object properties</h1>
<div id="background"></div>
</p>
<p>
<h1>App window <code>chrome</code> object properties</h1>
<div id="window"></div>
</p>
<button id="exit">window.close()</button>
<script src="main.js"></script>
</body>
</html>
// display the available Chrome APIs in the background script
document.getElementById("background").innerText = window.location.search;
// display all the available Chrome APIs (accessible from the app window).
document.getElementById("window").innerText = Object.keys(chrome).join(",");
document.getElementById("exit").onclick = () => window.close()
In the image below networking
cannot be found among the available APIs and if i try to access networking.onc
i get the error: Uncaught TypeError: Cannot read property 'onc' of undefined
This issue seems to be caused by a bug in Chrome OS.
I've reported the issue in the Chromium issue tracker here: https://bugs.chromium.org/p/chromium/issues/detail?id=1012629