Skip to content

Commit

Permalink
[Android] Dismiss select popup upon entering fullscreen
Browse files Browse the repository at this point in the history
Chrome dismisses select popup menu when entering fullscreen. This
prevents a potential hack that deliberately hides the fullscreen
notification toast message with the select popup menu.

Bug: 1327505
Change-Id: I788e6dc3f9866beeac5cd58232a1e7facacf43bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3847044
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1039341}
  • Loading branch information
JinsukKim authored and Chromium LUCI CQ committed Aug 25, 2022
1 parent 83b6d4b commit 726a045
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions content/browser/web_contents/web_contents_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3521,6 +3521,8 @@ void WebContentsImpl::FullscreenStateChanged(
"render_frame_host", rfh, "is_fullscreen",
is_fullscreen);

GetView()->FullscreenStateChanged(is_fullscreen);

if (is_fullscreen) {
if (options.is_null()) {
ReceivedBadMessage(rfh->GetProcess(),
Expand Down
2 changes: 2 additions & 0 deletions content/browser/web_contents/web_contents_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class WebContentsView {
// loop has ended.
virtual bool CloseTabAfterEventTrackingIfNeeded() = 0;
#endif

virtual void FullscreenStateChanged(bool is_fullscreen) = 0;
};

// Factory function to create `WebContentsView`s. Implemented in the platform
Expand Down
5 changes: 5 additions & 0 deletions content/browser/web_contents/web_contents_view_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ void WebContentsViewAndroid::SetOverscrollControllerEnabled(bool enabled) {

void WebContentsViewAndroid::OnCapturerCountChanged() {}

void WebContentsViewAndroid::FullscreenStateChanged(bool is_fullscreen) {
if (select_popup_)
select_popup_->HideMenu();
}

void WebContentsViewAndroid::ShowContextMenu(RenderFrameHost& render_frame_host,
const ContextMenuParams& params) {
if (is_active_drag_ && drag_exceeded_movement_threshold_)
Expand Down
1 change: 1 addition & 0 deletions content/browser/web_contents/web_contents_view_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class WebContentsViewAndroid : public WebContentsView,
RenderViewHost* new_host) override;
void SetOverscrollControllerEnabled(bool enabled) override;
void OnCapturerCountChanged() override;
void FullscreenStateChanged(bool is_fullscreen) override;

// Backend implementation of RenderViewHostDelegateView.
void ShowContextMenu(RenderFrameHost& render_frame_host,
Expand Down
2 changes: 2 additions & 0 deletions content/browser/web_contents/web_contents_view_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,8 @@ void WebContentsViewAura::OnCapturerCountChanged() {
}
}

void WebContentsViewAura::FullscreenStateChanged(bool is_fullscreen) {}

////////////////////////////////////////////////////////////////////////////////
// WebContentsViewAura, RenderViewHostDelegateView implementation:

Expand Down
1 change: 1 addition & 0 deletions content/browser/web_contents/web_contents_view_aura.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class CONTENT_EXPORT WebContentsViewAura
RenderViewHost* new_host) override;
void SetOverscrollControllerEnabled(bool enabled) override;
void OnCapturerCountChanged() override;
void FullscreenStateChanged(bool is_fullscreen) override;

// Overridden from RenderViewHostDelegateView:
void ShowContextMenu(RenderFrameHost& render_frame_host,
Expand Down
2 changes: 2 additions & 0 deletions content/browser/web_contents/web_contents_view_child_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ bool WebContentsViewChildFrame::CloseTabAfterEventTrackingIfNeeded() {

void WebContentsViewChildFrame::OnCapturerCountChanged() {}

void WebContentsViewChildFrame::FullscreenStateChanged(bool is_fullscreen) {}

void WebContentsViewChildFrame::RestoreFocus() {
NOTREACHED();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class WebContentsViewChildFrame : public WebContentsView,
bool CloseTabAfterEventTrackingIfNeeded() override;
#endif
void OnCapturerCountChanged() override;
void FullscreenStateChanged(bool is_fullscreen) override;

// Backend implementation of RenderViewHostDelegateView.
void ShowContextMenu(RenderFrameHost& render_frame_host,
Expand Down
1 change: 1 addition & 0 deletions content/browser/web_contents/web_contents_view_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class WebContentsViewMac : public WebContentsView,
void SetOverscrollControllerEnabled(bool enabled) override;
bool CloseTabAfterEventTrackingIfNeeded() override;
void OnCapturerCountChanged() override;
void FullscreenStateChanged(bool is_fullscreen) override;

// RenderViewHostDelegateView:
void StartDragging(const DropData& drop_data,
Expand Down
2 changes: 2 additions & 0 deletions content/browser/web_contents/web_contents_view_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ void PromiseWriterHelper(const DropData& drop_data, base::File file) {

void WebContentsViewMac::OnCapturerCountChanged() {}

void WebContentsViewMac::FullscreenStateChanged(bool is_fullscreen) {}

void WebContentsViewMac::StartDragging(
const DropData& drop_data,
DragOperationsMask allowed_operations,
Expand Down

0 comments on commit 726a045

Please sign in to comment.