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

Unified Diff: chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.mm

Issue 1038503003: Autofill OSX: Add PermanentErrorMessage box and label. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.mm
diff --git a/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.mm b/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.mm
index 799bd76661debeaa951b38ecfe5ce79074444a02..47da81677020406efc69952ef39367f5d56f8904 100644
--- a/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.mm
+++ b/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.mm
@@ -27,6 +27,8 @@ namespace {
const CGFloat kButtonGap = 6.0f;
const CGFloat kDialogContentMinWidth = 210.0f;
const CGFloat kCvcInputWidth = 64.0f;
+const SkColor kPermanentErrorTextColor = 0xffffffff;
+const SkColor kPermanentErrorBackgroundColor = 0xffd32f2f;
const ui::ResourceBundle::FontStyle kProgressFontStyle =
chrome_style::kTitleFontStyle;
const ui::ResourceBundle::FontStyle kErrorFontStyle =
@@ -88,9 +90,16 @@ void CardUnmaskPromptViewBridge::GotVerificationResult(
base::TimeDelta::FromSeconds(1));
} else {
[view_controller_ setProgressOverlayText:base::string16()];
- // TODO(bondd): Views version never hides |errorLabel_|. When Views decides
- // when to hide it then do the same thing here.
- [view_controller_ setRetriableErrorMessage:error_message];
+
+ if (allow_retry) {
+ // TODO(bondd): Views version never hides |errorLabel_|. When Views
+ // decides when to hide it then do the same thing here.
+ [view_controller_ setRetriableErrorMessage:error_message];
+ } else {
+ [view_controller_ setPermanentErrorMessage:error_message];
+ [view_controller_ setRetriableErrorMessage:base::string16()];
+ }
+ [view_controller_ performLayout];
}
}
@@ -114,10 +123,12 @@ void CardUnmaskPromptViewBridge::PerformClose() {
#pragma mark CardUnmaskPromptViewCocoa
@implementation CardUnmaskPromptViewCocoa {
+ base::scoped_nsobject<NSBox> permanentErrorBox_;
base::scoped_nsobject<NSView> inputRowView_;
base::scoped_nsobject<NSView> storageView_;
base::scoped_nsobject<NSTextField> titleLabel_;
+ base::scoped_nsobject<NSTextField> permanentErrorLabel_;
base::scoped_nsobject<NSTextField> instructionsLabel_;
base::scoped_nsobject<NSTextField> cvcInput_;
base::scoped_nsobject<NSPopUpButton> monthPopup_;
@@ -206,7 +217,34 @@ void CardUnmaskPromptViewBridge::PerformClose() {
SysUTF16ToNSString(text), kErrorFontStyle, NSNaturalTextAlignment,
NSLineBreakByWordWrapping);
[errorLabel_ setAttributedStringValue:attributedString];
- [self performLayoutAndDisplay:YES];
+}
+
+- (void)setPermanentErrorMessage:(const base::string16&)text {
groby-ooo-7-16 2015/03/25 19:32:35 OK, I still have to harp on the naming. setRetriab
bondd 2015/03/26 00:17:59 Acknowledged.
+ if (!text.empty()) {
+ if (!permanentErrorBox_) {
+ permanentErrorBox_.reset([[NSBox alloc] initWithFrame:NSZeroRect]);
+ [permanentErrorBox_ setBoxType:NSBoxCustom];
+ [permanentErrorBox_ setBorderType:NSNoBorder];
+ [permanentErrorBox_ setTitlePosition:NSNoTitle];
+ [permanentErrorBox_ setFillColor:gfx::SkColorToCalibratedNSColor(
+ kPermanentErrorBackgroundColor)];
+
+ permanentErrorLabel_.reset([constrained_window::CreateLabel() retain]);
+ [permanentErrorLabel_ setTextColor:gfx::SkColorToCalibratedNSColor(
+ kPermanentErrorTextColor)];
+
+ [permanentErrorBox_ addSubview:permanentErrorLabel_];
+ [[self view] addSubview:permanentErrorBox_];
+ }
+
+ NSAttributedString* attributedString =
+ constrained_window::GetAttributedLabelString(
+ SysUTF16ToNSString(text), kErrorFontStyle, NSNaturalTextAlignment,
+ NSLineBreakByWordWrapping);
+ [permanentErrorLabel_ setAttributedStringValue:attributedString];
+ }
+
+ [permanentErrorBox_ setHidden:text.empty()];
}
- (void)updateVerifyButtonEnabled {
@@ -283,7 +321,25 @@ void CardUnmaskPromptViewBridge::PerformClose() {
return view;
}
-// TODO(bondd): Add an ASCII diagram of the layout.
+// +------------------------------------------------+
+// | titleLabel_ (Single line.) |
+// |------------------------------------------------|
+// | permanentErrorBox_ (Multiline, may be hidden.) |
+// |------------------------------------------------|
+// | instructionsLabel_ (Multiline.) |
+// |------------------------------------------------|
+// | monthPopup_ yearPopup_ cvcInput_ cvcImage |
+// | (All enclosed in inputRowView_. Month and |
+// | year may be hidden.) |
+// |------------------------------------------------|
+// | errorLabel_ (Multiline. Always takes up space |
+// | for one line even if empty.) |
+// |------------------------------------------------|
+// | [Cancel] [Verify] |
+// |------------------------------------------------|
+// | storageCheckbox_ storageTooltip_ |
+// | (Both enclosed in storageView_.) |
groby-ooo-7-16 2015/03/25 19:32:35 Yay! +1 for ASCII diagrams! (No, really - this is
bondd 2015/03/26 00:17:59 Woo!
+// +------------------------------------------------+
- (void)performLayoutAndDisplay:(BOOL)display {
// Calculate dialog content width.
CGFloat contentWidth =
@@ -316,9 +372,22 @@ void CardUnmaskPromptViewBridge::PerformClose() {
[CardUnmaskPromptViewCocoa sizeTextField:instructionsLabel_
toFitWidth:contentWidth];
- [titleLabel_
- setFrameOrigin:NSMakePoint(0, NSMaxY([instructionsLabel_ frame]) +
- chrome_style::kRowPadding)];
+ // Layout permanent error box.
+ CGFloat minY = NSMaxY([instructionsLabel_ frame]) + chrome_style::kRowPadding;
groby-ooo-7-16 2015/03/25 19:32:35 [permanentErrorBox_ setFrame:NSMakeRect(0, minY, c
bondd 2015/03/26 00:17:59 Nice! Done.
+ if (permanentErrorBox_ && ![permanentErrorBox_ isHidden]) {
+ CGFloat errorBoxContentWidth =
+ contentWidth - [permanentErrorBox_ contentViewMargins].width * 2.0;
+ [CardUnmaskPromptViewCocoa sizeTextField:permanentErrorLabel_
groby-ooo-7-16 2015/03/25 19:32:35 Sorry. My brain was stuck. This functionality exis
bondd 2015/03/26 00:17:59 Done.
+ toFitWidth:errorBoxContentWidth];
+
+ [permanentErrorBox_ sizeToFit];
+ [permanentErrorBox_
+ setFrame:NSMakeRect(0, minY, contentWidth,
+ NSHeight([permanentErrorBox_ frame]))];
+ minY = NSMaxY([permanentErrorBox_ frame]) + chrome_style::kRowPadding;
groby-ooo-7-16 2015/03/25 19:32:35 I'm tempted to suggest a "NextRow" helper.
bondd 2015/03/26 00:17:59 Acknowledged. This layout code is in flux right no
+ }
+
+ [titleLabel_ setFrameOrigin:NSMakePoint(0, minY)];
// Center progressOverlayLabel_ vertically within inputRowView_ frame.
CGFloat progressHeight = ui::ResourceBundle::GetSharedInstance()
@@ -341,6 +410,10 @@ void CardUnmaskPromptViewBridge::PerformClose() {
[[[self view] window] setFrame:frameRect display:display];
}
+- (void)performLayout {
+ [self performLayoutAndDisplay:YES];
+}
+
- (void)loadView {
autofill::CardUnmaskPromptController* controller = bridge_->GetController();
DCHECK(controller);
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698