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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.mm

Issue 10854150: Cocoa: Media gallery dialog unit test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 UpdateCheckboxContainerFrame(); 87 UpdateCheckboxContainerFrame();
88 [alert_ setAccessoryView:checkbox_container_]; 88 [alert_ setAccessoryView:checkbox_container_];
89 89
90 // As a safeguard against the user skipping reading over the dialog and just 90 // As a safeguard against the user skipping reading over the dialog and just
91 // confirming, the button will be unavailable for dialogs without any checks 91 // confirming, the button will be unavailable for dialogs without any checks
92 // until the user toggles something. 92 // until the user toggles something.
93 [[[alert_ buttons] objectAtIndex:0] setEnabled: 93 [[[alert_ buttons] objectAtIndex:0] setEnabled:
94 controller_->HasPermittedGalleries()]; 94 controller_->HasPermittedGalleries()];
95 95
96 set_sheet(alert_); 96 set_sheet(alert_);
97 window_ = new ConstrainedWindowMac(controller->tab_contents(), this); 97 // May be NULL during tests.
98 if (controller->tab_contents())
99 window_ = new ConstrainedWindowMac(controller->tab_contents(), this);
98 } 100 }
99 101
100 MediaGalleriesDialogCocoa::~MediaGalleriesDialogCocoa() { 102 MediaGalleriesDialogCocoa::~MediaGalleriesDialogCocoa() {
101 } 103 }
102 104
103 void MediaGalleriesDialogCocoa::OnAddFolderClicked() { 105 void MediaGalleriesDialogCocoa::OnAddFolderClicked() {
104 controller_->OnAddFolderClicked(); 106 controller_->OnAddFolderClicked();
105 } 107 }
106 108
107 void MediaGalleriesDialogCocoa::OnCheckboxToggled(NSButton* checkbox) { 109 void MediaGalleriesDialogCocoa::OnCheckboxToggled(NSButton* checkbox) {
(...skipping 10 matching lines...) Expand all
118 controller_->DidToggleGallery(gallery, [checkbox state] == NSOnState); 120 controller_->DidToggleGallery(gallery, [checkbox state] == NSOnState);
119 break; 121 break;
120 } 122 }
121 } 123 }
122 } 124 }
123 125
124 void MediaGalleriesDialogCocoa::SheetDidEnd(NSInteger result) { 126 void MediaGalleriesDialogCocoa::SheetDidEnd(NSInteger result) {
125 switch (result) { 127 switch (result) {
126 case NSAlertFirstButtonReturn: 128 case NSAlertFirstButtonReturn:
127 accepted_ = true; 129 accepted_ = true;
128 window_->CloseConstrainedWindow(); 130 if (window_)
131 window_->CloseConstrainedWindow();
129 break; 132 break;
130 case NSAlertSecondButtonReturn: 133 case NSAlertSecondButtonReturn:
131 window_->CloseConstrainedWindow(); 134 if (window_)
135 window_->CloseConstrainedWindow();
132 break; 136 break;
133 default: 137 default:
134 NOTREACHED(); 138 NOTREACHED();
135 break; 139 break;
136 } 140 }
137 } 141 }
138 142
139 void MediaGalleriesDialogCocoa::UpdateGalleryCheckbox( 143 void MediaGalleriesDialogCocoa::UpdateGalleryCheckbox(
140 NSButton* checkbox, 144 NSButton* checkbox,
141 const MediaGalleryPrefInfo* gallery, 145 const MediaGalleryPrefInfo* gallery,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 213
210 // static 214 // static
211 MediaGalleriesDialog* MediaGalleriesDialog::Create( 215 MediaGalleriesDialog* MediaGalleriesDialog::Create(
212 MediaGalleriesDialogController* controller) { 216 MediaGalleriesDialogController* controller) {
213 scoped_nsobject<MediaGalleriesCocoaBridge> cocoa_bridge( 217 scoped_nsobject<MediaGalleriesCocoaBridge> cocoa_bridge(
214 [[MediaGalleriesCocoaBridge alloc] init]); 218 [[MediaGalleriesCocoaBridge alloc] init]);
215 return new MediaGalleriesDialogCocoa(controller, cocoa_bridge); 219 return new MediaGalleriesDialogCocoa(controller, cocoa_bridge);
216 } 220 }
217 221
218 } // namespace chrome 222 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698