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

Unified Diff: chrome/browser/cocoa/bookmark_bar_view.mm

Issue 336001: [Mac] Make bookmark bar a primitive drag destination. (Closed)
Patch Set: cleanup Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/bookmark_bar_view.mm
diff --git a/chrome/browser/cocoa/bookmark_bar_view.mm b/chrome/browser/cocoa/bookmark_bar_view.mm
index a991e7170a2b5956fd890b981e5c5a70fbc2fa25..d62b7555ed53735e2194c001723d0933df79df3a 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 up via Interface Builder");
+ NSArray* types = [NSArray arrayWithObjects:NSStringPboardType,
+ NSHTMLPboardType, NSURLPboardType, nil];
+ [self registerForDraggedTypes:types];
}
- (void)viewDidMoveToWindow {
@@ -51,4 +61,42 @@
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
pink (ping after 24hrs) 2009/10/27 15:00:43 we've stopped using "port" for TODOs.
Nico 2009/10/27 15:52:42 Will convert it when I touch this file the next ti
+ // 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])
pink (ping after 24hrs) 2009/10/27 15:00:43 todo for DragOperationMove when dragging a bookmar
Nico 2009/10/27 15:52:42 Given that http://crbug.com/17609 is set to "start
+ return NSDragOperationCopy;
+ return NSDragOperationNone;
+}
+
+- (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]];
+}
+
@end // @implementation BookmarkBarView

Powered by Google App Engine
This is Rietveld 408576698