Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 } | 228 } |
| 229 | 229 |
| 230 @end | 230 @end |
| 231 | 231 |
| 232 @implementation BookmarkBarFolderController | 232 @implementation BookmarkBarFolderController |
| 233 | 233 |
| 234 @synthesize subFolderGrowthToRight = subFolderGrowthToRight_; | 234 @synthesize subFolderGrowthToRight = subFolderGrowthToRight_; |
| 235 | 235 |
| 236 - (id)initWithParentButton:(BookmarkButton*)button | 236 - (id)initWithParentButton:(BookmarkButton*)button |
| 237 parentController:(BookmarkBarFolderController*)parentController | 237 parentController:(BookmarkBarFolderController*)parentController |
| 238 barController:(BookmarkBarController*)barController { | 238 barController:(BookmarkBarController*)barController |
| 239 profile:(Profile*)profile { | |
|
Alexei Svitkine (slow)
2013/03/27 15:16:39
align the :'s
tfarina
2013/03/27 21:02:27
Done.
| |
| 239 NSString* nibPath = | 240 NSString* nibPath = |
| 240 [base::mac::FrameworkBundle() pathForResource:@"BookmarkBarFolderWindow" | 241 [base::mac::FrameworkBundle() pathForResource:@"BookmarkBarFolderWindow" |
| 241 ofType:@"nib"]; | 242 ofType:@"nib"]; |
| 242 if ((self = [super initWithWindowNibPath:nibPath owner:self])) { | 243 if ((self = [super initWithWindowNibPath:nibPath owner:self])) { |
| 243 parentButton_.reset([button retain]); | 244 parentButton_.reset([button retain]); |
| 244 selectedIndex_ = -1; | 245 selectedIndex_ = -1; |
| 245 | 246 |
| 247 profile_ = profile; | |
| 248 | |
| 246 // We want the button to remain bordered as part of the menu path. | 249 // We want the button to remain bordered as part of the menu path. |
| 247 [button forceButtonBorderToStayOnAlways:YES]; | 250 [button forceButtonBorderToStayOnAlways:YES]; |
| 248 | 251 |
| 249 // Pick the parent button's screen to be the screen upon which all display | 252 // Pick the parent button's screen to be the screen upon which all display |
| 250 // happens. This loop over all screens is not equivalent to | 253 // happens. This loop over all screens is not equivalent to |
| 251 // |[[button window] screen]|. BookmarkButtons are commonly positioned near | 254 // |[[button window] screen]|. BookmarkButtons are commonly positioned near |
| 252 // the edge of their windows (both in the bookmark bar and in other bookmark | 255 // the edge of their windows (both in the bookmark bar and in other bookmark |
| 253 // menus), and |[[button window] screen]| would return the screen that the | 256 // menus), and |[[button window] screen]| would return the screen that the |
| 254 // majority of their window was on even if the parent button were clearly | 257 // majority of their window was on even if the parent button were clearly |
| 255 // contained within a different screen. | 258 // contained within a different screen. |
| (...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1455 } | 1458 } |
| 1456 } | 1459 } |
| 1457 return dragged; | 1460 return dragged; |
| 1458 } | 1461 } |
| 1459 | 1462 |
| 1460 // TODO(mrossetti,jrg): Identical to the same function in BookmarkBarController. | 1463 // TODO(mrossetti,jrg): Identical to the same function in BookmarkBarController. |
| 1461 // http://crbug.com/35966 | 1464 // http://crbug.com/35966 |
| 1462 - (std::vector<const BookmarkNode*>)retrieveBookmarkNodeData { | 1465 - (std::vector<const BookmarkNode*>)retrieveBookmarkNodeData { |
| 1463 std::vector<const BookmarkNode*> dragDataNodes; | 1466 std::vector<const BookmarkNode*> dragDataNodes; |
| 1464 BookmarkNodeData dragData; | 1467 BookmarkNodeData dragData; |
| 1465 if(dragData.ReadFromDragClipboard()) { | 1468 if (dragData.ReadFromDragClipboard()) { |
| 1466 BookmarkModel* bookmarkModel = [self bookmarkModel]; | 1469 std::vector<const BookmarkNode*> nodes(dragData.GetNodes(profile_)); |
| 1467 Profile* profile = bookmarkModel->profile(); | |
| 1468 std::vector<const BookmarkNode*> nodes(dragData.GetNodes(profile)); | |
| 1469 dragDataNodes.assign(nodes.begin(), nodes.end()); | 1470 dragDataNodes.assign(nodes.begin(), nodes.end()); |
| 1470 } | 1471 } |
| 1471 return dragDataNodes; | 1472 return dragDataNodes; |
| 1472 } | 1473 } |
| 1473 | 1474 |
| 1474 // Return YES if we should show the drop indicator, else NO. | 1475 // Return YES if we should show the drop indicator, else NO. |
| 1475 // TODO(jrg): ARGH code dup! | 1476 // TODO(jrg): ARGH code dup! |
| 1476 // http://crbug.com/35966 | 1477 // http://crbug.com/35966 |
| 1477 - (BOOL)shouldShowIndicatorShownForPoint:(NSPoint)point { | 1478 - (BOOL)shouldShowIndicatorShownForPoint:(NSPoint)point { |
| 1478 return ![self buttonForDroppingOnAtPoint:point]; | 1479 return ![self buttonForDroppingOnAtPoint:point]; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1724 | 1725 |
| 1725 // Add a new folder controller as triggered by the given folder button. | 1726 // Add a new folder controller as triggered by the given folder button. |
| 1726 - (void)addNewFolderControllerWithParentButton:(BookmarkButton*)parentButton { | 1727 - (void)addNewFolderControllerWithParentButton:(BookmarkButton*)parentButton { |
| 1727 if (folderController_) | 1728 if (folderController_) |
| 1728 [self closeBookmarkFolder:self]; | 1729 [self closeBookmarkFolder:self]; |
| 1729 | 1730 |
| 1730 // Folder controller, like many window controllers, owns itself. | 1731 // Folder controller, like many window controllers, owns itself. |
| 1731 folderController_ = | 1732 folderController_ = |
| 1732 [[BookmarkBarFolderController alloc] initWithParentButton:parentButton | 1733 [[BookmarkBarFolderController alloc] initWithParentButton:parentButton |
| 1733 parentController:self | 1734 parentController:self |
| 1734 barController:barController_]; | 1735 barController:barController_ |
| 1736 profile:profile_]; | |
|
Alexei Svitkine (slow)
2013/03/27 15:16:39
Align the :'s
tfarina
2013/03/27 21:02:27
Done.
| |
| 1735 [folderController_ showWindow:self]; | 1737 [folderController_ showWindow:self]; |
| 1736 } | 1738 } |
| 1737 | 1739 |
| 1738 - (void)openAll:(const BookmarkNode*)node | 1740 - (void)openAll:(const BookmarkNode*)node |
| 1739 disposition:(WindowOpenDisposition)disposition { | 1741 disposition:(WindowOpenDisposition)disposition { |
| 1740 [barController_ openAll:node disposition:disposition]; | 1742 [barController_ openAll:node disposition:disposition]; |
| 1741 } | 1743 } |
| 1742 | 1744 |
| 1743 - (void)addButtonForNode:(const BookmarkNode*)node | 1745 - (void)addButtonForNode:(const BookmarkNode*)node |
| 1744 atIndex:(NSInteger)buttonIndex { | 1746 atIndex:(NSInteger)buttonIndex { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1965 | 1967 |
| 1966 - (void)setIgnoreAnimations:(BOOL)ignore { | 1968 - (void)setIgnoreAnimations:(BOOL)ignore { |
| 1967 ignoreAnimations_ = ignore; | 1969 ignoreAnimations_ = ignore; |
| 1968 } | 1970 } |
| 1969 | 1971 |
| 1970 - (BookmarkButton*)buttonThatMouseIsIn { | 1972 - (BookmarkButton*)buttonThatMouseIsIn { |
| 1971 return buttonThatMouseIsIn_; | 1973 return buttonThatMouseIsIn_; |
| 1972 } | 1974 } |
| 1973 | 1975 |
| 1974 @end // BookmarkBarFolderController | 1976 @end // BookmarkBarFolderController |
| OLD | NEW |