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

Side by Side Diff: chrome/browser/ui/cocoa/url_drop_target.mm

Issue 2014733003: Removing parsing of text from pasteboard. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compilation fix Created 4 years, 6 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 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 "chrome/browser/ui/cocoa/url_drop_target.h" 5 #import "chrome/browser/ui/cocoa/url_drop_target.h"
6 6
7 #include "chrome/browser/ui/cocoa/drag_util.h" 7 #include "chrome/browser/ui/cocoa/drag_util.h"
8 #import "third_party/mozilla/NSPasteboard+Utils.h" 8 #import "third_party/mozilla/NSPasteboard+Utils.h"
9 #include "ui/base/clipboard/clipboard_util_mac.h" 9 #include "ui/base/clipboard/clipboard_util_mac.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { 77 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
78 [self hideIndicator]; 78 [self hideIndicator];
79 79
80 NSPasteboard* pboard = [sender draggingPasteboard]; 80 NSPasteboard* pboard = [sender draggingPasteboard];
81 NSArray* supportedTypes = [NSArray arrayWithObjects:NSStringPboardType, nil]; 81 NSArray* supportedTypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
82 NSString* bestType = [pboard availableTypeFromArray:supportedTypes]; 82 NSString* bestType = [pboard availableTypeFromArray:supportedTypes];
83 83
84 NSPoint dropPoint = 84 NSPoint dropPoint =
85 [view_ convertPoint:[sender draggingLocation] fromView:nil]; 85 [view_ convertPoint:[sender draggingLocation] fromView:nil];
86 // Tell the window controller about the dropped URL(s). 86 // Tell the window controller about the dropped URL(s).
87 if ([pboard containsURLData]) { 87 if ([pboard containsURLDataConvertingTextToURL:NO]) {
88 NSArray* urls = nil; 88 NSArray* urls = nil;
89 NSArray* titles; // discarded 89 NSArray* titles; // discarded
90 [pboard getURLs:&urls andTitles:&titles convertingFilenames:YES]; 90 [pboard getURLs:&urls
91 andTitles:&titles
92 convertingFilenames:YES
93 convertingTextToURL:NO];
91 94
92 if ([urls count]) { 95 if ([urls count]) {
93 [[view_ urlDropController] dropURLs:urls inView:view_ at:dropPoint]; 96 [[view_ urlDropController] dropURLs:urls inView:view_ at:dropPoint];
94 return YES; 97 return YES;
95 } 98 }
96 } else if (NSString* text = [pboard stringForType:bestType]) { 99 } else if (NSString* text = [pboard stringForType:bestType]) {
97 // This does not include any URLs, so treat it as plain text if we can 100 // This does not include any URLs, so treat it as plain text if we can
98 // get NSString. 101 // get NSString.
99 [[view_ urlDropController] dropText:text inView:view_ at:dropPoint]; 102 [[view_ urlDropController] dropText:text inView:view_ at:dropPoint];
100 return YES; 103 return YES;
101 } 104 }
102 105
103 return NO; 106 return NO;
104 } 107 }
105 108
106 @end // @implementation URLDropTargetHandler 109 @end // @implementation URLDropTargetHandler
107 110
108 @implementation URLDropTargetHandler(Private) 111 @implementation URLDropTargetHandler(Private)
109 112
110 - (NSDragOperation)getDragOperation:(id<NSDraggingInfo>)sender { 113 - (NSDragOperation)getDragOperation:(id<NSDraggingInfo>)sender {
111 NSPasteboard* pboard = [sender draggingPasteboard]; 114 NSPasteboard* pboard = [sender draggingPasteboard];
112 NSArray *supportedTypes = [NSArray arrayWithObjects:NSStringPboardType, nil]; 115 NSArray *supportedTypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
113 NSString *bestType = [pboard availableTypeFromArray:supportedTypes]; 116 NSString *bestType = [pboard availableTypeFromArray:supportedTypes];
114 if (![pboard containsURLData] && ![pboard stringForType:bestType]) 117 if (![pboard containsURLDataConvertingTextToURL:YES] &&
118 ![pboard stringForType:bestType])
115 return NSDragOperationNone; 119 return NSDragOperationNone;
116 120
117 // Only allow the copy operation. 121 // Only allow the copy operation.
118 return [sender draggingSourceOperationMask] & NSDragOperationCopy; 122 return [sender draggingSourceOperationMask] & NSDragOperationCopy;
119 } 123 }
120 124
121 - (void)hideIndicator { 125 - (void)hideIndicator {
122 [[view_ urlDropController] hideDropURLsIndicatorInView:view_]; 126 [[view_ urlDropController] hideDropURLsIndicatorInView:view_];
123 } 127 }
124 128
125 @end // @implementation URLDropTargetHandler(Private) 129 @end // @implementation URLDropTargetHandler(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698