Use applicationShouldTerminate to control whether application should quit.

This commit is contained in:
Cheng Zhao 2013-06-26 17:22:24 +08:00
parent 6362e60a7b
commit adacc2bcf9
5 changed files with 33 additions and 19 deletions

View file

@ -24,11 +24,12 @@ Browser* Browser::Get() {
}
void Browser::Quit() {
is_quiting_ = true;
atom::WindowList* window_list = atom::WindowList::GetInstance();
if (window_list->size() == 0)
NotifyAndTerminate();
is_quiting_ = true;
window_list->CloseAllWindows();
}
@ -53,16 +54,22 @@ void Browser::NotifyAndTerminate() {
bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillQuit(&prevent_default));
if (prevent_default)
if (prevent_default) {
is_quiting_ = false;
return;
}
Terminate();
}
void Browser::OnWindowCloseCancelled(NativeWindow* window) {
// Once a beforeunload handler has prevented the closing, we think the quit
// is cancelled too.
is_quiting_ = false;
if (is_quiting_) {
// Once a beforeunload handler has prevented the closing, we think the quit
// is cancelled too.
is_quiting_ = false;
CancelQuit();
}
}
void Browser::OnWindowAllClosed() {