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

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

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 years, 6 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 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "chrome/browser/ui/chrome_style.h" 8 #include "chrome/browser/ui/chrome_style.h"
9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_alert.h" 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_alert.h"
10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 keyEquivalent:kKeyEquivalentNone 91 keyEquivalent:kKeyEquivalentNone
92 target:cocoa_controller_ 92 target:cocoa_controller_
93 action:@selector(onAddFolderClicked:)]; 93 action:@selector(onAddFolderClicked:)];
94 [[alert_ closeButton] setTarget:cocoa_controller_]; 94 [[alert_ closeButton] setTarget:cocoa_controller_];
95 [[alert_ closeButton] setAction:@selector(onCancelButton:)]; 95 [[alert_ closeButton] setAction:@selector(onCancelButton:)];
96 96
97 InitDialogControls(); 97 InitDialogControls();
98 98
99 // May be NULL during tests. 99 // May be NULL during tests.
100 if (controller->web_contents()) { 100 if (controller->web_contents()) {
101 scoped_nsobject<CustomConstrainedWindowSheet> sheet( 101 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
102 [[CustomConstrainedWindowSheet alloc] 102 [[CustomConstrainedWindowSheet alloc]
103 initWithCustomWindow:[alert_ window]]); 103 initWithCustomWindow:[alert_ window]]);
104 window_.reset(new ConstrainedWindowMac( 104 window_.reset(new ConstrainedWindowMac(
105 this, controller->web_contents(), sheet)); 105 this, controller->web_contents(), sheet));
106 } 106 }
107 } 107 }
108 108
109 MediaGalleriesDialogCocoa::~MediaGalleriesDialogCocoa() { 109 MediaGalleriesDialogCocoa::~MediaGalleriesDialogCocoa() {
110 } 110 }
111 111
112 void MediaGalleriesDialogCocoa::InitDialogControls() { 112 void MediaGalleriesDialogCocoa::InitDialogControls() {
113 accessory_.reset([[NSBox alloc] init]); 113 accessory_.reset([[NSBox alloc] init]);
114 [accessory_ setBoxType:NSBoxCustom]; 114 [accessory_ setBoxType:NSBoxCustom];
115 [accessory_ setBorderType:NSLineBorder]; 115 [accessory_ setBorderType:NSLineBorder];
116 [accessory_ setBorderWidth:1]; 116 [accessory_ setBorderWidth:1];
117 [accessory_ setCornerRadius:0]; 117 [accessory_ setCornerRadius:0];
118 [accessory_ setTitlePosition:NSNoTitle]; 118 [accessory_ setTitlePosition:NSNoTitle];
119 [accessory_ setBorderColor:[NSColor colorWithCalibratedRed:0.625 119 [accessory_ setBorderColor:[NSColor colorWithCalibratedRed:0.625
120 green:0.625 120 green:0.625
121 blue:0.625 121 blue:0.625
122 alpha:1.0]]; 122 alpha:1.0]];
123 123
124 scoped_nsobject<NSScrollView> scroll_view( 124 base::scoped_nsobject<NSScrollView> scroll_view([[NSScrollView alloc]
125 [[NSScrollView alloc] initWithFrame:NSMakeRect( 125 initWithFrame:NSMakeRect(0, 0, kCheckboxMaxWidth, kScrollAreaHeight)]);
126 0, 0, kCheckboxMaxWidth, kScrollAreaHeight)]);
127 [scroll_view setHasVerticalScroller:YES]; 126 [scroll_view setHasVerticalScroller:YES];
128 [scroll_view setHasHorizontalScroller:NO]; 127 [scroll_view setHasHorizontalScroller:NO];
129 [scroll_view setBorderType:NSNoBorder]; 128 [scroll_view setBorderType:NSNoBorder];
130 [scroll_view setAutohidesScrollers:YES]; 129 [scroll_view setAutohidesScrollers:YES];
131 [[accessory_ contentView] addSubview:scroll_view]; 130 [[accessory_ contentView] addSubview:scroll_view];
132 131
133 // Add gallery permission checkboxes inside the scrolling view. 132 // Add gallery permission checkboxes inside the scrolling view.
134 checkbox_container_.reset([[FlippedView alloc] initWithFrame:NSZeroRect]); 133 checkbox_container_.reset([[FlippedView alloc] initWithFrame:NSZeroRect]);
135 checkboxes_.reset([[NSMutableArray alloc] init]); 134 checkboxes_.reset([[NSMutableArray alloc] init]);
136 [scroll_view setDocumentView:checkbox_container_]; 135 [scroll_view setDocumentView:checkbox_container_];
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 iter != permissions.end(); iter++) { 195 iter != permissions.end(); iter++) {
197 const MediaGalleriesDialogController::GalleryPermission& permission = *iter; 196 const MediaGalleriesDialogController::GalleryPermission& permission = *iter;
198 UpdateGalleryCheckbox(permission.pref_info, permission.allowed, y_pos); 197 UpdateGalleryCheckbox(permission.pref_info, permission.allowed, y_pos);
199 y_pos = NSMaxY([[checkboxes_ lastObject] frame]) + kCheckboxMargin; 198 y_pos = NSMaxY([[checkboxes_ lastObject] frame]) + kCheckboxMargin;
200 } 199 }
201 200
202 return y_pos; 201 return y_pos;
203 } 202 }
204 203
205 CGFloat MediaGalleriesDialogCocoa::CreateCheckboxSeparator(CGFloat y_pos) { 204 CGFloat MediaGalleriesDialogCocoa::CreateCheckboxSeparator(CGFloat y_pos) {
206 scoped_nsobject<NSBox> separator([[NSBox alloc] initWithFrame:NSMakeRect( 205 base::scoped_nsobject<NSBox> separator(
206 [[NSBox alloc] initWithFrame:NSMakeRect(
207 0, y_pos + kCheckboxMargin * 0.5, kCheckboxMaxWidth, 1.0)]); 207 0, y_pos + kCheckboxMargin * 0.5, kCheckboxMaxWidth, 1.0)]);
208 [separator setBoxType:NSBoxSeparator]; 208 [separator setBoxType:NSBoxSeparator];
209 [separator setBorderType:NSLineBorder]; 209 [separator setBorderType:NSLineBorder];
210 [separator setAlphaValue:0.2]; 210 [separator setAlphaValue:0.2];
211 [checkbox_container_ addSubview:separator]; 211 [checkbox_container_ addSubview:separator];
212 y_pos += kCheckboxMargin * 0.5 + 4; 212 y_pos += kCheckboxMargin * 0.5 + 4;
213 213
214 scoped_nsobject<NSTextField> unattached_label( 214 base::scoped_nsobject<NSTextField> unattached_label(
215 [[NSTextField alloc] initWithFrame:NSZeroRect]); 215 [[NSTextField alloc] initWithFrame:NSZeroRect]);
216 [unattached_label setEditable:NO]; 216 [unattached_label setEditable:NO];
217 [unattached_label setSelectable:NO]; 217 [unattached_label setSelectable:NO];
218 [unattached_label setBezeled:NO]; 218 [unattached_label setBezeled:NO];
219 [unattached_label setAttributedStringValue: 219 [unattached_label setAttributedStringValue:
220 constrained_window::GetAttributedLabelString( 220 constrained_window::GetAttributedLabelString(
221 base::SysUTF16ToNSString( 221 base::SysUTF16ToNSString(
222 controller_->GetUnattachedLocationsHeader()), 222 controller_->GetUnattachedLocationsHeader()),
223 chrome_style::kTextFontStyle, 223 chrome_style::kTextFontStyle,
224 NSNaturalTextAlignment, 224 NSNaturalTextAlignment,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 break; 281 break;
282 } 282 }
283 } 283 }
284 284
285 } 285 }
286 286
287 void MediaGalleriesDialogCocoa::UpdateGalleryCheckbox( 287 void MediaGalleriesDialogCocoa::UpdateGalleryCheckbox(
288 const MediaGalleryPrefInfo& gallery, 288 const MediaGalleryPrefInfo& gallery,
289 bool permitted, 289 bool permitted,
290 CGFloat y_pos) { 290 CGFloat y_pos) {
291 scoped_nsobject<NSButton> checkbox( 291 base::scoped_nsobject<NSButton> checkbox(
292 [[NSButton alloc] initWithFrame:NSZeroRect]); 292 [[NSButton alloc] initWithFrame:NSZeroRect]);
293 NSString* unique_id = GetUniqueIDForGallery(gallery); 293 NSString* unique_id = GetUniqueIDForGallery(gallery);
294 [[checkbox cell] setRepresentedObject:unique_id]; 294 [[checkbox cell] setRepresentedObject:unique_id];
295 [[checkbox cell] setLineBreakMode:NSLineBreakByTruncatingMiddle]; 295 [[checkbox cell] setLineBreakMode:NSLineBreakByTruncatingMiddle];
296 [checkbox setButtonType:NSSwitchButton]; 296 [checkbox setButtonType:NSSwitchButton];
297 [checkbox setTarget:cocoa_controller_]; 297 [checkbox setTarget:cocoa_controller_];
298 [checkbox setAction:@selector(onCheckboxToggled:)]; 298 [checkbox setAction:@selector(onCheckboxToggled:)];
299 [checkboxes_ addObject:checkbox]; 299 [checkboxes_ addObject:checkbox];
300 300
301 [checkbox setTitle:base::SysUTF16ToNSString( 301 [checkbox setTitle:base::SysUTF16ToNSString(
302 gallery.GetGalleryDisplayName())]; 302 gallery.GetGalleryDisplayName())];
303 [checkbox setToolTip:base::SysUTF16ToNSString(gallery.GetGalleryTooltip())]; 303 [checkbox setToolTip:base::SysUTF16ToNSString(gallery.GetGalleryTooltip())];
304 [checkbox setState:permitted ? NSOnState : NSOffState]; 304 [checkbox setState:permitted ? NSOnState : NSOffState];
305 305
306 [checkbox sizeToFit]; 306 [checkbox sizeToFit];
307 NSRect rect = [checkbox bounds]; 307 NSRect rect = [checkbox bounds];
308 rect.origin.y = y_pos; 308 rect.origin.y = y_pos;
309 rect.origin.x = kCheckboxMargin; 309 rect.origin.x = kCheckboxMargin;
310 rect.size.width = std::min(NSWidth(rect), kCheckboxMaxWidth); 310 rect.size.width = std::min(NSWidth(rect), kCheckboxMaxWidth);
311 [checkbox setFrame:rect]; 311 [checkbox setFrame:rect];
312 [checkbox_container_ addSubview:checkbox]; 312 [checkbox_container_ addSubview:checkbox];
313 313
314 scoped_nsobject<NSTextField> details( 314 base::scoped_nsobject<NSTextField> details(
315 [[NSTextField alloc] initWithFrame:NSZeroRect]); 315 [[NSTextField alloc] initWithFrame:NSZeroRect]);
316 [details setEditable:NO]; 316 [details setEditable:NO];
317 [details setSelectable:NO]; 317 [details setSelectable:NO];
318 [details setBezeled:NO]; 318 [details setBezeled:NO];
319 [details setAttributedStringValue: 319 [details setAttributedStringValue:
320 constrained_window::GetAttributedLabelString( 320 constrained_window::GetAttributedLabelString(
321 base::SysUTF16ToNSString(gallery.GetGalleryAdditionalDetails()), 321 base::SysUTF16ToNSString(gallery.GetGalleryAdditionalDetails()),
322 chrome_style::kTextFontStyle, 322 chrome_style::kTextFontStyle,
323 NSNaturalTextAlignment, 323 NSNaturalTextAlignment,
324 NSLineBreakByClipping 324 NSLineBreakByClipping
325 )]; 325 )];
(...skipping 22 matching lines...) Expand all
348 } 348 }
349 349
350 void MediaGalleriesDialogCocoa::OnConstrainedWindowClosed( 350 void MediaGalleriesDialogCocoa::OnConstrainedWindowClosed(
351 ConstrainedWindowMac* window) { 351 ConstrainedWindowMac* window) {
352 controller_->DialogFinished(accepted_); 352 controller_->DialogFinished(accepted_);
353 } 353 }
354 354
355 // static 355 // static
356 MediaGalleriesDialog* MediaGalleriesDialog::Create( 356 MediaGalleriesDialog* MediaGalleriesDialog::Create(
357 MediaGalleriesDialogController* controller) { 357 MediaGalleriesDialogController* controller) {
358 scoped_nsobject<MediaGalleriesCocoaController> cocoa_controller( 358 base::scoped_nsobject<MediaGalleriesCocoaController> cocoa_controller(
359 [[MediaGalleriesCocoaController alloc] init]); 359 [[MediaGalleriesCocoaController alloc] init]);
360 return new MediaGalleriesDialogCocoa(controller, cocoa_controller); 360 return new MediaGalleriesDialogCocoa(controller, cocoa_controller);
361 } 361 }
362 362
363 } // namespace chrome 363 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698