summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/bookmark_bar_view.mm
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-23 17:51:35 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-23 17:51:35 +0000
commitf4471c57c0d9df0dcbf4bc1b88c69ae1867c4042 (patch)
tree972bcd3cd909f08fdeec22e9831458d32a88d4d5 /chrome/browser/cocoa/bookmark_bar_view.mm
parente9d71884e97fd3484f2aad0b6f7562e3f86a1616 (diff)
downloadchromium_src-f4471c57c0d9df0dcbf4bc1b88c69ae1867c4042.zip
chromium_src-f4471c57c0d9df0dcbf4bc1b88c69ae1867c4042.tar.gz
chromium_src-f4471c57c0d9df0dcbf4bc1b88c69ae1867c4042.tar.bz2
[Mac] Make bookmark bar primitive drag destination.
BUG=18289 TEST=Drag a link or bookmarklet from the web to the bookmark bar. It should be added at the end of the bar. Review URL: http://codereview.chromium.org/336001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29906 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_bar_view.mm')
-rw-r--r--chrome/browser/cocoa/bookmark_bar_view.mm57
1 files changed, 57 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_view.mm b/chrome/browser/cocoa/bookmark_bar_view.mm
index a991e71..d2dc208 100644
--- a/chrome/browser/cocoa/bookmark_bar_view.mm
+++ b/chrome/browser/cocoa/bookmark_bar_view.mm
@@ -3,7 +3,10 @@
// found in the LICENSE file.
#import "chrome/browser/cocoa/bookmark_bar_view.h"
+
+#import "chrome/browser/cocoa/bookmark_bar_controller.h"
#import "third_party/GTM/AppKit/GTMTheme.h"
+#import "third_party/mozilla/include/NSPasteboard+Utils.h"
@interface BookmarkBarView (Private)
- (void)themeDidChangeNotification:(NSNotification*)aNotification;
@@ -14,6 +17,8 @@
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
+ // This probably isn't strictly necessary, but can't hurt.
+ [self unregisterDraggedTypes];
[super dealloc];
}
@@ -23,6 +28,11 @@
selector:@selector(themeDidChangeNotification:)
name:kGTMThemeDidChangeNotification
object:nil];
+
+ DCHECK(controller_ && "Expected this to be hooked via in Interface Builder");
+ NSArray* types = [NSArray arrayWithObjects:NSStringPboardType,
+ NSHTMLPboardType, NSURLPboardType, nil];
+ [self registerForDraggedTypes:types];
}
- (void)viewDidMoveToWindow {
@@ -51,4 +61,51 @@
return noItemTextfield_;
}
+// NSDraggingDestination methods
+
+- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)info {
+ if ([[info draggingPasteboard] containsURLData])
+ return NSDragOperationCopy;
+ return NSDragOperationNone;
+}
+
+- (BOOL)wantsPeriodicDraggingUpdates {
+ // TODO(port): This should probably return |YES| and the controller should
+ // slide the existing bookmark buttons interactively to the side to make
+ // room for the about-to-be-dropped bookmark.
+ return NO;
+}
+
+- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info {
+ if ([[info draggingPasteboard] containsURLData])
+ return NSDragOperationCopy;
+ return NSDragOperationNone;
+}
+
+- (void)draggingEnded:(id<NSDraggingInfo>)info {
+}
+
+- (void)draggingExited:(id<NSDraggingInfo>)info {
+}
+
+- (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)info {
+ return YES;
+}
+
+- (BOOL)performDragOperation:(id<NSDraggingInfo>)info {
+ NSPasteboard* pboard = [info draggingPasteboard];
+ DCHECK([pboard containsURLData]);
+
+ NSArray* urls = nil;
+ NSArray* titles = nil;
+ [pboard getURLs:&urls andTitles:&titles];
+
+ return [controller_ addURLs:urls
+ withTitles:titles
+ at:[info draggingLocation]];
+}
+
+- (void)concludeDragOperation:(id<NSDraggingInfo>)info {
+}
+
@end // @implementation BookmarkBarView