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

Side by Side Diff: chrome/browser/ui/autofill/card_unmask_prompt_controller_impl.cc

Issue 870203002: Add status to server credit cards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add TODO Created 5 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/autofill/card_unmask_prompt_controller_impl.h" 5 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller_impl.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h" 9 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h"
10 #include "chrome/grit/generated_resources.h" 10 #include "chrome/grit/generated_resources.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const base::string16& cvc) { 51 const base::string16& cvc) {
52 card_unmask_view_->DisableAndWaitForVerification(); 52 card_unmask_view_->DisableAndWaitForVerification();
53 delegate_->OnUnmaskResponse(cvc); 53 delegate_->OnUnmaskResponse(cvc);
54 } 54 }
55 55
56 content::WebContents* CardUnmaskPromptControllerImpl::GetWebContents() { 56 content::WebContents* CardUnmaskPromptControllerImpl::GetWebContents() {
57 return web_contents_; 57 return web_contents_;
58 } 58 }
59 59
60 base::string16 CardUnmaskPromptControllerImpl::GetWindowTitle() const { 60 base::string16 CardUnmaskPromptControllerImpl::GetWindowTitle() const {
61 return base::ASCIIToUTF16("Unlocking ") + card_.TypeAndLastFourDigits(); 61 // TODO(estade): i18n.
62 if (card_.GetServerStatus() == CreditCard::EXPIRED) {
63 return base::ASCIIToUTF16("Update and verify your card ") +
64 card_.TypeAndLastFourDigits();
65 }
66
67 return base::ASCIIToUTF16("Verify your card ") +
68 card_.TypeAndLastFourDigits();
62 } 69 }
63 70
64 base::string16 CardUnmaskPromptControllerImpl::GetInstructionsMessage() const { 71 base::string16 CardUnmaskPromptControllerImpl::GetInstructionsMessage() const {
72 if (card_.GetServerStatus() == CreditCard::EXPIRED) {
73 return l10n_util::GetStringUTF16(
74 card_.type() == kAmericanExpressCard
75 ? IDS_AUTOFILL_CARD_UNMASK_PROMPT_INSTRUCTIONS_EXPIRED_AMEX
76 : IDS_AUTOFILL_CARD_UNMASK_PROMPT_INSTRUCTIONS_EXPIRED);
77 }
78
65 return l10n_util::GetStringUTF16( 79 return l10n_util::GetStringUTF16(
66 card_.type() == kAmericanExpressCard 80 card_.type() == kAmericanExpressCard
67 ? IDS_AUTOFILL_CARD_UNMASK_PROMPT_INSTRUCTIONS_AMEX 81 ? IDS_AUTOFILL_CARD_UNMASK_PROMPT_INSTRUCTIONS_AMEX
68 : IDS_AUTOFILL_CARD_UNMASK_PROMPT_INSTRUCTIONS); 82 : IDS_AUTOFILL_CARD_UNMASK_PROMPT_INSTRUCTIONS);
69 } 83 }
70 84
71 int CardUnmaskPromptControllerImpl::GetCvcImageRid() const { 85 int CardUnmaskPromptControllerImpl::GetCvcImageRid() const {
72 return card_.type() == kAmericanExpressCard ? IDR_CREDIT_CARD_CVC_HINT_AMEX 86 return card_.type() == kAmericanExpressCard ? IDR_CREDIT_CARD_CVC_HINT_AMEX
73 : IDR_CREDIT_CARD_CVC_HINT; 87 : IDR_CREDIT_CARD_CVC_HINT;
74 } 88 }
75 89
90 bool CardUnmaskPromptControllerImpl::ShouldRequestExpirationDate() const {
91 return card_.GetServerStatus() == CreditCard::EXPIRED;
92 }
93
76 bool CardUnmaskPromptControllerImpl::InputTextIsValid( 94 bool CardUnmaskPromptControllerImpl::InputTextIsValid(
77 const base::string16& input_text) const { 95 const base::string16& input_text) const {
78 base::string16 trimmed_text; 96 base::string16 trimmed_text;
79 base::TrimWhitespace(input_text, base::TRIM_ALL, &trimmed_text); 97 base::TrimWhitespace(input_text, base::TRIM_ALL, &trimmed_text);
80 size_t input_size = card_.type() == kAmericanExpressCard ? 4 : 3; 98 size_t input_size = card_.type() == kAmericanExpressCard ? 4 : 3;
81 return trimmed_text.size() == input_size && 99 return trimmed_text.size() == input_size &&
82 base::ContainsOnlyChars(trimmed_text, 100 base::ContainsOnlyChars(trimmed_text,
83 base::ASCIIToUTF16("0123456789")); 101 base::ASCIIToUTF16("0123456789"));
84 } 102 }
85 103
86 } // namespace autofill 104 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/card_unmask_prompt_controller_impl.h ('k') | components/autofill/core/browser/credit_card.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698