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

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

Issue 501135: Revert 34998, more stabbing in the dark to find a perf regression - Mac: impl... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/url_drop_target.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/cocoa/url_drop_target.h" 5 #import "chrome/browser/cocoa/url_drop_target.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "third_party/mozilla/include/NSPasteboard+Utils.h" 8 #import "third_party/mozilla/include/NSPasteboard+Utils.h"
9 9
10 @interface URLDropTargetHandler(Private) 10 @interface URLDropTargetHandler(Private)
11 11
12 // Get the window controller.
13 - (id<URLDropTargetWindowController>)windowController;
14
12 // Gets the appropriate drag operation given the |NSDraggingInfo|. 15 // Gets the appropriate drag operation given the |NSDraggingInfo|.
13 - (NSDragOperation)getDragOperation:(id<NSDraggingInfo>)sender; 16 - (NSDragOperation)getDragOperation:(id<NSDraggingInfo>)sender;
14 17
15 // Tell the window controller to hide the drop indicator. 18 // Tell the window controller to hide the drop indicator.
16 - (void)hideIndicator; 19 - (void)hideIndicator;
17 20
18 @end // @interface URLDropTargetHandler(Private) 21 @end // @interface URLDropTargetHandler(Private)
19 22
20 @implementation URLDropTargetHandler 23 @implementation URLDropTargetHandler
21 24
(...skipping 15 matching lines...) Expand all
37 // (us). 40 // (us).
38 41
39 - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender { 42 - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
40 return [self getDragOperation:sender]; 43 return [self getDragOperation:sender];
41 } 44 }
42 45
43 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender { 46 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender {
44 NSDragOperation dragOp = [self getDragOperation:sender]; 47 NSDragOperation dragOp = [self getDragOperation:sender];
45 if (dragOp == NSDragOperationCopy) { 48 if (dragOp == NSDragOperationCopy) {
46 // Just tell the window controller to update the indicator. 49 // Just tell the window controller to update the indicator.
47 NSPoint hoverPoint = [view_ convertPointFromBase:[sender draggingLocation]]; 50 [[self windowController] indicateDropURLsAt:[sender draggingLocation]];
48 [[view_ urlDropController] indicateDropURLsInView:view_ at:hoverPoint];
49 } 51 }
50 return dragOp; 52 return dragOp;
51 } 53 }
52 54
53 - (void)draggingExited:(id<NSDraggingInfo>)sender { 55 - (void)draggingExited:(id<NSDraggingInfo>)sender {
54 [self hideIndicator]; 56 [self hideIndicator];
55 } 57 }
56 58
57 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { 59 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
58 [self hideIndicator]; 60 [self hideIndicator];
59 61
60 NSPasteboard* pboard = [sender draggingPasteboard]; 62 NSPasteboard* pboard = [sender draggingPasteboard];
61 if ([pboard containsURLData]) { 63 if ([pboard containsURLData]) {
62 NSArray* urls = nil; 64 NSArray* urls = nil;
63 NSArray* titles; // discarded 65 NSArray* titles; // discarded
64 [pboard getURLs:&urls andTitles:&titles]; 66 [pboard getURLs:&urls andTitles:&titles];
65 67
66 if ([urls count]) { 68 if ([urls count]) {
67 // Tell the window controller about the dropped URL(s). 69 // Tell the window controller about the dropped URL(s).
68 NSPoint dropPoint = 70 [[self windowController] dropURLs:urls at:[sender draggingLocation]];
69 [view_ convertPointFromBase:[sender draggingLocation]];
70 [[view_ urlDropController] dropURLs:urls inView:view_ at:dropPoint];
71 return YES; 71 return YES;
72 } 72 }
73 } 73 }
74 74
75 return NO; 75 return NO;
76 } 76 }
77 77
78 @end // @implementation URLDropTargetHandler 78 @end // @implementation URLDropTargetHandler
79 79
80 @implementation URLDropTargetHandler(Private) 80 @implementation URLDropTargetHandler(Private)
81 81
82 - (id<URLDropTargetWindowController>)windowController {
83 id<URLDropTargetWindowController> controller =
84 [[view_ window] windowController];
85 DCHECK([(id)controller conformsToProtocol:
86 @protocol(URLDropTargetWindowController)]);
87 return controller;
88 }
89
82 - (NSDragOperation)getDragOperation:(id<NSDraggingInfo>)sender { 90 - (NSDragOperation)getDragOperation:(id<NSDraggingInfo>)sender {
83 // Only allow the copy operation. 91 // Only allow the copy operation.
84 return [sender draggingSourceOperationMask] & NSDragOperationCopy; 92 return [sender draggingSourceOperationMask] & NSDragOperationCopy;
85 } 93 }
86 94
87 - (void)hideIndicator { 95 - (void)hideIndicator {
88 [[view_ urlDropController] hideDropURLsIndicatorInView:view_]; 96 [[self windowController] hideDropURLsIndicator];
89 } 97 }
90 98
91 @end // @implementation URLDropTargetHandler(Private) 99 @end // @implementation URLDropTargetHandler(Private)
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/url_drop_target.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698