| 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,32 @@
|
| 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];
|
| + for (; i < [checkboxes_ count]; ++i) {
|
| + 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];
|
| }
|
| -
|
| - UpdateGalleryCheckbox(checkbox, gallery, permitted);
|
| UpdateCheckboxContainerFrame();
|
| [alert_ layout];
|
| }
|
|
|