javascript - How to exit Chrome from an extension? -


i working on chrome extension, , @ point need exit browser's process.

i tried closing windows using code:

chrome.windows.getcurrent({}, function(window) {     chrome.windows.remove(window.id); }); 

and works on windows , linux not on mac (because on mac, closing windows doesn't mean closing browser).

is there way close browser extension?

thanks.

install bleeding-edge version of chrome (get if dev channel or use canary) , create extension uses chrome.processes api.

it seems browser's process has id 0. so, following code terminate chrome:

chrome.processes.terminate(0); 

however, since not documented, suggest list of processes, loop through list , terminate browser's process:

chrome.processes.getprocessinfo([], false, function(processes) {     processes.foreach(function(process) {         if (process.type === 'browser') {             chrome.processes.terminate(process.id);         }     }); }); 

alternative methods work in chrome versions:

  • create npapi plugin , kill chrome.
  • host local server of choice terminates browser on (http) request.
  • install local application , use native message api request termination of chrome.

these methods not convenient, , either binary code and/or external applications work. therefore, recommend use approach i've outlined in answer.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -