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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.mm

Issue 1038043003: Autofill OSX: Disable inputs and Verify button after permanent error. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cup_13_upstream_09_12_10_applied_01
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 SysUTF16ToNSString(text), kProgressFontStyle, NSCenterTextAlignment, 192 SysUTF16ToNSString(text), kProgressFontStyle, NSCenterTextAlignment,
193 NSLineBreakByWordWrapping); 193 NSLineBreakByWordWrapping);
194 [progressOverlayLabel_ setAttributedStringValue:attributedString]; 194 [progressOverlayLabel_ setAttributedStringValue:attributedString];
195 } 195 }
196 196
197 [progressOverlayLabel_ setHidden:text.empty()]; 197 [progressOverlayLabel_ setHidden:text.empty()];
198 [inputRowView_ setHidden:!text.empty()]; 198 [inputRowView_ setHidden:!text.empty()];
199 [self updateVerifyButtonEnabled]; 199 [self updateVerifyButtonEnabled];
200 } 200 }
201 201
202 - (void)setInputsEnabled:(BOOL)enabled {
bondd 2015/03/26 19:50:06 Only ever called with enabled == NO. I could renam
groby-ooo-7-16 2015/03/26 20:17:45 No, I'd leave it, for API symmetry. If you leave t
bondd 2015/03/26 20:33:12 We want to leave the Cancel button enabled.
bondd 2015/03/26 20:46:52 Also, unless I'm missing something this will give
203 [cvcInput_ setEnabled:enabled];
204 [monthPopup_ setEnabled:enabled];
205 [yearPopup_ setEnabled:enabled];
206 [storageCheckbox_ setEnabled:enabled];
207 }
208
202 - (void)setRetriableErrorMessage:(const base::string16&)text { 209 - (void)setRetriableErrorMessage:(const base::string16&)text {
203 NSAttributedString* attributedString = 210 NSAttributedString* attributedString =
204 constrained_window::GetAttributedLabelString( 211 constrained_window::GetAttributedLabelString(
205 SysUTF16ToNSString(text), kErrorFontStyle, NSNaturalTextAlignment, 212 SysUTF16ToNSString(text), kErrorFontStyle, NSNaturalTextAlignment,
206 NSLineBreakByWordWrapping); 213 NSLineBreakByWordWrapping);
207 [errorLabel_ setAttributedStringValue:attributedString]; 214 [errorLabel_ setAttributedStringValue:attributedString];
208 [self performLayoutAndDisplay:YES]; 215 [self performLayoutAndDisplay:YES];
209 } 216 }
210 217
211 - (void)setPermanentErrorMessage:(const base::string16&)text { 218 - (void)setPermanentErrorMessage:(const base::string16&)text {
(...skipping 16 matching lines...) Expand all
228 } 235 }
229 236
230 NSAttributedString* attributedString = 237 NSAttributedString* attributedString =
231 constrained_window::GetAttributedLabelString( 238 constrained_window::GetAttributedLabelString(
232 SysUTF16ToNSString(text), kErrorFontStyle, NSNaturalTextAlignment, 239 SysUTF16ToNSString(text), kErrorFontStyle, NSNaturalTextAlignment,
233 NSLineBreakByWordWrapping); 240 NSLineBreakByWordWrapping);
234 [permanentErrorLabel_ setAttributedStringValue:attributedString]; 241 [permanentErrorLabel_ setAttributedStringValue:attributedString];
235 } 242 }
236 243
237 [permanentErrorBox_ setHidden:text.empty()]; 244 [permanentErrorBox_ setHidden:text.empty()];
245 [self setInputsEnabled:NO];
246 [self updateVerifyButtonEnabled];
238 [self setRetriableErrorMessage:base::string16()]; 247 [self setRetriableErrorMessage:base::string16()];
239 } 248 }
240 249
241 - (void)updateVerifyButtonEnabled { 250 - (void)updateVerifyButtonEnabled {
242 BOOL enable = ![inputRowView_ isHidden] && 251 BOOL enable = ![inputRowView_ isHidden] &&
252 ![[permanentErrorLabel_ stringValue] length] &&
bondd 2015/03/26 19:50:06 Alternatively, this line could be "[cvcInput_ isEn
groby-ooo-7-16 2015/03/26 20:17:45 I like the current one better, because it's more g
bondd 2015/03/26 20:33:12 Acknowledged.
243 bridge_->GetController()->InputCvcIsValid( 253 bridge_->GetController()->InputCvcIsValid(
244 base::SysNSStringToUTF16([cvcInput_ stringValue])) && 254 base::SysNSStringToUTF16([cvcInput_ stringValue])) &&
245 [self expirationDateIsValid]; 255 [self expirationDateIsValid];
246 256
247 [verifyButton_ setEnabled:enable]; 257 [verifyButton_ setEnabled:enable];
248 } 258 }
249 259
250 - (void)onVerify:(id)sender { 260 - (void)onVerify:(id)sender {
251 bridge_->GetController()->OnUnmaskResponse( 261 bridge_->GetController()->OnUnmaskResponse(
252 base::SysNSStringToUTF16([cvcInput_ stringValue]), 262 base::SysNSStringToUTF16([cvcInput_ stringValue]),
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 544
535 // Layout inputRowView_. 545 // Layout inputRowView_.
536 [CardUnmaskPromptViewCocoa sizeToFitView:inputRowView_]; 546 [CardUnmaskPromptViewCocoa sizeToFitView:inputRowView_];
537 [CardUnmaskPromptViewCocoa verticallyCenterSubviewsInView:inputRowView_]; 547 [CardUnmaskPromptViewCocoa verticallyCenterSubviewsInView:inputRowView_];
538 548
539 [self setView:mainView]; 549 [self setView:mainView];
540 [self performLayoutAndDisplay:NO]; 550 [self performLayoutAndDisplay:NO];
541 } 551 }
542 552
543 @end 553 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698