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

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

Issue 2890143003: Move ContextMenu show/hide state tracking to WebContents (Closed)
Patch Set: Fixing another compile error Created 3 years, 7 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
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 9a91bc9bb167547dc5e4bbba8d4f0e9d331f4040..6bc7c44297bfa2d7231c89922549cd3f8f1819f8 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -511,6 +511,7 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context)
page_scale_factor_is_one_(true),
mouse_lock_widget_(nullptr),
is_overlay_content_(false),
+ showing_context_menu_(false),
loading_weak_factory_(this),
weak_factory_(this) {
frame_tree_.SetFrameRemoveListener(
@@ -4372,7 +4373,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);
@@ -4484,6 +4485,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 defined(OS_MACOSX)
+ if (auto* view = GetRenderWidgetHostView()) {
+ static_cast<RenderWidgetHostViewBase*>(view)->SetShowingContextMenu(
+ showing);
+ }
+#endif
+}
+
void WebContentsImpl::ClearFocusedElement() {
if (auto* frame = GetFocusedFrame())
frame->ClearFocusedElement();
@@ -5628,6 +5644,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()) {

Powered by Google App Engine
This is Rietveld 408576698