| 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" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 // Give the delegate an opportunity to cancel the drag. | 136 // Give the delegate an opportunity to cancel the drag. |
| 137 canceled_ = !webContents_->GetDelegate()->CanDragEnter( | 137 canceled_ = !webContents_->GetDelegate()->CanDragEnter( |
| 138 webContents_, | 138 webContents_, |
| 139 *dropData, | 139 *dropData, |
| 140 static_cast<WebDragOperationsMask>(mask)); | 140 static_cast<WebDragOperationsMask>(mask)); |
| 141 if (canceled_) | 141 if (canceled_) |
| 142 return NSDragOperationNone; | 142 return NSDragOperationNone; |
| 143 | 143 |
| 144 if ([self onlyAllowsNavigation]) { | 144 if ([self onlyAllowsNavigation]) { |
| 145 if ([[info draggingPasteboard] containsURLData]) | 145 if ([[info draggingPasteboard] containsURLDataConvertingTextToURL:YES]) |
| 146 return NSDragOperationCopy; | 146 return NSDragOperationCopy; |
| 147 return NSDragOperationNone; | 147 return NSDragOperationNone; |
| 148 } | 148 } |
| 149 | 149 |
| 150 if (delegate_) { | 150 if (delegate_) { |
| 151 delegate_->DragInitialize(webContents_); | 151 delegate_->DragInitialize(webContents_); |
| 152 delegate_->OnDragEnter(); | 152 delegate_->OnDragEnter(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 dropData_.swap(dropData); | 155 dropData_.swap(dropData); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info | 193 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info |
| 194 view:(NSView*)view { | 194 view:(NSView*)view { |
| 195 DCHECK(currentRVH_); | 195 DCHECK(currentRVH_); |
| 196 if (currentRVH_ != webContents_->GetRenderViewHost()) | 196 if (currentRVH_ != webContents_->GetRenderViewHost()) |
| 197 [self draggingEntered:info view:view]; | 197 [self draggingEntered:info view:view]; |
| 198 | 198 |
| 199 if (canceled_) | 199 if (canceled_) |
| 200 return NSDragOperationNone; | 200 return NSDragOperationNone; |
| 201 | 201 |
| 202 if ([self onlyAllowsNavigation]) { | 202 if ([self onlyAllowsNavigation]) { |
| 203 if ([[info draggingPasteboard] containsURLData]) | 203 if ([[info draggingPasteboard] containsURLDataConvertingTextToURL:YES]) |
| 204 return NSDragOperationCopy; | 204 return NSDragOperationCopy; |
| 205 return NSDragOperationNone; | 205 return NSDragOperationNone; |
| 206 } | 206 } |
| 207 | 207 |
| 208 // Create the appropriate mouse locations for WebCore. The draggingLocation | 208 // Create the appropriate mouse locations for WebCore. The draggingLocation |
| 209 // is in window coordinates. | 209 // is in window coordinates. |
| 210 NSPoint windowPoint = [info draggingLocation]; | 210 NSPoint windowPoint = [info draggingLocation]; |
| 211 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; | 211 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; |
| 212 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; | 212 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; |
| 213 NSDragOperation mask = [info draggingSourceOperationMask]; | 213 NSDragOperation mask = [info draggingSourceOperationMask]; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 224 } | 224 } |
| 225 | 225 |
| 226 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info | 226 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info |
| 227 view:(NSView*)view { | 227 view:(NSView*)view { |
| 228 if (currentRVH_ != webContents_->GetRenderViewHost()) | 228 if (currentRVH_ != webContents_->GetRenderViewHost()) |
| 229 [self draggingEntered:info view:view]; | 229 [self draggingEntered:info view:view]; |
| 230 | 230 |
| 231 // Check if we only allow navigation and navigate to a url on the pasteboard. | 231 // Check if we only allow navigation and navigate to a url on the pasteboard. |
| 232 if ([self onlyAllowsNavigation]) { | 232 if ([self onlyAllowsNavigation]) { |
| 233 NSPasteboard* pboard = [info draggingPasteboard]; | 233 NSPasteboard* pboard = [info draggingPasteboard]; |
| 234 if ([pboard containsURLData]) { | 234 if ([pboard containsURLDataConvertingTextToURL:YES]) { |
| 235 GURL url; | 235 GURL url; |
| 236 ui::PopulateURLAndTitleFromPasteboard(&url, NULL, pboard, YES); | 236 ui::PopulateURLAndTitleFromPasteboard(&url, NULL, pboard, YES); |
| 237 webContents_->OpenURL(OpenURLParams( | 237 webContents_->OpenURL(OpenURLParams( |
| 238 url, Referrer(), CURRENT_TAB, ui::PAGE_TRANSITION_AUTO_BOOKMARK, | 238 url, Referrer(), CURRENT_TAB, ui::PAGE_TRANSITION_AUTO_BOOKMARK, |
| 239 false)); | 239 false)); |
| 240 return YES; | 240 return YES; |
| 241 } else { | 241 } else { |
| 242 return NO; | 242 return NO; |
| 243 } | 243 } |
| 244 } | 244 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 // Get custom MIME data. | 323 // Get custom MIME data. |
| 324 if ([types containsObject:ui::kWebCustomDataPboardType]) { | 324 if ([types containsObject:ui::kWebCustomDataPboardType]) { |
| 325 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; | 325 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; |
| 326 ui::ReadCustomDataIntoMap([customData bytes], | 326 ui::ReadCustomDataIntoMap([customData bytes], |
| 327 [customData length], | 327 [customData length], |
| 328 &data->custom_data); | 328 &data->custom_data); |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 @end | 332 @end |
| OLD | NEW |