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:
parent
8796d3cd95
commit
5f9bd3ecbd
|
@ -62,7 +62,6 @@ class CefBrowserPlatformDelegateNative
|
||||||
void set_windowless_handler(WindowlessHandler* handler) {
|
void set_windowless_handler(WindowlessHandler* handler) {
|
||||||
windowless_handler_ = handler;
|
windowless_handler_ = handler;
|
||||||
}
|
}
|
||||||
void set_browser(CefBrowserHostImpl* browser) { browser_ = browser; }
|
|
||||||
|
|
||||||
CefWindowInfo window_info_;
|
CefWindowInfo window_info_;
|
||||||
const SkColor background_color_;
|
const SkColor background_color_;
|
||||||
|
|
|
@ -225,6 +225,8 @@ int CefBrowserPlatformDelegateNativeAura::TranslateUiChangedButtonFlags(
|
||||||
|
|
||||||
content::RenderWidgetHostViewAura*
|
content::RenderWidgetHostViewAura*
|
||||||
CefBrowserPlatformDelegateNativeAura::GetHostView() const {
|
CefBrowserPlatformDelegateNativeAura::GetHostView() const {
|
||||||
|
if (!web_contents_)
|
||||||
|
return nullptr;
|
||||||
return static_cast<content::RenderWidgetHostViewAura*>(
|
return static_cast<content::RenderWidgetHostViewAura*>(
|
||||||
web_contents_->GetRenderWidgetHostView());
|
web_contents_->GetRenderWidgetHostView());
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,15 +69,21 @@ void CefBrowserPlatformDelegateViews::WebContentsCreated(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
bool owned) {
|
bool owned) {
|
||||||
CefBrowserPlatformDelegateAlloy::WebContentsCreated(web_contents, owned);
|
CefBrowserPlatformDelegateAlloy::WebContentsCreated(web_contents, owned);
|
||||||
|
native_delegate_->WebContentsCreated(web_contents, /*owned=*/false);
|
||||||
browser_view_->WebContentsCreated(web_contents);
|
browser_view_->WebContentsCreated(web_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegateViews::WebContentsDestroyed(
|
||||||
|
content::WebContents* web_contents) {
|
||||||
|
CefBrowserPlatformDelegateAlloy::WebContentsDestroyed(web_contents);
|
||||||
|
native_delegate_->WebContentsDestroyed(web_contents);
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateViews::BrowserCreated(
|
void CefBrowserPlatformDelegateViews::BrowserCreated(
|
||||||
CefBrowserHostImpl* browser) {
|
CefBrowserHostImpl* browser) {
|
||||||
CefBrowserPlatformDelegateAlloy::BrowserCreated(browser);
|
CefBrowserPlatformDelegateAlloy::BrowserCreated(browser);
|
||||||
|
|
||||||
native_delegate_->set_browser(browser);
|
native_delegate_->BrowserCreated(browser);
|
||||||
browser_view_->BrowserCreated(browser, GetBoundsChangedCallback());
|
browser_view_->BrowserCreated(browser, GetBoundsChangedCallback());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,9 +105,9 @@ void CefBrowserPlatformDelegateViews::BrowserDestroyed(
|
||||||
CefBrowserHostImpl* browser) {
|
CefBrowserHostImpl* browser) {
|
||||||
CefBrowserPlatformDelegateAlloy::BrowserDestroyed(browser);
|
CefBrowserPlatformDelegateAlloy::BrowserDestroyed(browser);
|
||||||
|
|
||||||
native_delegate_->set_browser(nullptr);
|
|
||||||
browser_view_->BrowserDestroyed(browser);
|
browser_view_->BrowserDestroyed(browser);
|
||||||
browser_view_ = nullptr;
|
browser_view_ = nullptr;
|
||||||
|
native_delegate_->BrowserDestroyed(browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefBrowserPlatformDelegateViews::CreateHostWindow() {
|
bool CefBrowserPlatformDelegateViews::CreateHostWindow() {
|
||||||
|
|
|
@ -23,6 +23,7 @@ class CefBrowserPlatformDelegateViews
|
||||||
// CefBrowserPlatformDelegate methods:
|
// CefBrowserPlatformDelegate methods:
|
||||||
void WebContentsCreated(content::WebContents* web_contents,
|
void WebContentsCreated(content::WebContents* web_contents,
|
||||||
bool owned) override;
|
bool owned) override;
|
||||||
|
void WebContentsDestroyed(content::WebContents* web_contents) override;
|
||||||
void BrowserCreated(CefBrowserHostImpl* browser) override;
|
void BrowserCreated(CefBrowserHostImpl* browser) override;
|
||||||
void NotifyBrowserCreated() override;
|
void NotifyBrowserCreated() override;
|
||||||
void NotifyBrowserDestroyed() override;
|
void NotifyBrowserDestroyed() override;
|
||||||
|
|
Loading…
Reference in New Issue