Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2890143003: Move ContextMenu show/hide state tracking to WebContents (Closed)
Patch Set: Remove #if def Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/render_widget_host_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index cef65a924bd6e3cc1036361d9f338427a92ec0de..c2f9e1428ece304886840c3fe21c27a19d43ed91 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -516,6 +516,7 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context)
#endif // !defined(OS_ANDROID)
mouse_lock_widget_(nullptr),
is_overlay_content_(false),
+ showing_context_menu_(false),
loading_weak_factory_(this),
weak_factory_(this) {
frame_tree_.SetFrameRemoveListener(
@@ -4400,7 +4401,7 @@ void WebContentsImpl::ShowContextMenu(RenderFrameHost* render_frame_host,
const ContextMenuParams& params) {
// If a renderer fires off a second command to show a context menu before the
// first context menu is closed, just ignore it. https://crbug.com/707534
- if (GetRenderWidgetHostView()->IsShowingContextMenu())
+ if (showing_context_menu_)
return;
ContextMenuParams context_menu_params(params);
@@ -4514,6 +4515,21 @@ bool WebContentsImpl::IsFocusedElementEditable() {
return frame && frame->has_focused_editable_element();
}
+bool WebContentsImpl::IsShowingContextMenu() const {
+ return showing_context_menu_;
+}
+
+void WebContentsImpl::SetShowingContextMenu(bool showing) {
+ DCHECK_NE(showing_context_menu_, showing);
+ showing_context_menu_ = showing;
+
+ if (auto* view = GetRenderWidgetHostView()) {
+ // Notify the main frame's RWHV to run the platform-specific code, if any.
+ static_cast<RenderWidgetHostViewBase*>(view)->SetShowingContextMenu(
+ showing);
+ }
+}
+
void WebContentsImpl::ClearFocusedElement() {
if (auto* frame = GetFocusedFrame())
frame->ClearFocusedElement();
@@ -5666,6 +5682,10 @@ void WebContentsImpl::ShowInsecureLocalhostWarningIfNeeded() {
" releasing your website to the public."));
}
+bool WebContentsImpl::IsShowingContextMenuOnPage() const {
+ return showing_context_menu_;
+}
+
void WebContentsImpl::NotifyPreferencesChanged() {
std::set<RenderViewHost*> render_view_host_set;
for (FrameTreeNode* node : frame_tree_.Nodes()) {
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/render_widget_host_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698