Skip to content

Commit

Permalink
send App.quit correctly when the last window closed
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerwang committed Jun 23, 2013
1 parent 5782676 commit a6e2edc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
25 changes: 14 additions & 11 deletions src/api/app/app.cc
Expand Up @@ -133,20 +133,23 @@ void App::CloseAllWindows() {
}

// static
void App::Quit() {
void App::Quit(RenderProcessHost* render_process_host) {
// Send the quit message.
int no_use;
std::set<RenderProcessHost*> rphs;
std::set<RenderProcessHost*>::iterator it;

GetRenderProcessHosts(rphs);
for (it = rphs.begin(); it != rphs.end(); it++) {
RenderProcessHost* rph = *it;
DCHECK(rph != NULL);

rph->Send(new ViewMsg_WillQuit(&no_use));
if (render_process_host) {
render_process_host->Send(new ViewMsg_WillQuit(&no_use));
}else{
std::set<RenderProcessHost*> rphs;
std::set<RenderProcessHost*>::iterator it;

GetRenderProcessHosts(rphs);
for (it = rphs.begin(); it != rphs.end(); it++) {
RenderProcessHost* rph = *it;
DCHECK(rph != NULL);

rph->Send(new ViewMsg_WillQuit(&no_use));
}
}

// Then quit.
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/app.h
Expand Up @@ -50,7 +50,7 @@ class App {
static void CloseAllWindows();

// Quit the whole app.
static void Quit();
static void Quit(content::RenderProcessHost* rph = NULL);

// Post "open" event.
static void EmitOpenEvent(const std::string& path);
Expand Down
2 changes: 1 addition & 1 deletion src/nw_shell.cc
Expand Up @@ -170,7 +170,7 @@ Shell::~Shell() {
}

if (windows_.empty() && quit_message_loop_)
api::App::Quit();
api::App::Quit(web_contents()->GetRenderProcessHost());
}

void Shell::SendEvent(const std::string& event, const std::string& arg1) {
Expand Down

0 comments on commit a6e2edc

Please sign in to comment.