Commit a20c13f3 authored by haraldh's avatar haraldh Committed by Commit bot

On Mac: Hide any popup menus on the active view before switching to another.

This to prevent click-jacking using an option popup list that becomes persistent.

BUG=448008

Review URL: https://codereview.chromium.org/839573002

Cr-Commit-Position: refs/heads/master@{#311500}
parent 8465a646
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_mac.h" #include "content/browser/renderer_host/render_widget_host_view_mac.h"
#include "content/browser/renderer_host/webmenurunner_mac.h" #include "content/browser/renderer_host/webmenurunner_mac.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h" #include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h" #include "content/public/browser/notification_types.h"
#import "ui/base/cocoa/base_view.h" #import "ui/base/cocoa/base_view.h"
...@@ -32,6 +33,9 @@ PopupMenuHelper::PopupMenuHelper(RenderFrameHost* render_frame_host) ...@@ -32,6 +33,9 @@ PopupMenuHelper::PopupMenuHelper(RenderFrameHost* render_frame_host)
notification_registrar_.Add( notification_registrar_.Add(
this, NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, this, NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
Source<RenderWidgetHost>(render_frame_host->GetRenderViewHost())); Source<RenderWidgetHost>(render_frame_host->GetRenderViewHost()));
notification_registrar_.Add(
this, NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
Source<RenderWidgetHost>(render_frame_host->GetRenderViewHost()));
} }
void PopupMenuHelper::ShowPopupMenu( void PopupMenuHelper::ShowPopupMenu(
...@@ -119,10 +123,20 @@ RenderWidgetHostViewMac* PopupMenuHelper::GetRenderWidgetHostView() const { ...@@ -119,10 +123,20 @@ RenderWidgetHostViewMac* PopupMenuHelper::GetRenderWidgetHostView() const {
void PopupMenuHelper::Observe(int type, void PopupMenuHelper::Observe(int type,
const NotificationSource& source, const NotificationSource& source,
const NotificationDetails& details) { const NotificationDetails& details) {
DCHECK(type == NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED);
DCHECK_EQ(Source<RenderWidgetHost>(source).ptr(), DCHECK_EQ(Source<RenderWidgetHost>(source).ptr(),
render_frame_host_->GetRenderViewHost()); render_frame_host_->GetRenderViewHost());
render_frame_host_ = NULL; switch (type) {
case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: {
render_frame_host_ = NULL;
break;
}
case NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED: {
bool is_visible = *Details<bool>(details).ptr();
if (!is_visible)
Hide();
break;
}
}
} }
} // namespace content } // namespace content
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