Fix crash when sending programmatic event to a Views-hosted browser window.

The |web_contents_| member was nullptr in CefBrowserPlatformDelegateNativeAura
when calling methods like SendKeyEvent from CefBrowserPlatformDelegateViews.
This commit is contained in:
Marshall Greenblatt 2020-09-15 11:03:38 -04:00
parent 8796d3cd95
commit 5f9bd3ecbd
4 changed files with 12 additions and 4 deletions

View File

@ -62,7 +62,6 @@ class CefBrowserPlatformDelegateNative
void set_windowless_handler(WindowlessHandler* handler) {
windowless_handler_ = handler;
}
void set_browser(CefBrowserHostImpl* browser) { browser_ = browser; }
CefWindowInfo window_info_;
const SkColor background_color_;

View File

@ -225,6 +225,8 @@ int CefBrowserPlatformDelegateNativeAura::TranslateUiChangedButtonFlags(
content::RenderWidgetHostViewAura*
CefBrowserPlatformDelegateNativeAura::GetHostView() const {
if (!web_contents_)
return nullptr;
return static_cast<content::RenderWidgetHostViewAura*>(
web_contents_->GetRenderWidgetHostView());
}

View File

@ -69,15 +69,21 @@ void CefBrowserPlatformDelegateViews::WebContentsCreated(
content::WebContents* web_contents,
bool owned) {
CefBrowserPlatformDelegateAlloy::WebContentsCreated(web_contents, owned);
native_delegate_->WebContentsCreated(web_contents, /*owned=*/false);
browser_view_->WebContentsCreated(web_contents);
}
void CefBrowserPlatformDelegateViews::WebContentsDestroyed(
content::WebContents* web_contents) {
CefBrowserPlatformDelegateAlloy::WebContentsDestroyed(web_contents);
native_delegate_->WebContentsDestroyed(web_contents);
}
void CefBrowserPlatformDelegateViews::BrowserCreated(
CefBrowserHostImpl* browser) {
CefBrowserPlatformDelegateAlloy::BrowserCreated(browser);
native_delegate_->set_browser(browser);
native_delegate_->BrowserCreated(browser);
browser_view_->BrowserCreated(browser, GetBoundsChangedCallback());
}
@ -99,9 +105,9 @@ void CefBrowserPlatformDelegateViews::BrowserDestroyed(
CefBrowserHostImpl* browser) {
CefBrowserPlatformDelegateAlloy::BrowserDestroyed(browser);
native_delegate_->set_browser(nullptr);
browser_view_->BrowserDestroyed(browser);
browser_view_ = nullptr;
native_delegate_->BrowserDestroyed(browser);
}
bool CefBrowserPlatformDelegateViews::CreateHostWindow() {

View File

@ -23,6 +23,7 @@ class CefBrowserPlatformDelegateViews
// CefBrowserPlatformDelegate methods:
void WebContentsCreated(content::WebContents* web_contents,
bool owned) override;
void WebContentsDestroyed(content::WebContents* web_contents) override;
void BrowserCreated(CefBrowserHostImpl* browser) override;
void NotifyBrowserCreated() override;
void NotifyBrowserDestroyed() override;