| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bookmarks/bookmark_bar_folder_view.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" | 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" |
| 10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // makes things more of a pain but there should be no excuse for laziness. | 54 // makes things more of a pain but there should be no excuse for laziness. |
| 55 // http://crbug.com/35966 | 55 // http://crbug.com/35966 |
| 56 - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)info { | 56 - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)info { |
| 57 inDrag_ = YES; | 57 inDrag_ = YES; |
| 58 if (![[self controller] draggingAllowed:info]) | 58 if (![[self controller] draggingAllowed:info]) |
| 59 return NSDragOperationNone; | 59 return NSDragOperationNone; |
| 60 if ([[info draggingPasteboard] | 60 if ([[info draggingPasteboard] |
| 61 dataForType:ui::ClipboardUtil::UTIForPasteboardType( | 61 dataForType:ui::ClipboardUtil::UTIForPasteboardType( |
| 62 kBookmarkButtonDragType)] || | 62 kBookmarkButtonDragType)] || |
| 63 bookmarks::PasteboardContainsBookmarks(ui::CLIPBOARD_TYPE_DRAG) || | 63 bookmarks::PasteboardContainsBookmarks(ui::CLIPBOARD_TYPE_DRAG) || |
| 64 [[info draggingPasteboard] containsURLData]) { | 64 [[info draggingPasteboard] containsURLDataConvertingTextToURL:YES]) { |
| 65 // Find the position of the drop indicator. | 65 // Find the position of the drop indicator. |
| 66 BOOL showIt = [[self controller] | 66 BOOL showIt = [[self controller] |
| 67 shouldShowIndicatorShownForPoint:[info draggingLocation]]; | 67 shouldShowIndicatorShownForPoint:[info draggingLocation]]; |
| 68 if (!showIt) { | 68 if (!showIt) { |
| 69 [self setDropIndicatorShown:NO]; | 69 [self setDropIndicatorShown:NO]; |
| 70 } else { | 70 } else { |
| 71 [self setDropIndicatorShown:YES]; | 71 [self setDropIndicatorShown:YES]; |
| 72 | 72 |
| 73 CGFloat y = [[self controller] | 73 CGFloat y = [[self controller] |
| 74 indicatorPosForDragToPoint:[info draggingLocation]]; | 74 indicatorPosForDragToPoint:[info draggingLocation]]; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return YES; | 124 return YES; |
| 125 } | 125 } |
| 126 | 126 |
| 127 // This code is practically identical to the same function in BookmarkBarView | 127 // This code is practically identical to the same function in BookmarkBarView |
| 128 // with the only difference being how the controller is retrieved. | 128 // with the only difference being how the controller is retrieved. |
| 129 // TODO(mrossetti,jrg): http://crbug.com/35966 | 129 // TODO(mrossetti,jrg): http://crbug.com/35966 |
| 130 // Implement NSDraggingDestination protocol method | 130 // Implement NSDraggingDestination protocol method |
| 131 // performDragOperation: for URLs. | 131 // performDragOperation: for URLs. |
| 132 - (BOOL)performDragOperationForURL:(id<NSDraggingInfo>)info { | 132 - (BOOL)performDragOperationForURL:(id<NSDraggingInfo>)info { |
| 133 NSPasteboard* pboard = [info draggingPasteboard]; | 133 NSPasteboard* pboard = [info draggingPasteboard]; |
| 134 DCHECK([pboard containsURLData]); | 134 DCHECK([pboard containsURLDataConvertingTextToURL:YES]); |
| 135 | 135 |
| 136 NSArray* urls = nil; | 136 NSArray* urls = nil; |
| 137 NSArray* titles = nil; | 137 NSArray* titles = nil; |
| 138 [pboard getURLs:&urls andTitles:&titles convertingFilenames:YES]; | 138 [pboard getURLs:&urls |
| 139 andTitles:&titles |
| 140 convertingFilenames:YES |
| 141 convertingTextToURL:YES]; |
| 139 | 142 |
| 140 return [[self controller] addURLs:urls | 143 return [[self controller] addURLs:urls |
| 141 withTitles:titles | 144 withTitles:titles |
| 142 at:[info draggingLocation]]; | 145 at:[info draggingLocation]]; |
| 143 } | 146 } |
| 144 | 147 |
| 145 // This code is practically identical to the same function in BookmarkBarView | 148 // This code is practically identical to the same function in BookmarkBarView |
| 146 // with the only difference being how the controller is retrieved. | 149 // with the only difference being how the controller is retrieved. |
| 147 // http://crbug.com/35966 | 150 // http://crbug.com/35966 |
| 148 // Implement NSDraggingDestination protocol method | 151 // Implement NSDraggingDestination protocol method |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 183 } |
| 181 | 184 |
| 182 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info { | 185 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info { |
| 183 if ([[self controller] dragBookmarkData:info]) | 186 if ([[self controller] dragBookmarkData:info]) |
| 184 return YES; | 187 return YES; |
| 185 NSPasteboard* pboard = [info draggingPasteboard]; | 188 NSPasteboard* pboard = [info draggingPasteboard]; |
| 186 if ([pboard dataForType:ui::ClipboardUtil::UTIForPasteboardType( | 189 if ([pboard dataForType:ui::ClipboardUtil::UTIForPasteboardType( |
| 187 kBookmarkButtonDragType)] && | 190 kBookmarkButtonDragType)] && |
| 188 [self performDragOperationForBookmarkButton:info]) | 191 [self performDragOperationForBookmarkButton:info]) |
| 189 return YES; | 192 return YES; |
| 190 if ([pboard containsURLData] && [self performDragOperationForURL:info]) | 193 if ([pboard containsURLDataConvertingTextToURL:YES] && |
| 194 [self performDragOperationForURL:info]) |
| 191 return YES; | 195 return YES; |
| 192 return NO; | 196 return NO; |
| 193 } | 197 } |
| 194 | 198 |
| 195 - (void)setDropIndicatorShown:(BOOL)flag { | 199 - (void)setDropIndicatorShown:(BOOL)flag { |
| 196 if (dropIndicatorShown_ == flag) | 200 if (dropIndicatorShown_ == flag) |
| 197 return; | 201 return; |
| 198 | 202 |
| 199 dropIndicatorShown_ = flag; | 203 dropIndicatorShown_ = flag; |
| 200 if (dropIndicatorShown_) { | 204 if (dropIndicatorShown_) { |
| 201 NSRect frame = NSInsetRect([self bounds], 4, 0); | 205 NSRect frame = NSInsetRect([self bounds], 4, 0); |
| 202 frame.size.height = 1; | 206 frame.size.height = 1; |
| 203 dropIndicator_.reset([[NSBox alloc] initWithFrame:frame]); | 207 dropIndicator_.reset([[NSBox alloc] initWithFrame:frame]); |
| 204 [dropIndicator_ setBoxType:NSBoxSeparator]; | 208 [dropIndicator_ setBoxType:NSBoxSeparator]; |
| 205 [dropIndicator_ setBorderType:NSLineBorder]; | 209 [dropIndicator_ setBorderType:NSLineBorder]; |
| 206 [dropIndicator_ setAlphaValue:0.85]; | 210 [dropIndicator_ setAlphaValue:0.85]; |
| 207 [self addSubview:dropIndicator_]; | 211 [self addSubview:dropIndicator_]; |
| 208 } else { | 212 } else { |
| 209 [dropIndicator_ removeFromSuperview]; | 213 [dropIndicator_ removeFromSuperview]; |
| 210 dropIndicator_.reset(); | 214 dropIndicator_.reset(); |
| 211 } | 215 } |
| 212 } | 216 } |
| 213 | 217 |
| 214 @end | 218 @end |
| OLD | NEW |