Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 "base/bind.h" | |
| 6 #include "base/message_loop/message_loop.h" | |
| 5 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 6 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 8 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
| 7 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" | 9 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" |
| 8 #include "chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h" | 10 #include "chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h" |
| 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" | 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" |
| 10 #include "chrome/browser/ui/chrome_style.h" | 12 #include "chrome/browser/ui/chrome_style.h" |
| 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_control_u tils.h" | 13 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_control_u tils.h" |
| 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" | 14 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" |
| 13 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h" | 15 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h" |
| 14 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" | 16 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" |
| 15 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 16 #include "ui/base/cocoa/window_size_constants.h" | 18 #include "ui/base/cocoa/window_size_constants.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 const CGFloat kButtonGap = 6.0f; | 23 const CGFloat kButtonGap = 6.0f; |
| 22 const CGFloat kDialogContentMinWidth = 210.0f; | 24 const CGFloat kDialogContentMinWidth = 210.0f; |
| 23 const CGFloat kCvcInputWidth = 64.0f; | 25 const CGFloat kCvcInputWidth = 64.0f; |
| 26 const ui::ResourceBundle::FontStyle kProgressFontStyle = | |
| 27 chrome_style::kTitleFontStyle; | |
| 24 | 28 |
| 25 } // namespace | 29 } // namespace |
| 26 | 30 |
| 27 namespace autofill { | 31 namespace autofill { |
| 28 | 32 |
| 29 // static | 33 // static |
| 30 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow( | 34 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow( |
| 31 CardUnmaskPromptController* controller) { | 35 CardUnmaskPromptController* controller) { |
| 32 return new CardUnmaskPromptViewBridge(controller); | 36 return new CardUnmaskPromptViewBridge(controller); |
| 33 } | 37 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 52 | 56 |
| 53 CardUnmaskPromptViewBridge::~CardUnmaskPromptViewBridge() { | 57 CardUnmaskPromptViewBridge::~CardUnmaskPromptViewBridge() { |
| 54 } | 58 } |
| 55 | 59 |
| 56 void CardUnmaskPromptViewBridge::ControllerGone() { | 60 void CardUnmaskPromptViewBridge::ControllerGone() { |
| 57 controller_ = nullptr; | 61 controller_ = nullptr; |
| 58 PerformClose(); | 62 PerformClose(); |
| 59 } | 63 } |
| 60 | 64 |
| 61 void CardUnmaskPromptViewBridge::DisableAndWaitForVerification() { | 65 void CardUnmaskPromptViewBridge::DisableAndWaitForVerification() { |
| 62 [view_controller_ setInputsEnabled:false]; | 66 [view_controller_ setProgressOverlayText: |
| 63 [view_controller_ updateVerifyButtonEnabled]; | 67 l10n_util::GetStringUTF16( |
| 68 IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_IN_PROGRESS)]; | |
| 64 } | 69 } |
| 65 | 70 |
| 66 void CardUnmaskPromptViewBridge::GotVerificationResult( | 71 void CardUnmaskPromptViewBridge::GotVerificationResult( |
| 67 const base::string16& error_message, | 72 const base::string16& error_message, |
| 68 bool allow_retry) { | 73 bool allow_retry) { |
| 69 [view_controller_ setInputsEnabled:true]; | 74 if (error_message.empty()) { |
| 70 [view_controller_ updateVerifyButtonEnabled]; | 75 [view_controller_ setProgressOverlayText: |
| 76 l10n_util::GetStringUTF16( | |
| 77 IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_SUCCESS)]; | |
| 78 | |
| 79 base::MessageLoop::current()->PostDelayedTask( | |
| 80 FROM_HERE, base::Bind(&CardUnmaskPromptViewBridge::PerformClose, | |
| 81 base::Unretained(this)), | |
|
groby-ooo-7-16
2015/03/19 05:15:38
Unretained this? What happens if you close the dia
bondd
2015/03/19 21:43:37
Done. Same solution as estade@'s here:
https://cod
| |
| 82 base::TimeDelta::FromSeconds(1)); | |
| 83 } else { | |
| 84 [view_controller_ setProgressOverlayText:base::string16()]; | |
| 85 } | |
| 71 } | 86 } |
| 72 | 87 |
| 73 void CardUnmaskPromptViewBridge::OnConstrainedWindowClosed( | 88 void CardUnmaskPromptViewBridge::OnConstrainedWindowClosed( |
| 74 ConstrainedWindowMac* window) { | 89 ConstrainedWindowMac* window) { |
| 75 constrained_window_.reset(); | 90 constrained_window_.reset(); |
| 76 if (controller_) | 91 if (controller_) |
| 77 controller_->OnUnmaskDialogClosed(); | 92 controller_->OnUnmaskDialogClosed(); |
| 78 } | 93 } |
| 79 | 94 |
| 80 CardUnmaskPromptController* CardUnmaskPromptViewBridge::GetController() { | 95 CardUnmaskPromptController* CardUnmaskPromptViewBridge::GetController() { |
| 81 return controller_; | 96 return controller_; |
| 82 } | 97 } |
| 83 | 98 |
| 84 void CardUnmaskPromptViewBridge::PerformClose() { | 99 void CardUnmaskPromptViewBridge::PerformClose() { |
| 85 constrained_window_->CloseWebContentsModalDialog(); | 100 constrained_window_->CloseWebContentsModalDialog(); |
| 86 } | 101 } |
| 87 | 102 |
| 88 } // autofill | 103 } // autofill |
| 89 | 104 |
| 90 #pragma mark CardUnmaskPromptViewCocoa | 105 #pragma mark CardUnmaskPromptViewCocoa |
| 91 | 106 |
| 92 @implementation CardUnmaskPromptViewCocoa { | 107 @implementation CardUnmaskPromptViewCocoa { |
| 93 base::scoped_nsobject<NSTextField> cvcInput_; | 108 base::scoped_nsobject<NSTextField> cvcInput_; |
| 94 base::scoped_nsobject<NSPopUpButton> monthPopup_; | 109 base::scoped_nsobject<NSPopUpButton> monthPopup_; |
| 95 base::scoped_nsobject<NSPopUpButton> yearPopup_; | 110 base::scoped_nsobject<NSPopUpButton> yearPopup_; |
| 96 base::scoped_nsobject<NSButton> verifyButton_; | 111 base::scoped_nsobject<NSButton> verifyButton_; |
| 112 base::scoped_nsobject<NSView> inputRow_; | |
| 113 base::scoped_nsobject<NSTextField> progressOverlayText_; | |
| 97 | 114 |
| 98 int monthPopupDefaultIndex_; | 115 int monthPopupDefaultIndex_; |
| 99 int yearPopupDefaultIndex_; | 116 int yearPopupDefaultIndex_; |
| 100 | 117 |
| 101 // Owns |self|. | 118 // Owns |self|. |
| 102 autofill::CardUnmaskPromptViewBridge* bridge_; | 119 autofill::CardUnmaskPromptViewBridge* bridge_; |
| 103 } | 120 } |
| 104 | 121 |
| 105 + (NSPopUpButton*)buildDatePopupWithModel:(ui::ComboboxModel&)model { | 122 + (NSPopUpButton*)buildDatePopupWithModel:(ui::ComboboxModel&)model { |
| 106 NSPopUpButton* popup = | 123 NSPopUpButton* popup = |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 134 | 151 |
| 135 - (id)initWithBridge:(autofill::CardUnmaskPromptViewBridge*)bridge { | 152 - (id)initWithBridge:(autofill::CardUnmaskPromptViewBridge*)bridge { |
| 136 DCHECK(bridge); | 153 DCHECK(bridge); |
| 137 | 154 |
| 138 if ((self = [super initWithNibName:nil bundle:nil])) | 155 if ((self = [super initWithNibName:nil bundle:nil])) |
| 139 bridge_ = bridge; | 156 bridge_ = bridge; |
| 140 | 157 |
| 141 return self; | 158 return self; |
| 142 } | 159 } |
| 143 | 160 |
| 144 - (void)setInputsEnabled:(BOOL)enabled { | 161 - (void)setProgressOverlayText:(const base::string16&)text { |
| 145 [cvcInput_ setEnabled:enabled]; | 162 if (!text.empty()) { |
| 146 [monthPopup_ setEnabled:enabled]; | 163 NSAttributedString* attributedString = |
| 147 [yearPopup_ setEnabled:enabled]; | 164 constrained_window::GetAttributedLabelString( |
| 165 SysUTF16ToNSString(text), kProgressFontStyle, NSCenterTextAlignment, | |
| 166 NSLineBreakByWordWrapping); | |
| 167 [progressOverlayText_ setAttributedStringValue:attributedString]; | |
| 168 } | |
| 169 | |
| 170 [progressOverlayText_ setHidden:text.empty()]; | |
| 171 [inputRow_ setHidden:!text.empty()]; | |
| 172 [self updateVerifyButtonEnabled]; | |
| 148 } | 173 } |
| 149 | 174 |
| 150 - (void)updateVerifyButtonEnabled { | 175 - (void)updateVerifyButtonEnabled { |
| 151 autofill::CardUnmaskPromptController* controller = bridge_->GetController(); | 176 autofill::CardUnmaskPromptController* controller = bridge_->GetController(); |
| 152 DCHECK(controller); | 177 DCHECK(controller); |
| 153 | 178 |
| 154 BOOL enable = | 179 BOOL enable = |
| 155 [cvcInput_ isEnabled] && | 180 ![inputRow_ isHidden] && |
| 156 controller->InputCvcIsValid( | 181 controller->InputCvcIsValid( |
| 157 base::SysNSStringToUTF16([cvcInput_ stringValue])) && | 182 base::SysNSStringToUTF16([cvcInput_ stringValue])) && |
| 158 (!monthPopup_ || | 183 (!monthPopup_ || |
| 159 [monthPopup_ indexOfSelectedItem] != monthPopupDefaultIndex_) && | 184 [monthPopup_ indexOfSelectedItem] != monthPopupDefaultIndex_) && |
| 160 (!yearPopup_ || | 185 (!yearPopup_ || |
| 161 [yearPopup_ indexOfSelectedItem] != yearPopupDefaultIndex_); | 186 [yearPopup_ indexOfSelectedItem] != yearPopupDefaultIndex_); |
| 162 | 187 |
| 163 [verifyButton_ setEnabled:enable]; | 188 [verifyButton_ setEnabled:enable]; |
| 164 } | 189 } |
| 165 | 190 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 191 DCHECK(controller); | 216 DCHECK(controller); |
| 192 | 217 |
| 193 base::scoped_nsobject<NSBox> mainView( | 218 base::scoped_nsobject<NSBox> mainView( |
| 194 [[NSBox alloc] initWithFrame:NSZeroRect]); | 219 [[NSBox alloc] initWithFrame:NSZeroRect]); |
| 195 [mainView setBoxType:NSBoxCustom]; | 220 [mainView setBoxType:NSBoxCustom]; |
| 196 [mainView setBorderType:NSNoBorder]; | 221 [mainView setBorderType:NSNoBorder]; |
| 197 [mainView setTitlePosition:NSNoTitle]; | 222 [mainView setTitlePosition:NSNoTitle]; |
| 198 [mainView | 223 [mainView |
| 199 setContentViewMargins:NSMakeSize(chrome_style::kHorizontalPadding, 0)]; | 224 setContentViewMargins:NSMakeSize(chrome_style::kHorizontalPadding, 0)]; |
| 200 | 225 |
| 201 base::scoped_nsobject<NSView> inputRowView( | 226 inputRow_.reset([[NSView alloc] initWithFrame:NSZeroRect]); |
| 202 [[NSView alloc] initWithFrame:NSZeroRect]); | 227 [mainView addSubview:inputRow_]; |
| 203 [mainView addSubview:inputRowView]; | |
| 204 | 228 |
| 205 // Title label. | 229 // Title label. |
| 206 NSTextField* title = constrained_window::CreateLabel(); | 230 NSTextField* title = constrained_window::CreateLabel(); |
| 207 NSAttributedString* titleString = | 231 NSAttributedString* titleString = |
| 208 constrained_window::GetAttributedLabelString( | 232 constrained_window::GetAttributedLabelString( |
| 209 SysUTF16ToNSString(controller->GetWindowTitle()), | 233 SysUTF16ToNSString(controller->GetWindowTitle()), |
| 210 chrome_style::kTitleFontStyle, NSNaturalTextAlignment, | 234 chrome_style::kTitleFontStyle, NSNaturalTextAlignment, |
| 211 NSLineBreakByWordWrapping); | 235 NSLineBreakByWordWrapping); |
| 212 [title setAttributedStringValue:titleString]; | 236 [title setAttributedStringValue:titleString]; |
| 213 [title sizeToFit]; | 237 [title sizeToFit]; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 [expirationView addSubview:yearPopup_]; | 271 [expirationView addSubview:yearPopup_]; |
| 248 | 272 |
| 249 // Layout month and year within expirationView. | 273 // Layout month and year within expirationView. |
| 250 [yearPopup_ | 274 [yearPopup_ |
| 251 setFrameOrigin:NSMakePoint(NSMaxX([monthPopup_ frame]) + kButtonGap, | 275 setFrameOrigin:NSMakePoint(NSMaxX([monthPopup_ frame]) + kButtonGap, |
| 252 0)]; | 276 0)]; |
| 253 NSRect expirationFrame = | 277 NSRect expirationFrame = |
| 254 NSUnionRect([monthPopup_ frame], [yearPopup_ frame]); | 278 NSUnionRect([monthPopup_ frame], [yearPopup_ frame]); |
| 255 expirationFrame.size.width += kButtonGap; | 279 expirationFrame.size.width += kButtonGap; |
| 256 [expirationView setFrame:expirationFrame]; | 280 [expirationView setFrame:expirationFrame]; |
| 257 [inputRowView addSubview:expirationView]; | 281 [inputRow_ addSubview:expirationView]; |
| 258 } | 282 } |
| 259 | 283 |
| 260 // CVC text input. | 284 // CVC text input. |
| 261 cvcInput_.reset([[NSTextField alloc] initWithFrame:NSZeroRect]); | 285 cvcInput_.reset([[NSTextField alloc] initWithFrame:NSZeroRect]); |
| 262 [[cvcInput_ cell] | 286 [[cvcInput_ cell] |
| 263 setPlaceholderString:l10n_util::GetNSString( | 287 setPlaceholderString:l10n_util::GetNSString( |
| 264 IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC)]; | 288 IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC)]; |
| 265 [[cvcInput_ cell] setScrollable:YES]; | 289 [[cvcInput_ cell] setScrollable:YES]; |
| 266 [cvcInput_ setDelegate:self]; | 290 [cvcInput_ setDelegate:self]; |
| 267 [cvcInput_ sizeToFit]; | 291 [cvcInput_ sizeToFit]; |
| 268 [cvcInput_ setFrame:NSMakeRect(NSMaxX([expirationView frame]), 0, | 292 [cvcInput_ setFrame:NSMakeRect(NSMaxX([expirationView frame]), 0, |
| 269 kCvcInputWidth, NSHeight([cvcInput_ frame]))]; | 293 kCvcInputWidth, NSHeight([cvcInput_ frame]))]; |
| 270 [inputRowView addSubview:cvcInput_]; | 294 [inputRow_ addSubview:cvcInput_]; |
| 271 | 295 |
| 272 // CVC image. | 296 // CVC image. |
| 273 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 297 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 274 NSImage* cvcImage = | 298 NSImage* cvcImage = |
| 275 rb.GetNativeImageNamed(controller->GetCvcImageRid()).ToNSImage(); | 299 rb.GetNativeImageNamed(controller->GetCvcImageRid()).ToNSImage(); |
| 276 base::scoped_nsobject<NSImageView> cvcImageView( | 300 base::scoped_nsobject<NSImageView> cvcImageView( |
| 277 [[NSImageView alloc] initWithFrame:NSZeroRect]); | 301 [[NSImageView alloc] initWithFrame:NSZeroRect]); |
| 278 [cvcImageView setImage:cvcImage]; | 302 [cvcImageView setImage:cvcImage]; |
| 279 [cvcImageView setFrameSize:[cvcImage size]]; | 303 [cvcImageView setFrameSize:[cvcImage size]]; |
| 280 [cvcImageView | 304 [cvcImageView |
| 281 setFrameOrigin:NSMakePoint(NSMaxX([cvcInput_ frame]) + kButtonGap, 0)]; | 305 setFrameOrigin:NSMakePoint(NSMaxX([cvcInput_ frame]) + kButtonGap, 0)]; |
| 282 [inputRowView addSubview:cvcImageView]; | 306 [inputRow_ addSubview:cvcImageView]; |
| 283 | 307 |
| 284 // Cancel button. | 308 // Cancel button. |
| 285 base::scoped_nsobject<NSButton> cancelButton( | 309 base::scoped_nsobject<NSButton> cancelButton( |
| 286 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); | 310 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); |
| 287 [cancelButton setTitle:l10n_util::GetNSStringWithFixup(IDS_CANCEL)]; | 311 [cancelButton setTitle:l10n_util::GetNSStringWithFixup(IDS_CANCEL)]; |
| 288 [cancelButton setKeyEquivalent:kKeyEquivalentEscape]; | 312 [cancelButton setKeyEquivalent:kKeyEquivalentEscape]; |
| 289 [cancelButton setTarget:self]; | 313 [cancelButton setTarget:self]; |
| 290 [cancelButton setAction:@selector(onCancel:)]; | 314 [cancelButton setAction:@selector(onCancel:)]; |
| 291 [cancelButton sizeToFit]; | 315 [cancelButton sizeToFit]; |
| 292 [mainView addSubview:cancelButton]; | 316 [mainView addSubview:cancelButton]; |
| 293 | 317 |
| 294 // Verify button. | 318 // Verify button. |
| 295 verifyButton_.reset( | 319 verifyButton_.reset( |
| 296 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); | 320 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); |
| 297 // TODO(bondd): use l10n string. | 321 // TODO(bondd): use l10n string. |
| 298 [verifyButton_ setTitle:@"Verify"]; | 322 [verifyButton_ setTitle:@"Verify"]; |
| 299 [verifyButton_ setKeyEquivalent:kKeyEquivalentReturn]; | 323 [verifyButton_ setKeyEquivalent:kKeyEquivalentReturn]; |
| 300 [verifyButton_ setTarget:self]; | 324 [verifyButton_ setTarget:self]; |
| 301 [verifyButton_ setAction:@selector(onVerify:)]; | 325 [verifyButton_ setAction:@selector(onVerify:)]; |
| 302 [verifyButton_ sizeToFit]; | 326 [verifyButton_ sizeToFit]; |
| 303 [self updateVerifyButtonEnabled]; | 327 [self updateVerifyButtonEnabled]; |
| 304 [mainView addSubview:verifyButton_]; | 328 [mainView addSubview:verifyButton_]; |
| 305 | 329 |
| 306 // Layout inputRowView. | 330 // Layout inputRow_. |
| 307 [CardUnmaskPromptViewCocoa sizeToFitView:inputRowView]; | 331 [CardUnmaskPromptViewCocoa sizeToFitView:inputRow_]; |
| 308 [CardUnmaskPromptViewCocoa verticallyCenterSubviewsInView:inputRowView]; | 332 [CardUnmaskPromptViewCocoa verticallyCenterSubviewsInView:inputRow_]; |
| 309 | 333 |
| 310 // Calculate dialog content width. | 334 // Calculate dialog content width. |
| 311 CGFloat contentWidth = | 335 CGFloat contentWidth = |
| 312 std::max(NSWidth([title frame]), NSWidth([inputRowView frame])); | 336 std::max(NSWidth([title frame]), NSWidth([inputRow_ frame])); |
| 313 contentWidth = std::max(contentWidth, kDialogContentMinWidth); | 337 contentWidth = std::max(contentWidth, kDialogContentMinWidth); |
| 314 | 338 |
| 315 // Layout mainView contents, starting at the bottom and moving up. | 339 // Layout mainView contents, starting at the bottom and moving up. |
| 316 | 340 |
| 317 // Verify and Cancel buttons. | 341 // Verify and Cancel buttons. |
| 318 [verifyButton_ | 342 [verifyButton_ |
| 319 setFrameOrigin:NSMakePoint(contentWidth - NSWidth([verifyButton_ frame]), | 343 setFrameOrigin:NSMakePoint(contentWidth - NSWidth([verifyButton_ frame]), |
| 320 chrome_style::kClientBottomPadding)]; | 344 chrome_style::kClientBottomPadding)]; |
| 321 | 345 |
| 322 [cancelButton | 346 [cancelButton |
| 323 setFrameOrigin:NSMakePoint(NSMinX([verifyButton_ frame]) - kButtonGap - | 347 setFrameOrigin:NSMakePoint(NSMinX([verifyButton_ frame]) - kButtonGap - |
| 324 NSWidth([cancelButton frame]), | 348 NSWidth([cancelButton frame]), |
| 325 NSMinY([verifyButton_ frame]))]; | 349 NSMinY([verifyButton_ frame]))]; |
| 326 | 350 |
| 327 // Input row. | 351 // Input row. |
| 328 [inputRowView setFrameOrigin:NSMakePoint(0, NSMaxY([cancelButton frame]) + | 352 [inputRow_ setFrameOrigin:NSMakePoint(0, NSMaxY([cancelButton frame]) + |
| 329 chrome_style::kRowPadding)]; | 353 chrome_style::kRowPadding)]; |
| 330 | 354 |
| 331 // Instruction label. | 355 // Instruction label. |
| 332 [instructions setFrameOrigin:NSMakePoint(0, NSMaxY([inputRowView frame]) + | 356 [instructions setFrameOrigin:NSMakePoint(0, NSMaxY([inputRow_ frame]) + |
| 333 chrome_style::kRowPadding)]; | 357 chrome_style::kRowPadding)]; |
| 334 NSSize instructionsSize = [[instructions cell] | 358 NSSize instructionsSize = [[instructions cell] |
| 335 cellSizeForBounds:NSMakeRect(0, 0, contentWidth, CGFLOAT_MAX)]; | 359 cellSizeForBounds:NSMakeRect(0, 0, contentWidth, CGFLOAT_MAX)]; |
| 336 [instructions setFrameSize:instructionsSize]; | 360 [instructions setFrameSize:instructionsSize]; |
| 337 | 361 |
| 338 // Title label. | 362 // Title label. |
| 339 [title setFrameOrigin:NSMakePoint(0, NSMaxY([instructions frame]) + | 363 [title setFrameOrigin:NSMakePoint(0, NSMaxY([instructions frame]) + |
| 340 chrome_style::kRowPadding)]; | 364 chrome_style::kRowPadding)]; |
| 341 | 365 |
| 342 // Dialog size. | 366 // Dialog size. |
| 343 [mainView | 367 [mainView |
| 344 setFrameSize:NSMakeSize( | 368 setFrameSize:NSMakeSize( |
| 345 contentWidth + [mainView contentViewMargins].width * 2.0, | 369 contentWidth + [mainView contentViewMargins].width * 2.0, |
| 346 NSMaxY([title frame]) + chrome_style::kTitleTopPadding)]; | 370 NSMaxY([title frame]) + chrome_style::kTitleTopPadding)]; |
| 347 | 371 |
| 372 // Add progress overlay. | |
| 373 progressOverlayText_.reset([constrained_window::CreateLabel() retain]); | |
| 374 const gfx::Font& progressFont = | |
| 375 ui::ResourceBundle::GetSharedInstance().GetFont(kProgressFontStyle); | |
| 376 base::scoped_nsobject<NSLayoutManager> layoutManager( | |
|
groby-ooo-7-16
2015/03/19 05:15:38
Whoa, that's a lot of code :)
Why not progressFon
bondd
2015/03/19 21:43:37
Done.
| |
| 377 [[NSLayoutManager alloc] init]); | |
| 378 CGFloat progressHeight = | |
| 379 [layoutManager defaultLineHeightForFont:progressFont.GetNativeFont()]; | |
| 380 [progressOverlayText_ setFrame:NSMakeRect(0, ceil(NSMidY([inputRow_ frame]) - | |
|
groby-ooo-7-16
2015/03/19 05:15:38
That's an interesting calculation... I'm not sure
bondd
2015/03/19 21:43:37
Done. Answered in comment.
Is there an easier way
| |
| 381 progressHeight * 0.5), | |
| 382 contentWidth, progressHeight)]; | |
| 383 [progressOverlayText_ setHidden:YES]; | |
| 384 [mainView addSubview:progressOverlayText_]; | |
| 385 | |
| 348 [self setView:mainView]; | 386 [self setView:mainView]; |
| 349 } | 387 } |
| 350 | 388 |
| 351 @end | 389 @end |
| OLD | NEW |