Advertisement
BigRob154

Chrome App - Allow only one instance at a time

Sep 24th, 2013
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // background.js
  2. (function() {
  3.     var opened = false;
  4.  
  5.     chrome.app.runtime.onLaunched.addListener(function() {
  6.         chrome.app.window.create(
  7.             'main.html',
  8.             {
  9.                 bounds: { width: 768, height: 700 },
  10.                 minWidth: 700,
  11.                 minHeight: 550,
  12.                 frame: "none"
  13.             },
  14.             function(win) {
  15.                 if (opened) {
  16.                     win.close();
  17.                     return;
  18.                 }
  19.  
  20.                 win.onClosed.addListener(function() {
  21.                     opened = false;
  22.                 });
  23.  
  24.                 opened = true;
  25.                 win.show();
  26.             }
  27.         );
  28.     });
  29. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement