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" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 8 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
| 9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
| 10 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" | 10 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 [self expirationDateIsValid]; | 255 [self expirationDateIsValid]; |
| 256 | 256 |
| 257 [verifyButton_ setEnabled:enable]; | 257 [verifyButton_ setEnabled:enable]; |
| 258 } | 258 } |
| 259 | 259 |
| 260 - (void)onVerify:(id)sender { | 260 - (void)onVerify:(id)sender { |
| 261 bridge_->GetController()->OnUnmaskResponse( | 261 bridge_->GetController()->OnUnmaskResponse( |
| 262 base::SysNSStringToUTF16([cvcInput_ stringValue]), | 262 base::SysNSStringToUTF16([cvcInput_ stringValue]), |
| 263 base::SysNSStringToUTF16([monthPopup_ titleOfSelectedItem]), | 263 base::SysNSStringToUTF16([monthPopup_ titleOfSelectedItem]), |
| 264 base::SysNSStringToUTF16([yearPopup_ titleOfSelectedItem]), | 264 base::SysNSStringToUTF16([yearPopup_ titleOfSelectedItem]), |
| 265 [storageCheckbox_ state] == NSOnState); | 265 [storageCheckbox_ state] == NSOnState); |
|
bondd
2015/03/27 00:20:52
storageCheckbox_ can be nil. Apple docs indicate t
groby-ooo-7-16
2015/03/27 00:53:17
sgtm
| |
| 266 } | 266 } |
| 267 | 267 |
| 268 - (void)onCancel:(id)sender { | 268 - (void)onCancel:(id)sender { |
| 269 bridge_->PerformClose(); | 269 bridge_->PerformClose(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 - (BOOL)expirationDateIsValid { | 272 - (BOOL)expirationDateIsValid { |
| 273 if (!bridge_->GetController()->ShouldRequestExpirationDate()) | 273 if (!bridge_->GetController()->ShouldRequestExpirationDate()) |
| 274 return true; | 274 return true; |
| 275 | 275 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP))]; | 323 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP))]; |
| 324 [view addSubview:[storageTooltip_ view]]; | 324 [view addSubview:[storageTooltip_ view]]; |
| 325 [[storageTooltip_ view] setFrameOrigin: | 325 [[storageTooltip_ view] setFrameOrigin: |
| 326 NSMakePoint(NSMaxX([storageCheckbox_ frame]) + kButtonGap, 0)]; | 326 NSMakePoint(NSMaxX([storageCheckbox_ frame]) + kButtonGap, 0)]; |
| 327 | 327 |
| 328 [CardUnmaskPromptViewCocoa sizeToFitView:view]; | 328 [CardUnmaskPromptViewCocoa sizeToFitView:view]; |
| 329 [CardUnmaskPromptViewCocoa verticallyCenterSubviewsInView:view]; | 329 [CardUnmaskPromptViewCocoa verticallyCenterSubviewsInView:view]; |
| 330 return view; | 330 return view; |
| 331 } | 331 } |
| 332 | 332 |
| 333 // +------------------------------------------------+ | 333 // +---------------------------------------------------------------------------+ |
| 334 // | titleLabel_ (Single line.) | | 334 // | titleLabel_ (Single line.) | |
| 335 // |------------------------------------------------| | 335 // |---------------------------------------------------------------------------| |
| 336 // | permanentErrorBox_ (Multiline, may be hidden.) | | 336 // | permanentErrorBox_ (Multiline, may be hidden.) | |
| 337 // |------------------------------------------------| | 337 // |---------------------------------------------------------------------------| |
| 338 // | instructionsLabel_ (Multiline.) | | 338 // | instructionsLabel_ (Multiline.) | |
| 339 // |------------------------------------------------| | 339 // |---------------------------------------------------------------------------| |
| 340 // | monthPopup_ yearPopup_ cvcInput_ cvcImage | | 340 // | monthPopup_ yearPopup_ cvcInput_ cvcImage | |
| 341 // | (All enclosed in inputRowView_. Month and | | 341 // | (All enclosed in inputRowView_. Month and year may be hidden.) | |
| 342 // | year may be hidden.) | | 342 // |---------------------------------------------------------------------------| |
| 343 // |------------------------------------------------| | 343 // | errorLabel_ (Multiline. Always takes up space for one line even if | |
| 344 // | errorLabel_ (Multiline. Always takes up space | | 344 // | empty.) | |
| 345 // | for one line even if empty.) | | 345 // |---------------------------------------------------------------------------| |
| 346 // |------------------------------------------------| | 346 // | [Cancel] [Verify] | |
| 347 // | [Cancel] [Verify] | | 347 // |---------------------------------------------------------------------------| |
| 348 // |------------------------------------------------| | 348 // | storageCheckbox_ storageTooltip_ | |
| 349 // | storageCheckbox_ storageTooltip_ | | 349 // | (Both enclosed in storageView_. May be hidden but still taking up | |
| 350 // | (Both enclosed in storageView_.) | | 350 // | layout space. Will all be nil if !CanStoreLocally()). | |
| 351 // +------------------------------------------------+ | 351 // +---------------------------------------------------------------------------+ |
| 352 - (void)performLayoutAndDisplay:(BOOL)display { | 352 - (void)performLayoutAndDisplay:(BOOL)display { |
| 353 // Calculate dialog content width. | 353 // Calculate dialog content width. |
| 354 CGFloat contentWidth = | 354 CGFloat contentWidth = |
| 355 std::max(NSWidth([titleLabel_ frame]), NSWidth([inputRowView_ frame])); | 355 std::max(NSWidth([titleLabel_ frame]), NSWidth([inputRowView_ frame])); |
| 356 contentWidth = std::max(contentWidth, NSWidth([storageView_ frame])); | 356 contentWidth = std::max(contentWidth, NSWidth([storageView_ frame])); |
| 357 contentWidth = std::max(contentWidth, kDialogContentMinWidth); | 357 contentWidth = std::max(contentWidth, kDialogContentMinWidth); |
| 358 | 358 |
| 359 [storageView_ | 359 [storageView_ |
| 360 setFrameOrigin:NSMakePoint(0, chrome_style::kClientBottomPadding)]; | 360 setFrameOrigin:NSMakePoint(0, chrome_style::kClientBottomPadding)]; |
| 361 | 361 |
| 362 CGFloat verifyMinY = | |
| 363 storageView_ ? NSMaxY([storageView_ frame]) + chrome_style::kRowPadding | |
| 364 : chrome_style::kClientBottomPadding; | |
| 362 [verifyButton_ setFrameOrigin: | 365 [verifyButton_ setFrameOrigin: |
| 363 NSMakePoint(contentWidth - NSWidth([verifyButton_ frame]), | 366 NSMakePoint(contentWidth - NSWidth([verifyButton_ frame]), verifyMinY)]; |
| 364 NSMaxY([storageView_ frame]) + chrome_style::kRowPadding)]; | |
| 365 | 367 |
| 366 [cancelButton_ | 368 [cancelButton_ |
| 367 setFrameOrigin:NSMakePoint(NSMinX([verifyButton_ frame]) - kButtonGap - | 369 setFrameOrigin:NSMakePoint(NSMinX([verifyButton_ frame]) - kButtonGap - |
| 368 NSWidth([cancelButton_ frame]), | 370 NSWidth([cancelButton_ frame]), |
| 369 NSMinY([verifyButton_ frame]))]; | 371 NSMinY([verifyButton_ frame]))]; |
| 370 | 372 |
| 371 [errorLabel_ setFrame:NSMakeRect(0, NSMaxY([cancelButton_ frame]) + | 373 [errorLabel_ setFrame:NSMakeRect(0, NSMaxY([cancelButton_ frame]) + |
| 372 chrome_style::kRowPadding, | 374 chrome_style::kRowPadding, |
| 373 contentWidth, 0)]; | 375 contentWidth, 0)]; |
| 374 cocoa_l10n_util::WrapOrSizeToFit(errorLabel_); | 376 cocoa_l10n_util::WrapOrSizeToFit(errorLabel_); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 [[NSBox alloc] initWithFrame:NSZeroRect]); | 423 [[NSBox alloc] initWithFrame:NSZeroRect]); |
| 422 [mainView setBoxType:NSBoxCustom]; | 424 [mainView setBoxType:NSBoxCustom]; |
| 423 [mainView setBorderType:NSNoBorder]; | 425 [mainView setBorderType:NSNoBorder]; |
| 424 [mainView setTitlePosition:NSNoTitle]; | 426 [mainView setTitlePosition:NSNoTitle]; |
| 425 [mainView | 427 [mainView |
| 426 setContentViewMargins:NSMakeSize(chrome_style::kHorizontalPadding, 0)]; | 428 setContentViewMargins:NSMakeSize(chrome_style::kHorizontalPadding, 0)]; |
| 427 | 429 |
| 428 inputRowView_.reset([[NSView alloc] initWithFrame:NSZeroRect]); | 430 inputRowView_.reset([[NSView alloc] initWithFrame:NSZeroRect]); |
| 429 [mainView addSubview:inputRowView_]; | 431 [mainView addSubview:inputRowView_]; |
| 430 | 432 |
| 431 storageView_ = [self createStorageViewWithController:controller]; | 433 if (controller->CanStoreLocally()) { |
|
bondd
2015/03/27 00:20:52
CanStoreLocally() check can either go here, or at
groby-ooo-7-16
2015/03/27 00:53:17
sgtm
| |
| 432 [mainView addSubview:storageView_]; | 434 storageView_ = [self createStorageViewWithController:controller]; |
|
groby-ooo-7-16
2015/03/27 00:53:17
storageView_.reset()?
bondd
2015/03/27 01:09:38
Sorry, could you please clarify what you mean here
groby-ooo-7-16
2015/03/27 01:36:07
I assumed createStorage... returns a pointer, and
| |
| 435 [mainView addSubview:storageView_]; | |
| 436 } | |
| 433 | 437 |
| 434 progressOverlayLabel_.reset([constrained_window::CreateLabel() retain]); | 438 progressOverlayLabel_.reset([constrained_window::CreateLabel() retain]); |
| 435 [progressOverlayLabel_ setHidden:YES]; | 439 [progressOverlayLabel_ setHidden:YES]; |
| 436 [mainView addSubview:progressOverlayLabel_]; | 440 [mainView addSubview:progressOverlayLabel_]; |
| 437 | 441 |
| 438 // Add title label. | 442 // Add title label. |
| 439 titleLabel_.reset([constrained_window::CreateLabel() retain]); | 443 titleLabel_.reset([constrained_window::CreateLabel() retain]); |
| 440 NSAttributedString* titleString = | 444 NSAttributedString* titleString = |
| 441 constrained_window::GetAttributedLabelString( | 445 constrained_window::GetAttributedLabelString( |
| 442 SysUTF16ToNSString(controller->GetWindowTitle()), | 446 SysUTF16ToNSString(controller->GetWindowTitle()), |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 | 548 |
| 545 // Layout inputRowView_. | 549 // Layout inputRowView_. |
| 546 [CardUnmaskPromptViewCocoa sizeToFitView:inputRowView_]; | 550 [CardUnmaskPromptViewCocoa sizeToFitView:inputRowView_]; |
| 547 [CardUnmaskPromptViewCocoa verticallyCenterSubviewsInView:inputRowView_]; | 551 [CardUnmaskPromptViewCocoa verticallyCenterSubviewsInView:inputRowView_]; |
| 548 | 552 |
| 549 [self setView:mainView]; | 553 [self setView:mainView]; |
| 550 [self performLayoutAndDisplay:NO]; | 554 [self performLayoutAndDisplay:NO]; |
| 551 } | 555 } |
| 552 | 556 |
| 553 @end | 557 @end |
| OLD | NEW |