Move ContextMenu show/hide state tracking to WebContents
Currently, RenderWidgetHostView of the page tracks the visibility state of context
menus. However, the RWHV might go away during navigations (cross origin). On the
other hand, a context menu might outlive the RWHV and stay visible during the page
navigation which leads to a mismatch between the stored visibility state in the
new RWHV and the actual visibility of the context menu.
This CL will move this state tracking logic to WebContents which stays the same
during page navigations.
BUG=708182
Review-Url: https://codereview.chromium.org/2890143003
Cr-Commit-Position: refs/heads/master@{#477346}
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index 352bda3..3e1ed690 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -782,6 +782,12 @@
// Returns true if the current focused element is editable.
virtual bool IsFocusedElementEditable() = 0;
+ // Returns true if a context menu is showing on the page.
+ virtual bool IsShowingContextMenu() const = 0;
+
+ // Tells the WebContents whether the context menu is showing.
+ virtual void SetShowingContextMenu(bool showing) = 0;
+
#if defined(OS_ANDROID)
CONTENT_EXPORT static WebContents* FromJavaWebContents(
const base::android::JavaRef<jobject>& jweb_contents_android);