| 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/chrome_style.h" | 10 #include "chrome/browser/ui/chrome_style.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 [inputRowView_ addSubview:newCardButton_]; | 297 [inputRowView_ addSubview:newCardButton_]; |
| 298 } | 298 } |
| 299 | 299 |
| 300 [self performLayoutAndDisplay:YES]; | 300 [self performLayoutAndDisplay:YES]; |
| 301 } | 301 } |
| 302 | 302 |
| 303 - (void)setPermanentErrorMessage:(const base::string16&)text { | 303 - (void)setPermanentErrorMessage:(const base::string16&)text { |
| 304 if (!text.empty()) { | 304 if (!text.empty()) { |
| 305 if (!permanentErrorBox_) { | 305 if (!permanentErrorBox_) { |
| 306 permanentErrorBox_ = [CardUnmaskPromptViewCocoa createPlainBox]; | 306 permanentErrorBox_ = [CardUnmaskPromptViewCocoa createPlainBox]; |
| 307 [permanentErrorBox_ setFillColor:gfx::SkColorToCalibratedNSColor( | 307 [permanentErrorBox_ setFillColor:skia::SkColorToCalibratedNSColor( |
| 308 autofill::kWarningColor)]; | 308 autofill::kWarningColor)]; |
| 309 [permanentErrorBox_ | 309 [permanentErrorBox_ |
| 310 setContentViewMargins:NSMakeSize(kPermanentErrorHorizontalPadding, | 310 setContentViewMargins:NSMakeSize(kPermanentErrorHorizontalPadding, |
| 311 kPermanentErrorVerticalPadding)]; | 311 kPermanentErrorVerticalPadding)]; |
| 312 | 312 |
| 313 permanentErrorLabel_.reset([constrained_window::CreateLabel() retain]); | 313 permanentErrorLabel_.reset([constrained_window::CreateLabel() retain]); |
| 314 [permanentErrorLabel_ setAutoresizingMask:NSViewWidthSizable]; | 314 [permanentErrorLabel_ setAutoresizingMask:NSViewWidthSizable]; |
| 315 [permanentErrorLabel_ setTextColor:gfx::SkColorToCalibratedNSColor( | 315 [permanentErrorLabel_ setTextColor:skia::SkColorToCalibratedNSColor( |
| 316 kPermanentErrorTextColor)]; | 316 kPermanentErrorTextColor)]; |
| 317 | 317 |
| 318 [permanentErrorBox_ addSubview:permanentErrorLabel_]; | 318 [permanentErrorBox_ addSubview:permanentErrorLabel_]; |
| 319 [[self view] addSubview:permanentErrorBox_]; | 319 [[self view] addSubview:permanentErrorBox_]; |
| 320 } | 320 } |
| 321 | 321 |
| 322 NSAttributedString* attributedString = | 322 NSAttributedString* attributedString = |
| 323 constrained_window::GetAttributedLabelString( | 323 constrained_window::GetAttributedLabelString( |
| 324 SysUTF16ToNSString(text), chrome_style::kTextFontStyle, | 324 SysUTF16ToNSString(text), chrome_style::kTextFontStyle, |
| 325 NSNaturalTextAlignment, NSLineBreakByWordWrapping); | 325 NSNaturalTextAlignment, NSLineBreakByWordWrapping); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 } | 475 } |
| 476 | 476 |
| 477 - (void)createStorageViewWithController: | 477 - (void)createStorageViewWithController: |
| 478 (autofill::CardUnmaskPromptController*)controller { | 478 (autofill::CardUnmaskPromptController*)controller { |
| 479 DCHECK(!storageView_); | 479 DCHECK(!storageView_); |
| 480 storageView_.reset([[NSView alloc] initWithFrame:NSZeroRect]); | 480 storageView_.reset([[NSView alloc] initWithFrame:NSZeroRect]); |
| 481 [storageView_ setAutoresizingMask:NSViewWidthSizable]; | 481 [storageView_ setAutoresizingMask:NSViewWidthSizable]; |
| 482 | 482 |
| 483 base::scoped_nsobject<NSBox> box = [CardUnmaskPromptViewCocoa createPlainBox]; | 483 base::scoped_nsobject<NSBox> box = [CardUnmaskPromptViewCocoa createPlainBox]; |
| 484 [box setAutoresizingMask:NSViewWidthSizable]; | 484 [box setAutoresizingMask:NSViewWidthSizable]; |
| 485 [box setFillColor:gfx::SkColorToCalibratedNSColor(kShadingColor)]; | 485 [box setFillColor:skia::SkColorToCalibratedNSColor(kShadingColor)]; |
| 486 [box setContentViewMargins:NSMakeSize(chrome_style::kHorizontalPadding, | 486 [box setContentViewMargins:NSMakeSize(chrome_style::kHorizontalPadding, |
| 487 chrome_style::kClientBottomPadding)]; | 487 chrome_style::kClientBottomPadding)]; |
| 488 [storageView_ addSubview:box]; | 488 [storageView_ addSubview:box]; |
| 489 | 489 |
| 490 // Add "Store card on this device" checkbox. | 490 // Add "Store card on this device" checkbox. |
| 491 storageCheckbox_.reset([[NSButton alloc] initWithFrame:NSZeroRect]); | 491 storageCheckbox_.reset([[NSButton alloc] initWithFrame:NSZeroRect]); |
| 492 [storageCheckbox_ setButtonType:NSSwitchButton]; | 492 [storageCheckbox_ setButtonType:NSSwitchButton]; |
| 493 [storageCheckbox_ | 493 [storageCheckbox_ |
| 494 setTitle:base::SysUTF16ToNSString(l10n_util::GetStringUTF16( | 494 setTitle:base::SysUTF16ToNSString(l10n_util::GetStringUTF16( |
| 495 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX))]; | 495 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX))]; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 509 setMessage:base::SysUTF16ToNSString(l10n_util::GetStringUTF16( | 509 setMessage:base::SysUTF16ToNSString(l10n_util::GetStringUTF16( |
| 510 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP))]; | 510 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP))]; |
| 511 [box addSubview:[storageTooltip_ view]]; | 511 [box addSubview:[storageTooltip_ view]]; |
| 512 [[storageTooltip_ view] setFrameOrigin: | 512 [[storageTooltip_ view] setFrameOrigin: |
| 513 NSMakePoint(NSMaxX([storageCheckbox_ frame]) + kButtonGap, 0)]; | 513 NSMakePoint(NSMaxX([storageCheckbox_ frame]) + kButtonGap, 0)]; |
| 514 | 514 |
| 515 // Add horizontal separator. | 515 // Add horizontal separator. |
| 516 base::scoped_nsobject<NSBox> separator = | 516 base::scoped_nsobject<NSBox> separator = |
| 517 [CardUnmaskPromptViewCocoa createPlainBox]; | 517 [CardUnmaskPromptViewCocoa createPlainBox]; |
| 518 [separator setAutoresizingMask:NSViewWidthSizable]; | 518 [separator setAutoresizingMask:NSViewWidthSizable]; |
| 519 [separator setFillColor:gfx::SkColorToCalibratedNSColor(kSubtleBorderColor)]; | 519 [separator setFillColor:skia::SkColorToCalibratedNSColor(kSubtleBorderColor)]; |
| 520 [storageView_ addSubview:separator]; | 520 [storageView_ addSubview:separator]; |
| 521 | 521 |
| 522 [box sizeToFit]; | 522 [box sizeToFit]; |
| 523 [separator setFrame:NSMakeRect(0, NSMaxY([box frame]), NSWidth([box frame]), | 523 [separator setFrame:NSMakeRect(0, NSMaxY([box frame]), NSWidth([box frame]), |
| 524 kSeparatorHeight)]; | 524 kSeparatorHeight)]; |
| 525 [CardUnmaskPromptViewCocoa sizeToFitView:storageView_]; | 525 [CardUnmaskPromptViewCocoa sizeToFitView:storageView_]; |
| 526 } | 526 } |
| 527 | 527 |
| 528 // +---------------------------------------------------------------------------+ | 528 // +---------------------------------------------------------------------------+ |
| 529 // | titleLabel_ (Single line.) | | 529 // | titleLabel_ (Single line.) | |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 [self createStorageViewWithController:controller]; | 652 [self createStorageViewWithController:controller]; |
| 653 [mainView addSubview:storageView_]; | 653 [mainView addSubview:storageView_]; |
| 654 } | 654 } |
| 655 | 655 |
| 656 // Add progress overlay. | 656 // Add progress overlay. |
| 657 progressOverlayView_.reset([[NSView alloc] initWithFrame:NSZeroRect]); | 657 progressOverlayView_.reset([[NSView alloc] initWithFrame:NSZeroRect]); |
| 658 [progressOverlayView_ setHidden:YES]; | 658 [progressOverlayView_ setHidden:YES]; |
| 659 [mainView addSubview:progressOverlayView_]; | 659 [mainView addSubview:progressOverlayView_]; |
| 660 | 660 |
| 661 progressOverlayLabel_.reset([constrained_window::CreateLabel() retain]); | 661 progressOverlayLabel_.reset([constrained_window::CreateLabel() retain]); |
| 662 NSColor* throbberBlueColor = gfx::SkColorToCalibratedNSColor( | 662 NSColor* throbberBlueColor = skia::SkColorToCalibratedNSColor( |
| 663 ui::NativeThemeMac::instance()->GetSystemColor( | 663 ui::NativeThemeMac::instance()->GetSystemColor( |
| 664 ui::NativeTheme::kColorId_ThrobberSpinningColor)); | 664 ui::NativeTheme::kColorId_ThrobberSpinningColor)); |
| 665 [progressOverlayLabel_ setTextColor:throbberBlueColor]; | 665 [progressOverlayLabel_ setTextColor:throbberBlueColor]; |
| 666 [progressOverlayView_ addSubview:progressOverlayLabel_]; | 666 [progressOverlayView_ addSubview:progressOverlayLabel_]; |
| 667 | 667 |
| 668 progressOverlaySpinner_.reset([[SpinnerView alloc] | 668 progressOverlaySpinner_.reset([[SpinnerView alloc] |
| 669 initWithFrame:NSMakeRect(0, 0, kSpinnerSize, kSpinnerSize)]); | 669 initWithFrame:NSMakeRect(0, 0, kSpinnerSize, kSpinnerSize)]); |
| 670 [progressOverlayView_ addSubview:progressOverlaySpinner_]; | 670 [progressOverlayView_ addSubview:progressOverlaySpinner_]; |
| 671 | 671 |
| 672 // Add title label. | 672 // Add title label. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 NSImage* cvcImage = | 706 NSImage* cvcImage = |
| 707 rb.GetNativeImageNamed(controller->GetCvcImageRid()).ToNSImage(); | 707 rb.GetNativeImageNamed(controller->GetCvcImageRid()).ToNSImage(); |
| 708 cvcImageView_.reset([[NSImageView alloc] initWithFrame:NSZeroRect]); | 708 cvcImageView_.reset([[NSImageView alloc] initWithFrame:NSZeroRect]); |
| 709 [cvcImageView_ setImage:cvcImage]; | 709 [cvcImageView_ setImage:cvcImage]; |
| 710 [cvcImageView_ setFrameSize:[cvcImage size]]; | 710 [cvcImageView_ setFrameSize:[cvcImage size]]; |
| 711 [inputRowView_ addSubview:cvcImageView_]; | 711 [inputRowView_ addSubview:cvcImageView_]; |
| 712 | 712 |
| 713 // Add error message label. | 713 // Add error message label. |
| 714 errorLabel_.reset([constrained_window::CreateLabel() retain]); | 714 errorLabel_.reset([constrained_window::CreateLabel() retain]); |
| 715 [errorLabel_ | 715 [errorLabel_ |
| 716 setTextColor:gfx::SkColorToCalibratedNSColor(autofill::kWarningColor)]; | 716 setTextColor:skia::SkColorToCalibratedNSColor(autofill::kWarningColor)]; |
| 717 [mainView addSubview:errorLabel_]; | 717 [mainView addSubview:errorLabel_]; |
| 718 | 718 |
| 719 // Add cancel button. | 719 // Add cancel button. |
| 720 cancelButton_.reset( | 720 cancelButton_.reset( |
| 721 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); | 721 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); |
| 722 [cancelButton_ setTitle:l10n_util::GetNSStringWithFixup(IDS_CANCEL)]; | 722 [cancelButton_ setTitle:l10n_util::GetNSStringWithFixup(IDS_CANCEL)]; |
| 723 [cancelButton_ setKeyEquivalent:kKeyEquivalentEscape]; | 723 [cancelButton_ setKeyEquivalent:kKeyEquivalentEscape]; |
| 724 [cancelButton_ setTarget:self]; | 724 [cancelButton_ setTarget:self]; |
| 725 [cancelButton_ setAction:@selector(onCancel:)]; | 725 [cancelButton_ setAction:@selector(onCancel:)]; |
| 726 [cancelButton_ sizeToFit]; | 726 [cancelButton_ sizeToFit]; |
| 727 [mainView addSubview:cancelButton_]; | 727 [mainView addSubview:cancelButton_]; |
| 728 | 728 |
| 729 // Add verify button. | 729 // Add verify button. |
| 730 verifyButton_.reset( | 730 verifyButton_.reset( |
| 731 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); | 731 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); |
| 732 [verifyButton_ setTitle:l10n_util::GetNSStringWithFixup( | 732 [verifyButton_ setTitle:l10n_util::GetNSStringWithFixup( |
| 733 IDS_AUTOFILL_CARD_UNMASK_CONFIRM_BUTTON)]; | 733 IDS_AUTOFILL_CARD_UNMASK_CONFIRM_BUTTON)]; |
| 734 [verifyButton_ setKeyEquivalent:kKeyEquivalentReturn]; | 734 [verifyButton_ setKeyEquivalent:kKeyEquivalentReturn]; |
| 735 [verifyButton_ setTarget:self]; | 735 [verifyButton_ setTarget:self]; |
| 736 [verifyButton_ setAction:@selector(onVerify:)]; | 736 [verifyButton_ setAction:@selector(onVerify:)]; |
| 737 [verifyButton_ sizeToFit]; | 737 [verifyButton_ sizeToFit]; |
| 738 [self updateVerifyButtonEnabled]; | 738 [self updateVerifyButtonEnabled]; |
| 739 [mainView addSubview:verifyButton_]; | 739 [mainView addSubview:verifyButton_]; |
| 740 | 740 |
| 741 [self setView:mainView]; | 741 [self setView:mainView]; |
| 742 [self performLayoutAndDisplay:NO]; | 742 [self performLayoutAndDisplay:NO]; |
| 743 } | 743 } |
| 744 | 744 |
| 745 @end | 745 @end |
| OLD | NEW |