2014-08-09 17:38:46 +00:00
|
|
|
'use strict';
|
|
|
|
|
2014-06-08 17:32:24 +00:00
|
|
|
var usbDevices = {
|
|
|
|
STM32DFU: {'vendorId': 1155, 'productId': 57105}
|
|
|
|
};
|
|
|
|
var usbPermissions = {permissions: [{'usbDevices': [usbDevices.STM32DFU]}]};
|
|
|
|
|
|
|
|
function check_usb_permissions(callback) {
|
2014-08-09 17:38:46 +00:00
|
|
|
chrome.permissions.contains(usbPermissions, function (result) {
|
2014-06-08 17:32:24 +00:00
|
|
|
if (result) {
|
|
|
|
GUI.optional_usb_permissions = true;
|
|
|
|
} else {
|
|
|
|
console.log('Optional USB permissions: missing');
|
|
|
|
GUI.log(chrome.i18n.getMessage('please_grant_usb_permissions'));
|
|
|
|
|
|
|
|
// display optional usb permissions request box
|
|
|
|
$('div.optional_permissions').show();
|
|
|
|
|
|
|
|
// UI hooks
|
2014-08-09 17:38:46 +00:00
|
|
|
document.getElementById("requestOptionalPermissions").addEventListener('click', function () {
|
|
|
|
chrome.permissions.request(usbPermissions, function (result) {
|
2014-06-08 17:32:24 +00:00
|
|
|
if (result) {
|
|
|
|
GUI.log(chrome.i18n.getMessage('usb_permissions_granted'));
|
|
|
|
$('div.optional_permissions').hide();
|
|
|
|
|
|
|
|
GUI.optional_usb_permissions = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-08-09 17:38:46 +00:00
|
|
|
if (callback) {
|
|
|
|
callback();
|
|
|
|
}
|
2014-06-08 17:32:24 +00:00
|
|
|
});
|
|
|
|
}
|