mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
chrome: Support unload handlers with TryCloseBrowser
TryCloseBrowser should potentially trigger JavaScript unload handlers and return false. Add CefBrowserHost::IsReadyToBeClosed for detecting mandatory close state. Enable, for Chrome style browsers, LifeSpanTest that don't require DoClose(). Update related documentation.
This commit is contained in:
@@ -452,6 +452,20 @@ bool CefBrowserHostBase::HasView() {
|
||||
return is_views_hosted_;
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::IsReadyToBeClosed() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
DCHECK(false) << "called on invalid thread";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto web_contents = GetWebContents()) {
|
||||
return static_cast<content::RenderFrameHostImpl*>(
|
||||
web_contents->GetPrimaryMainFrame())
|
||||
->IsPageReadyToBeClosed();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::SetFocus(bool focus) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
|
Reference in New Issue
Block a user