summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa/url_drop_target.mm
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 19:52:36 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 19:52:36 +0000
commitf3035449a5a79955c8cbddaccbfdb18e7d97ba3a (patch)
tree59a0cc2f36397197d50a90d1a7bab6cf101208f2 /chrome/browser/ui/cocoa/url_drop_target.mm
parent0423c02392562f5c7639ad634136ee0b445d2987 (diff)
downloadchromium_src-f3035449a5a79955c8cbddaccbfdb18e7d97ba3a.zip
chromium_src-f3035449a5a79955c8cbddaccbfdb18e7d97ba3a.tar.gz
chromium_src-f3035449a5a79955c8cbddaccbfdb18e7d97ba3a.tar.bz2
Add TEXT_PLAIN as a drag and drop target. And accept TEXT_PLAIN as a target at CompleteDrop(). In the function classify the word and make the URL.(Linux)
If the drop source is not URL, use the source as plain text and pass it to tab_strip_controller and classify it. To pass if the source is URL or plain text, use is_plain_text flag. (Mac) patch from takano.naoki@gmail.com BUG=42797 TEST= 1. Open any site which has text. (news.google.com) 2. Select 2-3 words of text and drag n drop selected text to tabstrip. 3. Chrome opens a new tab with search results (using selected search engine in preferences). git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69034 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/cocoa/url_drop_target.mm')
-rw-r--r--chrome/browser/ui/cocoa/url_drop_target.mm19
1 files changed, 15 insertions, 4 deletions
diff --git a/chrome/browser/ui/cocoa/url_drop_target.mm b/chrome/browser/ui/cocoa/url_drop_target.mm
index d854775..ceca7d2 100644
--- a/chrome/browser/ui/cocoa/url_drop_target.mm
+++ b/chrome/browser/ui/cocoa/url_drop_target.mm
@@ -62,18 +62,26 @@
[self hideIndicator];
NSPasteboard* pboard = [sender draggingPasteboard];
+ NSArray* supportedTypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
+ NSString* bestType = [pboard availableTypeFromArray:supportedTypes];
+
+ NSPoint dropPoint =
+ [view_ convertPoint:[sender draggingLocation] fromView:nil];
+ // Tell the window controller about the dropped URL(s).
if ([pboard containsURLData]) {
NSArray* urls = nil;
NSArray* titles; // discarded
[pboard getURLs:&urls andTitles:&titles convertingFilenames:YES];
if ([urls count]) {
- // Tell the window controller about the dropped URL(s).
- NSPoint dropPoint =
- [view_ convertPoint:[sender draggingLocation] fromView:nil];
[[view_ urlDropController] dropURLs:urls inView:view_ at:dropPoint];
return YES;
}
+ } else if (NSString* text = [pboard stringForType:bestType]) {
+ // This does not include any URLs, so treat it as plain text if we can
+ // get NSString.
+ [[view_ urlDropController] dropText:text inView:view_ at:dropPoint];
+ return YES;
}
return NO;
@@ -84,7 +92,10 @@
@implementation URLDropTargetHandler(Private)
- (NSDragOperation)getDragOperation:(id<NSDraggingInfo>)sender {
- if (![[sender draggingPasteboard] containsURLData])
+ NSPasteboard* pboard = [sender draggingPasteboard];
+ NSArray *supportedTypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
+ NSString *bestType = [pboard availableTypeFromArray:supportedTypes];
+ if (![pboard containsURLData] && ![pboard stringForType:bestType])
return NSDragOperationNone;
// Only allow the copy operation.