Commit c5f8c777 authored by Kevin McNee's avatar Kevin McNee Committed by Commit Bot

Determine if RWHVMac cast is safe without checking for a BrowserPluginGuest

The GetRenderWidgetHostViewMac(NSObject*) test function was using
whether a WebContents was a guest to determine whether a cast to
RenderWidgetHostViewMac was safe. This would not be correct with other
nested WebContents, so we update the logic to check for a root RWHV
before casting.

Bug: 533069
Change-Id: I7af9fae9a862e2731e5770a1f628f9d6c39f8dc9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436950Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Commit-Queue: Kevin McNee <mcnee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811415}
parent 847e0cad
...@@ -55,9 +55,10 @@ namespace { ...@@ -55,9 +55,10 @@ namespace {
content::RenderWidgetHostViewMac* GetRenderWidgetHostViewMac(NSObject* object) { content::RenderWidgetHostViewMac* GetRenderWidgetHostViewMac(NSObject* object) {
for (auto* contents : WebContentsImpl::GetAllWebContents()) { for (auto* contents : WebContentsImpl::GetAllWebContents()) {
if (!contents->GetBrowserPluginGuest()) { auto* rwhv_base = static_cast<RenderWidgetHostViewBase*>(
RenderWidgetHostViewMac* rwhv_mac = static_cast<RenderWidgetHostViewMac*>( contents->GetRenderWidgetHostView());
contents->GetRenderWidgetHostView()); if (rwhv_base && !rwhv_base->IsRenderWidgetHostViewChildFrame()) {
auto* rwhv_mac = static_cast<RenderWidgetHostViewMac*>(rwhv_base);
if (rwhv_mac->GetInProcessNSView() == object) if (rwhv_mac->GetInProcessNSView() == object)
return rwhv_mac; return rwhv_mac;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment