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

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

Issue 2808011: Revert 49986 - crash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/bookmark_bar_folder_controller.h" 5 #import "chrome/browser/cocoa/bookmark_bar_folder_controller.h"
6 #include "base/mac_util.h" 6 #include "base/mac_util.h"
7 #include "base/nsimage_cache_mac.h" 7 #include "base/nsimage_cache_mac.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h" 9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "chrome/browser/bookmarks/bookmark_utils.h" 10 #include "chrome/browser/bookmarks/bookmark_utils.h"
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 // TODO(jrg): ARGH more code dup. 1018 // TODO(jrg): ARGH more code dup.
1019 // http://crbug.com/35966 1019 // http://crbug.com/35966
1020 - (BOOL)dragButton:(BookmarkButton*)sourceButton 1020 - (BOOL)dragButton:(BookmarkButton*)sourceButton
1021 to:(NSPoint)point 1021 to:(NSPoint)point
1022 copy:(BOOL)copy { 1022 copy:(BOOL)copy {
1023 DCHECK([sourceButton isKindOfClass:[BookmarkButton class]]); 1023 DCHECK([sourceButton isKindOfClass:[BookmarkButton class]]);
1024 const BookmarkNode* sourceNode = [sourceButton bookmarkNode]; 1024 const BookmarkNode* sourceNode = [sourceButton bookmarkNode];
1025 return [self dragBookmark:sourceNode to:point copy:copy]; 1025 return [self dragBookmark:sourceNode to:point copy:copy];
1026 } 1026 }
1027 1027
1028 // clang hack to work around http://llvm.org/bugs/show_bug.cgi?id=7386
1029 // TODO(mrossetti,jrg): Identical to the same function in BookmarkBarController.
1030 // http://crbug.com/35966
1031 - (std::vector<const BookmarkNode*>)retrieveBookmarkDragDataNodes {
1032 std::vector<const BookmarkNode*> dragDataNodes;
1033 BookmarkDragData dragData;
1034 if(dragData.ReadFromDragClipboard()) {
1035 BookmarkModel* bookmarkModel = [self bookmarkModel];
1036 Profile* profile = bookmarkModel->profile();
1037 std::vector<const BookmarkNode*> nodes(dragData.GetNodes(profile));
1038 dragDataNodes.assign(nodes.begin(), nodes.end());
1039 }
1040 return dragDataNodes;
1041 }
1042
1043 // TODO(mrossetti,jrg): Identical to the same function in BookmarkBarController. 1028 // TODO(mrossetti,jrg): Identical to the same function in BookmarkBarController.
1044 // http://crbug.com/35966 1029 // http://crbug.com/35966
1045 - (BOOL)dragBookmarkData:(id<NSDraggingInfo>)info { 1030 - (BOOL)dragBookmarkData:(id<NSDraggingInfo>)info {
1046 BOOL dragged = NO; 1031 BOOL dragged = NO;
1047 std::vector<const BookmarkNode*> nodes([self retrieveBookmarkDragDataNodes]); 1032 std::vector<const BookmarkNode*> nodes([self retrieveBookmarkDragDataNodes]);
1048 if (nodes.size()) { 1033 if (nodes.size()) {
1049 BOOL copy = !([info draggingSourceOperationMask] & NSDragOperationMove); 1034 BOOL copy = !([info draggingSourceOperationMask] & NSDragOperationMove);
1050 NSPoint dropPoint = [info draggingLocation]; 1035 NSPoint dropPoint = [info draggingLocation];
1051 for (std::vector<const BookmarkNode*>::const_iterator it = nodes.begin(); 1036 for (std::vector<const BookmarkNode*>::const_iterator it = nodes.begin();
1052 it != nodes.end(); ++it) { 1037 it != nodes.end(); ++it) {
1053 const BookmarkNode* sourceNode = *it; 1038 const BookmarkNode* sourceNode = *it;
1054 dragged = [self dragBookmark:sourceNode to:dropPoint copy:copy]; 1039 dragged = [self dragBookmark:sourceNode to:dropPoint copy:copy];
1055 } 1040 }
1056 } 1041 }
1057 return dragged; 1042 return dragged;
1058 } 1043 }
1059 1044
1045 // TODO(mrossetti,jrg): Identical to the same function in BookmarkBarController.
1046 // http://crbug.com/35966
1047 - (std::vector<const BookmarkNode*>)retrieveBookmarkDragDataNodes {
1048 std::vector<const BookmarkNode*> dragDataNodes;
1049 BookmarkDragData dragData;
1050 if(dragData.ReadFromDragClipboard()) {
1051 BookmarkModel* bookmarkModel = [self bookmarkModel];
1052 Profile* profile = bookmarkModel->profile();
1053 std::vector<const BookmarkNode*> nodes(dragData.GetNodes(profile));
1054 dragDataNodes.assign(nodes.begin(), nodes.end());
1055 }
1056 return dragDataNodes;
1057 }
1058
1060 // Return YES if we should show the drop indicator, else NO. 1059 // Return YES if we should show the drop indicator, else NO.
1061 // TODO(jrg): ARGH code dup! 1060 // TODO(jrg): ARGH code dup!
1062 // http://crbug.com/35966 1061 // http://crbug.com/35966
1063 - (BOOL)shouldShowIndicatorShownForPoint:(NSPoint)point { 1062 - (BOOL)shouldShowIndicatorShownForPoint:(NSPoint)point {
1064 return ![self buttonForDroppingOnAtPoint:point]; 1063 return ![self buttonForDroppingOnAtPoint:point];
1065 } 1064 }
1066 1065
1067 // Return the y position for a drop indicator. 1066 // Return the y position for a drop indicator.
1068 // 1067 //
1069 // TODO(jrg): again we have code dup, sort of, with 1068 // TODO(jrg): again we have code dup, sort of, with
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 return [folderController_ controllerForNode:node]; 1320 return [folderController_ controllerForNode:node];
1322 } 1321 }
1323 1322
1324 #pragma mark TestingAPI Only 1323 #pragma mark TestingAPI Only
1325 1324
1326 - (void)setIgnoreAnimations:(BOOL)ignore { 1325 - (void)setIgnoreAnimations:(BOOL)ignore {
1327 ignoreAnimations_ = ignore; 1326 ignoreAnimations_ = ignore;
1328 } 1327 }
1329 1328
1330 @end // BookmarkBarFolderController 1329 @end // BookmarkBarFolderController
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698