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

Unified Diff: chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc

Issue 1293963002: Fixing the Position of Context Menu for BrowserPlugin (<webview>) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Test Name Created 5 years, 4 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: chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc
diff --git a/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc b/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc
index c6d910b7be8eb052689f3573a0aa722ee0841aa2..7b1dda5eb4bcaa7a8401193562fb19d5b8a67944 100644
--- a/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc
+++ b/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc
@@ -39,7 +39,18 @@ bool ChromeWebViewGuestDelegate::HandleContextMenu(
ContextMenuDelegate::FromWebContents(guest_web_contents());
DCHECK(menu_delegate);
- pending_menu_ = menu_delegate->BuildMenu(guest_web_contents(), params);
+ content::ContextMenuParams new_params = params;
+ // The only case where |context_menu_position_| is not initialized is the case
+ // where the input event is directly sent to the guest WebContents without
+ // ever going throught the embedder and BrowserPlugin's
+ // RenderWidgetHostViewGuest. This only happens in some tests, e.g.,
+ // WebViewInteractiveTest.ContextMenuParamCoordinates.
+ if (context_menu_position_) {
+ new_params.x = context_menu_position_->x();
+ new_params.y = context_menu_position_->y();
+ }
+
+ pending_menu_ = menu_delegate->BuildMenu(guest_web_contents(), new_params);
// It's possible for the returned menu to be null, so early out to avoid
// a crash. TODO(wjmaclean): find out why it's possible for this to happen
// in the first place, and if it's an error.
@@ -139,4 +150,12 @@ void ChromeWebViewGuestDelegate::OnAccessibilityStatusChanged(
}
#endif
+void ChromeWebViewGuestDelegate::SetContextMenuPosition(
+ const gfx::Point& position) {
+ if (context_menu_position_ == nullptr)
+ context_menu_position_.reset(new gfx::Point());
+
+ *context_menu_position_ = position;
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698