2

I have developed a Chrome packaged app that can download certain video files. The videos are downloaded in the background using XHR, and multiple videos can be downloaded in parallel. For long videos, this can be a lenghty process.

If the user accidentally closes the app, all downloads will be terminated without warning.

Is it possible to have a Chrome app ask if the user really wants to quit?

marlar
  • 3,858
  • 6
  • 37
  • 60
  • Is a "Chrome app" just a regular web application? If so, this might help: http://stackoverflow.com/questions/1631959/how-to-capture-the-browser-window-close-event – Cypher Oct 09 '15 at 21:03
  • 1
    @Cypher No they're not. https://developer.chrome.com/apps/about_apps – Oliver Oct 09 '15 at 21:05
  • Maybe you can pass the urls to the built-in `chrome.downloads` API so that Chrome asks before exiting about unfinished downloads? – wOxxOm Oct 09 '15 at 21:13
  • @wOxxOm: I can't use the `chrome.downloads` API, I am using the `chrome.fileSystem` API. – marlar Oct 09 '15 at 21:24
  • Star the [Issue 30885: No way to detect when the browser is closed](https://code.google.com/p/chromium/issues/detail?id=30885) to make your voice count. Kind of. – wOxxOm Oct 09 '15 at 21:32
  • You're downloading them in the event page or an app window? – Daniel Herr Oct 09 '15 at 23:51

1 Answers1

1

You can create a frameless Chrome App, add your own close button, and attach your custom event handler on it.

Supersharp
  • 29,002
  • 9
  • 92
  • 134
  • 1
    Thanks. I didn't know about that option. – marlar Oct 12 '15 at 17:13
  • Note that if you close the app by right-clicking and choosing close in the contextual menu you won't be able to catch the event. But in this case, it's not really accidental. – Supersharp Oct 15 '15 at 14:41