| 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_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 NSMenu* menu = [button menu]; | 384 NSMenu* menu = [button menu]; |
| 385 NSMenuItem* item = [menu addItemWithTitle:title | 385 NSMenuItem* item = [menu addItemWithTitle:title |
| 386 action:NULL | 386 action:NULL |
| 387 keyEquivalent:@""]; | 387 keyEquivalent:@""]; |
| 388 [item setRepresentedObject:[NSValue valueWithPointer:parent]]; | 388 [item setRepresentedObject:[NSValue valueWithPointer:parent]]; |
| 389 [item setIndentationLevel:indentation]; | 389 [item setIndentationLevel:indentation]; |
| 390 ++indentation; | 390 ++indentation; |
| 391 } | 391 } |
| 392 for (int i = 0; i < parent->child_count(); i++) { | 392 for (int i = 0; i < parent->child_count(); i++) { |
| 393 const BookmarkNode* child = parent->GetChild(i); | 393 const BookmarkNode* child = parent->GetChild(i); |
| 394 if (child->is_folder()) | 394 if (child->is_folder() && child->IsVisible()) |
| 395 [self addFolderNodes:child | 395 [self addFolderNodes:child |
| 396 toPopUpButton:button | 396 toPopUpButton:button |
| 397 indentation:indentation]; | 397 indentation:indentation]; |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 - (void)setTitle:(NSString*)title parentFolder:(const BookmarkNode*)parent { | 401 - (void)setTitle:(NSString*)title parentFolder:(const BookmarkNode*)parent { |
| 402 [nameTextField_ setStringValue:title]; | 402 [nameTextField_ setStringValue:title]; |
| 403 [self setParentFolderSelection:parent]; | 403 [self setParentFolderSelection:parent]; |
| 404 } | 404 } |
| 405 | 405 |
| 406 // Pick a specific parent node in the selection by finding the right | 406 // Pick a specific parent node in the selection by finding the right |
| 407 // pop up button index. | 407 // pop up button index. |
| 408 - (void)setParentFolderSelection:(const BookmarkNode*)parent { | 408 - (void)setParentFolderSelection:(const BookmarkNode*)parent { |
| 409 // Expectation: There is a parent mapping for all items in the | 409 // Expectation: There is a parent mapping for all items in the |
| 410 // folderPopUpButton except the last one ("Choose another folder..."). | 410 // folderPopUpButton except the last one ("Choose another folder..."). |
| 411 NSMenu* menu = [folderPopUpButton_ menu]; | 411 NSMenu* menu = [folderPopUpButton_ menu]; |
| 412 NSValue* parentValue = [NSValue valueWithPointer:parent]; | 412 NSValue* parentValue = [NSValue valueWithPointer:parent]; |
| 413 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; | 413 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; |
| 414 DCHECK(idx != -1); | 414 DCHECK(idx != -1); |
| 415 [folderPopUpButton_ selectItemAtIndex:idx]; | 415 [folderPopUpButton_ selectItemAtIndex:idx]; |
| 416 } | 416 } |
| 417 | 417 |
| 418 - (NSPopUpButton*)folderPopUpButton { | 418 - (NSPopUpButton*)folderPopUpButton { |
| 419 return folderPopUpButton_; | 419 return folderPopUpButton_; |
| 420 } | 420 } |
| 421 | 421 |
| 422 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) | 422 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) |
| OLD | NEW |