Chromium Code Reviews| Index: chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.mm |
| =================================================================== |
| --- chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.mm (revision 181443) |
| +++ chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.mm (working copy) |
| @@ -153,6 +153,16 @@ |
| } |
| } |
| +NSButton* MediaGalleriesDialogCocoa::CheckboxForGallery( |
| + const MediaGalleryPrefInfo* gallery) { |
| + NSString* unique_id = GetUniqueIDForGallery(gallery); |
| + for (NSButton* button in checkboxes_.get()) { |
| + if ([[[button cell] representedObject] isEqual:unique_id]) |
| + return button; |
| + } |
| + return nil; |
| +} |
| + |
| void MediaGalleriesDialogCocoa::UpdateGalleryCheckbox( |
| NSButton* checkbox, |
| const MediaGalleryPrefInfo* gallery, |
| @@ -200,17 +210,33 @@ |
| void MediaGalleriesDialogCocoa::UpdateGallery( |
| const MediaGalleryPrefInfo* gallery, |
| bool permitted) { |
| - NSButton* checkbox = nil; |
| - NSString* unique_id = GetUniqueIDForGallery(gallery); |
| + NSButton* checkbox = CheckboxForGallery(gallery); |
| + UpdateGalleryCheckbox(checkbox, gallery, permitted); |
| + UpdateCheckboxContainerFrame(); |
| + [alert_ layout]; |
| +} |
| - for (NSButton* button in checkboxes_.get()) { |
| - if ([[[button cell] representedObject] isEqual:unique_id]) { |
| - checkbox = button; |
| - break; |
| +void MediaGalleriesDialogCocoa::ForgetGallery( |
| + const MediaGalleryPrefInfo* gallery) { |
| + NSButton* checkbox = CheckboxForGallery(gallery); |
| + if (!checkbox) |
| + return; |
| + |
| + // Remove checkbox and reposition the entries below it. |
| + NSUInteger i = [checkboxes_ indexOfObject:checkbox]; |
| + [checkboxes_ removeObjectAtIndex:i]; |
| + while (i < [checkboxes_ count]) { |
|
sail
2013/02/08 20:57:28
for (; i < [checkboxes_ count]; ++i) {}
Lei Zhang
2013/02/09 00:07:43
Done.
|
| + CGFloat y_pos = 0; |
| + if (i > 0) { |
| + y_pos = NSMaxY([[checkboxes_ objectAtIndex:i - 1] frame]) + |
| + kCheckboxMargin; |
| } |
| + checkbox = [checkboxes_ objectAtIndex:i]; |
| + NSRect rect = [checkbox bounds]; |
| + rect.origin.y = y_pos; |
| + [checkbox setFrame:rect]; |
| + ++i; |
| } |
| - |
| - UpdateGalleryCheckbox(checkbox, gallery, permitted); |
| UpdateCheckboxContainerFrame(); |
| [alert_ layout]; |
| } |