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

Side by Side Diff: content/browser/web_contents/web_drag_dest_mac.h

Issue 2580843003: Prevent drag-and-drop events from firing over cross-site, same-page frames. (Mac) (Closed)
Patch Set: Addressed grammar nits. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "content/browser/loader/global_routing_id.h"
10 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
11 #include "content/public/common/drop_data.h" 12 #include "content/public/common/drop_data.h"
12 #include "ui/gfx/geometry/point.h" 13 #include "ui/gfx/geometry/point.h"
13 14
14 namespace content { 15 namespace content {
15 class RenderViewHost; 16 class RenderViewHost;
16 class RenderWidgetHostImpl; 17 class RenderWidgetHostImpl;
17 class WebContentsImpl; 18 class WebContentsImpl;
18 class WebDragDestDelegate; 19 class WebDragDestDelegate;
19 } 20 }
(...skipping 17 matching lines...) Expand all
37 // allow the drop. 38 // allow the drop.
38 NSDragOperation currentOperation_; 39 NSDragOperation currentOperation_;
39 40
40 // Tracks the current RenderWidgetHost we're dragging over. 41 // Tracks the current RenderWidgetHost we're dragging over.
41 base::WeakPtr<content::RenderWidgetHostImpl> currentRWHForDrag_; 42 base::WeakPtr<content::RenderWidgetHostImpl> currentRWHForDrag_;
42 43
43 // Keep track of the render view host we're dragging over. If it changes 44 // Keep track of the render view host we're dragging over. If it changes
44 // during a drag, we need to re-send the DragEnter message. 45 // during a drag, we need to re-send the DragEnter message.
45 RenderViewHostIdentifier currentRVH_; 46 RenderViewHostIdentifier currentRVH_;
46 47
48 // Tracks the IDs of the source RenderProcessHost and RenderViewHost from
49 // which the current drag originated. These are set in
50 // -setDragStartTrackersForProcess:, and are used to ensure that drag events
51 // do not fire over a cross-site frame (with respect to the source frame) in
52 // the same page (see crbug.com/666858). See
53 // WebContentsViewAura::drag_start_process_id_ for additional information.
54 int dragStartProcessID_;
55 content::GlobalRoutingID dragStartViewID_;
56
47 // The data for the current drag, or NULL if none is in progress. 57 // The data for the current drag, or NULL if none is in progress.
48 std::unique_ptr<content::DropData> dropData_; 58 std::unique_ptr<content::DropData> dropData_;
49 59
50 // True if the drag has been canceled. 60 // True if the drag has been canceled.
51 bool canceled_; 61 bool canceled_;
52 } 62 }
53 63
54 // |contents| is the WebContentsImpl representing this tab, used to communicate 64 // |contents| is the WebContentsImpl representing this tab, used to communicate
55 // drag&drop messages to WebCore and handle navigation on a successful drop 65 // drag&drop messages to WebCore and handle navigation on a successful drop
56 // (if necessary). 66 // (if necessary).
(...skipping 15 matching lines...) Expand all
72 - (void)draggingExited:(id<NSDraggingInfo>)info; 82 - (void)draggingExited:(id<NSDraggingInfo>)info;
73 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info 83 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info
74 view:(NSView*)view; 84 view:(NSView*)view;
75 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info view:(NSView*)view; 85 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info view:(NSView*)view;
76 86
77 // Helper to call WebWidgetHostInputEventRouter::GetRenderWidgetHostAtPoint(). 87 // Helper to call WebWidgetHostInputEventRouter::GetRenderWidgetHostAtPoint().
78 - (content::RenderWidgetHostImpl*) 88 - (content::RenderWidgetHostImpl*)
79 GetRenderWidgetHostAtPoint:(const NSPoint&)viewPoint 89 GetRenderWidgetHostAtPoint:(const NSPoint&)viewPoint
80 transformedPt:(gfx::Point*)transformedPt; 90 transformedPt:(gfx::Point*)transformedPt;
81 91
92 // Sets |dragStartProcessID_| and |dragStartViewID_|.
93 - (void)setDragStartTrackersForProcess:(int)processID;
94
95 // Returns whether |targetRWH| is a valid RenderWidgetHost to be dragging
96 // over. This enforces that same-page, cross-site drags are not allowed. See
97 // crbug.com/666858.
98 - (bool)isValidDragTarget:(content::RenderWidgetHostImpl*)targetRWH;
99
82 @end 100 @end
83 101
84 // Public use only for unit tests. 102 // Public use only for unit tests.
85 @interface WebDragDest(Testing) 103 @interface WebDragDest(Testing)
86 // Given |data|, which should not be nil, fill it in using the contents of the 104 // Given |data|, which should not be nil, fill it in using the contents of the
87 // given pasteboard. 105 // given pasteboard.
88 - (void)populateDropData:(content::DropData*)data 106 - (void)populateDropData:(content::DropData*)data
89 fromPasteboard:(NSPasteboard*)pboard; 107 fromPasteboard:(NSPasteboard*)pboard;
90 // Given a point in window coordinates and a view in that window, return a 108 // Given a point in window coordinates and a view in that window, return a
91 // flipped point in the coordinate system of |view|. 109 // flipped point in the coordinate system of |view|.
92 - (NSPoint)flipWindowPointToView:(const NSPoint&)windowPoint 110 - (NSPoint)flipWindowPointToView:(const NSPoint&)windowPoint
93 view:(NSView*)view; 111 view:(NSView*)view;
94 // Given a point in window coordinates and a view in that window, return a 112 // Given a point in window coordinates and a view in that window, return a
95 // flipped point in screen coordinates. 113 // flipped point in screen coordinates.
96 - (NSPoint)flipWindowPointToScreen:(const NSPoint&)windowPoint 114 - (NSPoint)flipWindowPointToScreen:(const NSPoint&)windowPoint
97 view:(NSView*)view; 115 view:(NSView*)view;
98 @end 116 @end
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_mac.mm ('k') | content/browser/web_contents/web_drag_dest_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698