mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
36 lines
939 B
JavaScript
36 lines
939 B
JavaScript
function createWindow(state) {
|
|
chrome.app.window.create('index.html', {
|
|
state: state,
|
|
bounds: {
|
|
width: 960,
|
|
height: 540
|
|
}
|
|
}, function(window) {
|
|
// workaround:
|
|
// state = 'normal' in some cases not work (e.g. starting app from 'chrome://extensions' always open window in fullscreen mode)
|
|
// it requires manually restoring window state to 'normal'
|
|
if (state == 'normal') {
|
|
setTimeout(function() {
|
|
window.restore();
|
|
}, 1000);
|
|
}
|
|
});
|
|
}
|
|
|
|
chrome.app.runtime.onLaunched.addListener(function() {
|
|
console.log('Chrome app runtime launched.');
|
|
var windowState = 'normal';
|
|
|
|
if (chrome.storage) {
|
|
// load stored window state
|
|
chrome.storage.sync.get('windowState', function(item) {
|
|
windowState = (item && item.windowState) ?
|
|
item.windowState :
|
|
windowState;
|
|
createWindow(windowState);
|
|
});
|
|
} else {
|
|
createWindow(windowState);
|
|
}
|
|
});
|