| 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 #include "chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.h" |
| 6 | 6 |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "grit/generated_resources.h" | 8 #include "grit/generated_resources.h" |
| 9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 UpdateCheckboxContainerFrame(); | 86 UpdateCheckboxContainerFrame(); |
| 87 [alert_ setAccessoryView:checkbox_container_]; | 87 [alert_ setAccessoryView:checkbox_container_]; |
| 88 | 88 |
| 89 // As a safeguard against the user skipping reading over the dialog and just | 89 // As a safeguard against the user skipping reading over the dialog and just |
| 90 // confirming, the button will be unavailable for dialogs without any checks | 90 // confirming, the button will be unavailable for dialogs without any checks |
| 91 // until the user toggles something. | 91 // until the user toggles something. |
| 92 [[[alert_ buttons] objectAtIndex:0] setEnabled: | 92 [[[alert_ buttons] objectAtIndex:0] setEnabled: |
| 93 controller_->HasPermittedGalleries()]; | 93 controller_->HasPermittedGalleries()]; |
| 94 | 94 |
| 95 set_sheet(alert_); | 95 set_sheet(alert_); |
| 96 window_ = new ConstrainedWindowMac(controller->tab_contents(), this); | 96 // May be NULL during tests. |
| 97 if (controller->tab_contents()) |
| 98 window_ = new ConstrainedWindowMac(controller->tab_contents(), this); |
| 97 } | 99 } |
| 98 | 100 |
| 99 MediaGalleriesDialogCocoa::~MediaGalleriesDialogCocoa() { | 101 MediaGalleriesDialogCocoa::~MediaGalleriesDialogCocoa() { |
| 100 } | 102 } |
| 101 | 103 |
| 102 void MediaGalleriesDialogCocoa::OnAddFolderClicked() { | 104 void MediaGalleriesDialogCocoa::OnAddFolderClicked() { |
| 103 controller_->OnAddFolderClicked(); | 105 controller_->OnAddFolderClicked(); |
| 104 } | 106 } |
| 105 | 107 |
| 106 void MediaGalleriesDialogCocoa::OnCheckboxToggled(NSButton* checkbox) { | 108 void MediaGalleriesDialogCocoa::OnCheckboxToggled(NSButton* checkbox) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 117 controller_->DidToggleGallery(gallery, [checkbox state] == NSOnState); | 119 controller_->DidToggleGallery(gallery, [checkbox state] == NSOnState); |
| 118 break; | 120 break; |
| 119 } | 121 } |
| 120 } | 122 } |
| 121 } | 123 } |
| 122 | 124 |
| 123 void MediaGalleriesDialogCocoa::SheetDidEnd(NSInteger result) { | 125 void MediaGalleriesDialogCocoa::SheetDidEnd(NSInteger result) { |
| 124 switch (result) { | 126 switch (result) { |
| 125 case NSAlertFirstButtonReturn: | 127 case NSAlertFirstButtonReturn: |
| 126 accepted_ = true; | 128 accepted_ = true; |
| 127 window_->CloseConstrainedWindow(); | 129 if (window_) |
| 130 window_->CloseConstrainedWindow(); |
| 128 break; | 131 break; |
| 129 case NSAlertSecondButtonReturn: | 132 case NSAlertSecondButtonReturn: |
| 130 window_->CloseConstrainedWindow(); | 133 if (window_) |
| 134 window_->CloseConstrainedWindow(); |
| 131 break; | 135 break; |
| 132 default: | 136 default: |
| 133 NOTREACHED(); | 137 NOTREACHED(); |
| 134 break; | 138 break; |
| 135 } | 139 } |
| 136 } | 140 } |
| 137 | 141 |
| 138 void MediaGalleriesDialogCocoa::UpdateGalleryCheckbox( | 142 void MediaGalleriesDialogCocoa::UpdateGalleryCheckbox( |
| 139 NSButton* checkbox, | 143 NSButton* checkbox, |
| 140 const MediaGalleryPrefInfo* gallery, | 144 const MediaGalleryPrefInfo* gallery, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 211 |
| 208 // static | 212 // static |
| 209 MediaGalleriesDialog* MediaGalleriesDialog::Create( | 213 MediaGalleriesDialog* MediaGalleriesDialog::Create( |
| 210 MediaGalleriesDialogController* controller) { | 214 MediaGalleriesDialogController* controller) { |
| 211 scoped_nsobject<MediaGalleriesCocoaController> cocoa_controller( | 215 scoped_nsobject<MediaGalleriesCocoaController> cocoa_controller( |
| 212 [[MediaGalleriesCocoaController alloc] init]); | 216 [[MediaGalleriesCocoaController alloc] init]); |
| 213 return new MediaGalleriesDialogCocoa(controller, cocoa_controller); | 217 return new MediaGalleriesDialogCocoa(controller, cocoa_controller); |
| 214 } | 218 } |
| 215 | 219 |
| 216 } // namespace chrome | 220 } // namespace chrome |
| OLD | NEW |