| Index: chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc
|
| diff --git a/chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc b/chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc
|
| index 1d9f307a1688c879005be781a31ea7817e42c97c..0952195da30e5eb6241d865fa7f5b57d9908bd0a 100644
|
| --- a/chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc
|
| +++ b/chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc
|
| @@ -27,6 +27,7 @@
|
| #include "ui/views/controls/combobox/combobox.h"
|
| #include "ui/views/controls/image_view.h"
|
| #include "ui/views/controls/label.h"
|
| +#include "ui/views/controls/link.h"
|
| #include "ui/views/controls/throbber.h"
|
| #include "ui/views/layout/box_layout.h"
|
| #include "ui/views/widget/widget.h"
|
| @@ -57,6 +58,7 @@ CardUnmaskPromptViews::CardUnmaskPromptViews(
|
| cvc_input_(nullptr),
|
| month_input_(nullptr),
|
| year_input_(nullptr),
|
| + new_card_link_(nullptr),
|
| error_icon_(nullptr),
|
| error_label_(nullptr),
|
| storage_row_(nullptr),
|
| @@ -116,11 +118,16 @@ void CardUnmaskPromptViews::GotVerificationResult(
|
| if (allow_retry) {
|
| SetInputsEnabled(true);
|
|
|
| - // If there is more than one input showing, don't mark anything as
|
| - // invalid since we don't know the location of the problem.
|
| - if (!controller_->ShouldRequestExpirationDate())
|
| + if (!controller_->ShouldRequestExpirationDate()) {
|
| + // If there is more than one input showing, don't mark anything as
|
| + // invalid since we don't know the location of the problem.
|
| cvc_input_->SetInvalid(true);
|
|
|
| + // Show a "New card?" link, which when clicked will cause us to ask
|
| + // for expiration date.
|
| + ShowNewCardLink();
|
| + }
|
| +
|
| // TODO(estade): When do we hide |error_label_|?
|
| SetRetriableErrorMessage(error_message);
|
| } else {
|
| @@ -134,6 +141,21 @@ void CardUnmaskPromptViews::GotVerificationResult(
|
| Layout();
|
| }
|
|
|
| +void CardUnmaskPromptViews::LinkClicked(views::Link* source, int event_flags) {
|
| + DCHECK_EQ(source, new_card_link_);
|
| + controller_->NewCardLinkClicked();
|
| + for (int i = 0; i < input_row_->child_count(); ++i)
|
| + input_row_->child_at(i)->SetVisible(true);
|
| +
|
| + new_card_link_->SetVisible(false);
|
| + input_row_->InvalidateLayout();
|
| + cvc_input_->SetInvalid(false);
|
| + cvc_input_->SetText(base::string16());
|
| + GetDialogClientView()->UpdateDialogButtons();
|
| + GetWidget()->UpdateWindowTitle();
|
| + SetRetriableErrorMessage(base::string16());
|
| +}
|
| +
|
| void CardUnmaskPromptViews::SetRetriableErrorMessage(
|
| const base::string16& message) {
|
| if (message.empty()) {
|
| @@ -162,10 +184,20 @@ void CardUnmaskPromptViews::SetInputsEnabled(bool enabled) {
|
| cvc_input_->SetEnabled(enabled);
|
| if (storage_checkbox_)
|
| storage_checkbox_->SetEnabled(enabled);
|
| - if (month_input_)
|
| - month_input_->SetEnabled(enabled);
|
| - if (year_input_)
|
| - year_input_->SetEnabled(enabled);
|
| + month_input_->SetEnabled(enabled);
|
| + year_input_->SetEnabled(enabled);
|
| +}
|
| +
|
| +void CardUnmaskPromptViews::ShowNewCardLink() {
|
| + if (new_card_link_)
|
| + return;
|
| +
|
| + new_card_link_ = new views::Link(
|
| + l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_UNMASK_NEW_CARD_LINK));
|
| + new_card_link_->SetBorder(views::Border::CreateEmptyBorder(0, 7, 0, 0));
|
| + new_card_link_->SetUnderline(false);
|
| + new_card_link_->set_listener(this);
|
| + input_row_->AddChildView(new_card_link_);
|
| }
|
|
|
| views::View* CardUnmaskPromptViews::GetContentsView() {
|
| @@ -290,10 +322,12 @@ bool CardUnmaskPromptViews::Accept() {
|
|
|
| controller_->OnUnmaskResponse(
|
| cvc_input_->text(),
|
| - month_input_ ? month_input_->GetTextForRow(month_input_->selected_index())
|
| - : base::string16(),
|
| - year_input_ ? year_input_->GetTextForRow(year_input_->selected_index())
|
| - : base::string16(),
|
| + month_input_->visible()
|
| + ? month_input_->GetTextForRow(month_input_->selected_index())
|
| + : base::string16(),
|
| + year_input_->visible()
|
| + ? year_input_->GetTextForRow(year_input_->selected_index())
|
| + : base::string16(),
|
| storage_checkbox_ ? storage_checkbox_->checked() : false);
|
| return false;
|
| }
|
| @@ -377,18 +411,21 @@ void CardUnmaskPromptViews::InitIfNecessary() {
|
| new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 5));
|
| controls_container->AddChildView(input_row_);
|
|
|
| - if (controller_->ShouldRequestExpirationDate()) {
|
| - month_input_ = new views::Combobox(&month_combobox_model_);
|
| - month_input_->set_listener(this);
|
| - input_row_->AddChildView(month_input_);
|
| - views::Label* separator = new views::Label(l10n_util::GetStringUTF16(
|
| - IDS_AUTOFILL_CARD_UNMASK_EXPIRATION_DATE_SEPARATOR));
|
| - separator->SetEnabledColor(kGreyTextColor);
|
| - input_row_->AddChildView(separator);
|
| - year_input_ = new views::Combobox(&year_combobox_model_);
|
| - year_input_->set_listener(this);
|
| - input_row_->AddChildView(year_input_);
|
| - input_row_->AddChildView(new views::Label(base::ASCIIToUTF16(" ")));
|
| + month_input_ = new views::Combobox(&month_combobox_model_);
|
| + month_input_->set_listener(this);
|
| + input_row_->AddChildView(month_input_);
|
| + views::Label* separator = new views::Label(l10n_util::GetStringUTF16(
|
| + IDS_AUTOFILL_CARD_UNMASK_EXPIRATION_DATE_SEPARATOR));
|
| + separator->SetEnabledColor(kGreyTextColor);
|
| + input_row_->AddChildView(separator);
|
| + year_input_ = new views::Combobox(&year_combobox_model_);
|
| + year_input_->set_listener(this);
|
| + input_row_->AddChildView(year_input_);
|
| + input_row_->AddChildView(new views::Label(base::ASCIIToUTF16(" ")));
|
| + // Hide all of the above as appropriate.
|
| + if (!controller_->ShouldRequestExpirationDate()) {
|
| + for (int i = 0; i < input_row_->child_count(); ++i)
|
| + input_row_->child_at(i)->SetVisible(false);
|
| }
|
|
|
| cvc_input_ = new DecoratedTextfield(
|
|
|