Cleanup wrapper function when app has done quitting

The app may still do something when quitting, we need to make sure the
wrapper function is still there at that time.
This commit is contained in:
Cheng Zhao 2015-11-04 16:54:36 +08:00
parent 441cc3e57e
commit 75f49477ca
5 changed files with 31 additions and 24 deletions

View file

@ -1124,14 +1124,18 @@ mate::Handle<WebContents> WebContents::Create(
return handle;
}
void SetWrapWebContents(const WrapWebContentsCallback& callback) {
g_wrap_web_contents = callback;
}
void ClearWrapWebContents() {
g_wrap_web_contents.Reset();
}
void SetWrapWebContents(const WrapWebContentsCallback& callback) {
g_wrap_web_contents = callback;
// Cleanup the wrapper on exit.
atom::AtomBrowserMainParts::Get()->RegisterDestructionCallback(
base::Bind(ClearWrapWebContents));
}
} // namespace api
} // namespace atom
@ -1145,7 +1149,6 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
mate::Dictionary dict(isolate, exports);
dict.SetMethod("create", &atom::api::WebContents::Create);
dict.SetMethod("_setWrapWebContents", &atom::api::SetWrapWebContents);
dict.SetMethod("_clearWrapWebContents", &atom::api::ClearWrapWebContents);
}
} // namespace