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

Unified Diff: chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.mm

Issue 12095074: Media Galleries: Keep media gallery permission dialogs in sync with the gallery (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix nit Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
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];
}

Powered by Google App Engine
This is Rietveld 408576698