| 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_view.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h" | 7 #include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #import "chrome/browser/themes/theme_service.h" |
| 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" | 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" |
| 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 13 #import "chrome/browser/ui/cocoa/themed_window.h" | 14 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 14 #import "chrome/browser/ui/cocoa/view_id_util.h" | 15 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 15 #import "chrome/browser/themes/theme_service.h" | 16 #include "content/public/browser/user_metrics.h" |
| 16 #include "content/browser/user_metrics.h" | |
| 17 #import "third_party/mozilla/NSPasteboard+Utils.h" | 17 #import "third_party/mozilla/NSPasteboard+Utils.h" |
| 18 | 18 |
| 19 using content::UserMetricsAction; |
| 20 |
| 19 @interface BookmarkBarView (Private) | 21 @interface BookmarkBarView (Private) |
| 20 - (void)themeDidChangeNotification:(NSNotification*)aNotification; | 22 - (void)themeDidChangeNotification:(NSNotification*)aNotification; |
| 21 - (void)updateTheme:(ui::ThemeProvider*)themeProvider; | 23 - (void)updateTheme:(ui::ThemeProvider*)themeProvider; |
| 22 @end | 24 @end |
| 23 | 25 |
| 24 @implementation BookmarkBarView | 26 @implementation BookmarkBarView |
| 25 | 27 |
| 26 @synthesize dropIndicatorShown = dropIndicatorShown_; | 28 @synthesize dropIndicatorShown = dropIndicatorShown_; |
| 27 @synthesize dropIndicatorPosition = dropIndicatorPosition_; | 29 @synthesize dropIndicatorPosition = dropIndicatorPosition_; |
| 28 @synthesize noItemContainer = noItemContainer_; | 30 @synthesize noItemContainer = noItemContainer_; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 const BookmarkNode* const source_node = [button bookmarkNode]; | 237 const BookmarkNode* const source_node = [button bookmarkNode]; |
| 236 const BookmarkNode* const target_node = | 238 const BookmarkNode* const target_node = |
| 237 model->GetNodeByID(source_node->id()); | 239 model->GetNodeByID(source_node->id()); |
| 238 | 240 |
| 239 BOOL copy = | 241 BOOL copy = |
| 240 !([info draggingSourceOperationMask] & NSDragOperationMove) || | 242 !([info draggingSourceOperationMask] & NSDragOperationMove) || |
| 241 (source_node != target_node); | 243 (source_node != target_node); |
| 242 rtn = [controller_ dragButton:button | 244 rtn = [controller_ dragButton:button |
| 243 to:[info draggingLocation] | 245 to:[info draggingLocation] |
| 244 copy:copy]; | 246 copy:copy]; |
| 245 UserMetrics::RecordAction(UserMetricsAction("BookmarkBar_DragEnd")); | 247 content::RecordAction(UserMetricsAction("BookmarkBar_DragEnd")); |
| 246 } | 248 } |
| 247 return rtn; | 249 return rtn; |
| 248 } | 250 } |
| 249 | 251 |
| 250 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info { | 252 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info { |
| 251 if ([controller_ dragBookmarkData:info]) | 253 if ([controller_ dragBookmarkData:info]) |
| 252 return YES; | 254 return YES; |
| 253 NSPasteboard* pboard = [info draggingPasteboard]; | 255 NSPasteboard* pboard = [info draggingPasteboard]; |
| 254 if ([pboard dataForType:kBookmarkButtonDragType]) { | 256 if ([pboard dataForType:kBookmarkButtonDragType]) { |
| 255 if ([self performDragOperationForBookmarkButton:info]) | 257 if ([self performDragOperationForBookmarkButton:info]) |
| 256 return YES; | 258 return YES; |
| 257 // Fall through.... | 259 // Fall through.... |
| 258 } | 260 } |
| 259 if ([pboard containsURLData]) { | 261 if ([pboard containsURLData]) { |
| 260 if ([self performDragOperationForURL:info]) | 262 if ([self performDragOperationForURL:info]) |
| 261 return YES; | 263 return YES; |
| 262 } | 264 } |
| 263 return NO; | 265 return NO; |
| 264 } | 266 } |
| 265 | 267 |
| 266 - (void)setController:(id)controller { | 268 - (void)setController:(id)controller { |
| 267 controller_ = controller; | 269 controller_ = controller; |
| 268 } | 270 } |
| 269 | 271 |
| 270 - (ViewID)viewID { | 272 - (ViewID)viewID { |
| 271 return VIEW_ID_BOOKMARK_BAR; | 273 return VIEW_ID_BOOKMARK_BAR; |
| 272 } | 274 } |
| 273 | 275 |
| 274 @end // @implementation BookmarkBarView | 276 @end // @implementation BookmarkBarView |
| OLD | NEW |