OLD | NEW |
---|---|
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 "content/browser/web_contents/web_drag_dest_mac.h" | 5 #import "content/browser/web_contents/web_drag_dest_mac.h" |
6 | 6 |
7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
8 | 8 |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
11 #include "content/browser/web_contents/web_contents_impl.h" | 11 #include "content/browser/web_contents/web_contents_impl.h" |
12 #include "content/public/browser/render_process_host.h" | |
dcheng
2016/05/24 05:51:50
Nit: remove this include
hush (inactive)
2016/05/24 20:26:09
Done.
| |
12 #include "content/public/browser/web_contents_delegate.h" | 13 #include "content/public/browser/web_contents_delegate.h" |
13 #include "content/public/browser/web_drag_dest_delegate.h" | 14 #include "content/public/browser/web_drag_dest_delegate.h" |
14 #include "content/public/common/drop_data.h" | 15 #include "content/public/common/drop_data.h" |
15 #include "third_party/WebKit/public/web/WebInputEvent.h" | 16 #include "third_party/WebKit/public/web/WebInputEvent.h" |
16 #import "third_party/mozilla/NSPasteboard+Utils.h" | 17 #import "third_party/mozilla/NSPasteboard+Utils.h" |
17 #include "ui/base/clipboard/custom_data_helper.h" | 18 #include "ui/base/clipboard/custom_data_helper.h" |
18 #include "ui/base/cocoa/cocoa_base_utils.h" | 19 #include "ui/base/cocoa/cocoa_base_utils.h" |
19 #import "ui/base/dragdrop/cocoa_dnd_util.h" | 20 #import "ui/base/dragdrop/cocoa_dnd_util.h" |
20 #include "ui/base/window_open_disposition.h" | 21 #include "ui/base/window_open_disposition.h" |
21 | 22 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 view:(NSView*)view { | 124 view:(NSView*)view { |
124 // Save off the RVH so we can tell if it changes during a drag. If it does, | 125 // Save off the RVH so we can tell if it changes during a drag. If it does, |
125 // we need to send a new enter message in draggingUpdated:. | 126 // we need to send a new enter message in draggingUpdated:. |
126 currentRVH_ = webContents_->GetRenderViewHost(); | 127 currentRVH_ = webContents_->GetRenderViewHost(); |
127 | 128 |
128 // Fill out a DropData from pasteboard. | 129 // Fill out a DropData from pasteboard. |
129 std::unique_ptr<DropData> dropData; | 130 std::unique_ptr<DropData> dropData; |
130 dropData.reset(new DropData()); | 131 dropData.reset(new DropData()); |
131 [self populateDropData:dropData.get() | 132 [self populateDropData:dropData.get() |
132 fromPasteboard:[info draggingPasteboard]]; | 133 fromPasteboard:[info draggingPasteboard]]; |
134 currentRVH_->FilterDropData(dropData.get()); | |
133 | 135 |
134 NSDragOperation mask = [info draggingSourceOperationMask]; | 136 NSDragOperation mask = [info draggingSourceOperationMask]; |
135 | 137 |
136 // Give the delegate an opportunity to cancel the drag. | 138 // Give the delegate an opportunity to cancel the drag. |
137 canceled_ = !webContents_->GetDelegate()->CanDragEnter( | 139 canceled_ = !webContents_->GetDelegate()->CanDragEnter( |
138 webContents_, | 140 webContents_, |
139 *dropData, | 141 *dropData, |
140 static_cast<WebDragOperationsMask>(mask)); | 142 static_cast<WebDragOperationsMask>(mask)); |
141 if (canceled_) | 143 if (canceled_) |
142 return NSDragOperationNone; | 144 return NSDragOperationNone; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 delegate_->OnDrop(); | 249 delegate_->OnDrop(); |
248 | 250 |
249 currentRVH_ = NULL; | 251 currentRVH_ = NULL; |
250 | 252 |
251 // Create the appropriate mouse locations for WebCore. The draggingLocation | 253 // Create the appropriate mouse locations for WebCore. The draggingLocation |
252 // is in window coordinates. Both need to be flipped. | 254 // is in window coordinates. Both need to be flipped. |
253 NSPoint windowPoint = [info draggingLocation]; | 255 NSPoint windowPoint = [info draggingLocation]; |
254 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; | 256 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; |
255 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; | 257 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; |
256 webContents_->GetRenderViewHost()->DragTargetDrop( | 258 webContents_->GetRenderViewHost()->DragTargetDrop( |
257 gfx::Point(viewPoint.x, viewPoint.y), | 259 *dropData_, gfx::Point(viewPoint.x, viewPoint.y), |
258 gfx::Point(screenPoint.x, screenPoint.y), | 260 gfx::Point(screenPoint.x, screenPoint.y), GetModifierFlags()); |
259 GetModifierFlags()); | |
260 | 261 |
261 dropData_.reset(); | 262 dropData_.reset(); |
262 | 263 |
263 return YES; | 264 return YES; |
264 } | 265 } |
265 | 266 |
266 // Given |data|, which should not be nil, fill it in using the contents of the | 267 // Given |data|, which should not be nil, fill it in using the contents of the |
267 // given pasteboard. The types handled by this method should be kept in sync | 268 // given pasteboard. The types handled by this method should be kept in sync |
268 // with [WebContentsViewCocoa registerDragTypes]. | 269 // with [WebContentsViewCocoa registerDragTypes]. |
269 - (void)populateDropData:(DropData*)data | 270 - (void)populateDropData:(DropData*)data |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 // Get custom MIME data. | 324 // Get custom MIME data. |
324 if ([types containsObject:ui::kWebCustomDataPboardType]) { | 325 if ([types containsObject:ui::kWebCustomDataPboardType]) { |
325 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; | 326 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; |
326 ui::ReadCustomDataIntoMap([customData bytes], | 327 ui::ReadCustomDataIntoMap([customData bytes], |
327 [customData length], | 328 [customData length], |
328 &data->custom_data); | 329 &data->custom_data); |
329 } | 330 } |
330 } | 331 } |
331 | 332 |
332 @end | 333 @end |
OLD | NEW |