mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Close browser instead of sending shutdown message
CEF now supports calling the beforeunload handler when closed so we no longer need to send a shutdown message on the native side.
This commit is contained in:
@@ -18,7 +18,6 @@ class AtomCefRenderProcessHandler : public CefRenderProcessHandler {
|
||||
CefRefPtr<CefProcessMessage> message) OVERRIDE;
|
||||
|
||||
void Reload(CefRefPtr<CefBrowser> browser);
|
||||
void Shutdown(CefRefPtr<CefBrowser> browser);
|
||||
bool CallMessageReceivedHandler(CefRefPtr<CefV8Context> context, CefRefPtr<CefProcessMessage> message);
|
||||
void InjectExtensionsIntoV8Context(CefRefPtr<CefV8Context> context);
|
||||
|
||||
|
||||
@@ -30,10 +30,6 @@ bool AtomCefRenderProcessHandler::OnProcessMessageReceived(CefRefPtr<CefBrowser>
|
||||
Reload(browser);
|
||||
return true;
|
||||
}
|
||||
else if (name == "shutdown") {
|
||||
Shutdown(browser);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return CallMessageReceivedHandler(browser->GetMainFrame()->GetV8Context(), message);
|
||||
}
|
||||
@@ -54,17 +50,6 @@ void AtomCefRenderProcessHandler::Reload(CefRefPtr<CefBrowser> browser) {
|
||||
context->Exit();
|
||||
}
|
||||
|
||||
void AtomCefRenderProcessHandler::Shutdown(CefRefPtr<CefBrowser> browser) {
|
||||
CefRefPtr<CefV8Context> context = browser->GetMainFrame()->GetV8Context();
|
||||
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
||||
|
||||
context->Enter();
|
||||
CefV8ValueList arguments;
|
||||
CefRefPtr<CefV8Value> shutdownFunction = global->GetValue("shutdown");
|
||||
shutdownFunction->ExecuteFunction(global, arguments);
|
||||
context->Exit();
|
||||
}
|
||||
|
||||
bool AtomCefRenderProcessHandler::CallMessageReceivedHandler(CefRefPtr<CefV8Context> context, CefRefPtr<CefProcessMessage> message) {
|
||||
context->Enter();
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@
|
||||
|
||||
- (BOOL)windowShouldClose:(NSNotification *)notification {
|
||||
if (_cefClient && _cefClient->GetBrowser()) {
|
||||
_cefClient->GetBrowser()->SendProcessMessage(PID_RENDERER, CefProcessMessage::Create("shutdown"));
|
||||
_cefClient->GetBrowser()->GetHost()->CloseBrowser(false);
|
||||
}
|
||||
|
||||
if (_pidToKillOnClose) kill([_pidToKillOnClose intValue], SIGQUIT);
|
||||
|
||||
Reference in New Issue
Block a user