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

Unified Diff: content/browser/web_contents/web_contents_view_aura.h

Issue 2568893002: Prevent drag-and-drop events from firing over cross-site, same-page frames. (Closed)
Patch Set: Addressed comments. Created 4 years 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_view_aura.h
diff --git a/content/browser/web_contents/web_contents_view_aura.h b/content/browser/web_contents/web_contents_view_aura.h
index 68690959d5a6cf6b427f931f0ea78f704f68d0a4..ddce5ed98c6ac88141bb612db46f3b71256b6b63 100644
--- a/content/browser/web_contents/web_contents_view_aura.h
+++ b/content/browser/web_contents/web_contents_view_aura.h
@@ -87,6 +87,11 @@ class CONTENT_EXPORT WebContentsViewAura
// Returns GetNativeView unless overridden for testing.
gfx::NativeView GetRenderWidgetHostViewParent() const;
+ // Returns whether |target_rwh| is a valid RenderWidgetHost to be dragging
+ // over. This enforces that same-page, cross-site drags are not allowed. See
+ // crbug.com/666858.
+ bool ValidDragTarget(RenderWidgetHostImpl* target_rwh) const;
Charlie Reis 2016/12/14 18:06:50 nit: IsValidDragTarget
paulmeyer 2016/12/14 18:27:49 Done.
+
// Overridden from WebContentsView:
gfx::NativeView GetNativeView() const override;
gfx::NativeView GetContentNativeView() const override;
@@ -198,10 +203,16 @@ class CONTENT_EXPORT WebContentsViewAura
// during a drag, we need to re-send the DragEnter message.
base::WeakPtr<RenderWidgetHostImpl> current_rwh_for_drag_;
- // We also keep track of the RenderViewHost we're dragging over to avoid
- // sending the drag exited message after leaving the current
- // view. |current_rvh_for_drag_| should not be dereferenced.
- void* current_rvh_for_drag_;
+ // We also keep track of the ID of the RenderViewHost we're dragging over to
Charlie Reis 2016/12/13 23:01:16 Please elaborate in both comments what each int in
Łukasz Anforowicz 2016/12/13 23:07:24 Not sure if it is applicable here + don't want to
Charlie Reis 2016/12/14 18:06:50 That's a good idea-- let's use that. (Looks like
paulmeyer 2016/12/14 18:27:48 Okay, GlobalRoutingID seems like a better thing to
+ // avoid sending the drag exited message after leaving the current view.
+ std::pair<int, int> current_rvh_for_drag_;
+
+ // We track the IDs of the source RenderProcessHost and RenderViewHost from
Charlie Reis 2016/12/13 23:01:16 Nasko brought up the question about why this isn't
paulmeyer 2016/12/14 18:27:48 RenderViewHost is tracked to check the "same-page"
+ // which the current drag originated. These are used to ensure that drag
+ // events do not fire over a cross-site frame in the same page (with respect
+ // to the source frame). See crbug.com/666858.
Charlie Reis 2016/12/14 18:06:50 We should also clarify that the RPH and RVH here m
paulmeyer 2016/12/14 18:27:48 Done.
+ int drag_source_rph_;
Charlie Reis 2016/12/13 23:01:16 It's hard to tell from the name what this is. May
paulmeyer 2016/12/14 18:27:48 Actually, I noticed there are some other uses of t
Charlie Reis 2016/12/14 18:36:36 Acknowledged.
+ std::pair<int, int> drag_source_rvh_;
Charlie Reis 2016/12/13 23:01:16 drag_source_view_ids_?
Charlie Reis 2016/12/14 18:06:50 Or drag_source_view_global_routing_id_.
paulmeyer 2016/12/14 18:27:48 Renamed to drag_start_view_id_.
// The overscroll gesture currently in progress.
OverscrollMode current_overscroll_gesture_;

Powered by Google App Engine
This is Rietveld 408576698