| Index: chrome/browser/ui/views/autofill/autofill_dialog_views.cc
|
| diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
|
| index eb7a379d8540f44ad54616c4cebe449954eb6db6..b04a32ad67384e2264d3154384fd80531cf4be99 100644
|
| --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
|
| +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
|
| @@ -22,6 +22,7 @@
|
| #include "third_party/skia/include/core/SkColor.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/base/models/combobox_model.h"
|
| +#include "ui/base/models/menu_model.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/views/background.h"
|
| @@ -351,10 +352,11 @@ void AutofillDialogViews::SectionContainer::SetForwardMouseEvents(
|
| }
|
|
|
| void AutofillDialogViews::SectionContainer::SetActive(bool active) {
|
| - if (active == !!background())
|
| + bool is_active = active && proxy_button_->visible();
|
| + if (is_active == !!background())
|
| return;
|
|
|
| - set_background(active ?
|
| + set_background(is_active ?
|
| // TODO(estade): use the correct color.
|
| views::Background::CreateSolidBackground(SK_ColorLTGRAY):
|
| NULL);
|
| @@ -423,7 +425,8 @@ AutofillDialogViews::SuggestionView::SuggestionView(
|
| icon_(new views::ImageView()),
|
| label_container_(new views::View()),
|
| decorated_(
|
| - new DecoratedTextfield(string16(), string16(), autofill_dialog)) {
|
| + new DecoratedTextfield(string16(), string16(), autofill_dialog)),
|
| + edit_link_(new views::Link(edit_label)) {
|
| // Label and icon.
|
| label_container_->SetLayoutManager(
|
| new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
|
| @@ -441,16 +444,15 @@ AutofillDialogViews::SuggestionView::SuggestionView(
|
| AddChildView(label_line_2_);
|
|
|
| // TODO(estade): The link needs to have a different color when hovered.
|
| - views::Link* edit_link = new views::Link(edit_label);
|
| - edit_link->set_listener(autofill_dialog);
|
| - edit_link->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| - edit_link->SetUnderline(false);
|
| + edit_link_->set_listener(autofill_dialog);
|
| + edit_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| + edit_link_->SetUnderline(false);
|
|
|
| // This container prevents the edit link from being horizontally stretched.
|
| views::View* link_container = new views::View();
|
| link_container->SetLayoutManager(
|
| new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
|
| - link_container->AddChildView(edit_link);
|
| + link_container->AddChildView(edit_link_);
|
| AddChildView(link_container);
|
|
|
| SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
|
| @@ -458,6 +460,10 @@ AutofillDialogViews::SuggestionView::SuggestionView(
|
|
|
| AutofillDialogViews::SuggestionView::~SuggestionView() {}
|
|
|
| +void AutofillDialogViews::SuggestionView::SetEditable(bool editable) {
|
| + edit_link_->SetVisible(editable);
|
| +}
|
| +
|
| void AutofillDialogViews::SuggestionView::SetSuggestionText(
|
| const string16& text) {
|
| // TODO(estade): does this localize well?
|
| @@ -627,8 +633,10 @@ void AutofillDialogViews::GetUserInput(DialogSection section,
|
| }
|
|
|
| string16 AutofillDialogViews::GetCvc() {
|
| - return GroupForSection(SECTION_CC)->suggested_info->decorated_textfield()->
|
| - textfield()->text();
|
| + DialogSection billing_section = controller_->SectionIsActive(SECTION_CC) ?
|
| + SECTION_CC : SECTION_CC_BILLING;
|
| + return GroupForSection(billing_section)->suggested_info->
|
| + decorated_textfield()->textfield()->text();
|
| }
|
|
|
| bool AutofillDialogViews::UseBillingForShipping() {
|
| @@ -741,12 +749,10 @@ bool AutofillDialogViews::Cancel() {
|
| }
|
|
|
| bool AutofillDialogViews::Accept() {
|
| - if (!ValidateForm())
|
| - return false;
|
| + if (ValidateForm())
|
| + controller_->OnAccept();
|
|
|
| - controller_->OnSubmit();
|
| -
|
| - // Let |controller_| decide when to hide the dialog.
|
| + // |controller_| decides when to hide the dialog.
|
| return false;
|
| }
|
|
|
| @@ -777,6 +783,9 @@ void AutofillDialogViews::ButtonPressed(views::Button* sender,
|
| }
|
| DCHECK(group);
|
|
|
| + if (!group->suggested_button->visible())
|
| + return;
|
| +
|
| views::MenuModelAdapter adapter(
|
| controller_->MenuModelForSection(group->section));
|
| menu_runner_.reset(new views::MenuRunner(adapter.CreateMenu()));
|
| @@ -963,7 +972,7 @@ views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) {
|
| layout->StartRow(0, kColumnSetId);
|
|
|
| // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the
|
| - // dialog toggle which is shown.
|
| + // dialog to toggle which is shown.
|
| views::View* info_view = new views::View();
|
| info_view->SetLayoutManager(
|
| new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
|
| @@ -983,14 +992,6 @@ views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) {
|
| info_view->AddChildView(suggested_info);
|
| layout->AddView(info_view);
|
|
|
| - if (section == SECTION_CC) {
|
| - // TODO(estade): don't hardcode this string.
|
| - suggested_info->ShowTextfield(
|
| - ASCIIToUTF16("CVC"),
|
| - controller_->IconForField(CREDIT_CARD_VERIFICATION_CODE,
|
| - string16()).AsImageSkia());
|
| - }
|
| -
|
| // TODO(estade): Fix the appearance of this button.
|
| views::ImageButton* menu_button = new views::ImageButton(this);
|
| ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| @@ -1086,6 +1087,16 @@ void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) {
|
| gfx::Image icon = controller_->SuggestionIconForSection(group.section);
|
| group.suggested_info->SetSuggestionIcon(icon);
|
|
|
| + if (group.section == SECTION_CC ||
|
| + (group.section == SECTION_CC_BILLING &&
|
| + controller_->IsSubmitPausedOn(wallet::VERIFY_CVV))) {
|
| + // TODO(estade): don't hardcode this string.
|
| + group.suggested_info->ShowTextfield(
|
| + ASCIIToUTF16("CVC"),
|
| + controller_->IconForField(CREDIT_CARD_VERIFICATION_CODE,
|
| + string16()).AsImageSkia());
|
| + }
|
| +
|
| if (group.section == SECTION_SHIPPING) {
|
| bool show_checkbox = !show_suggestions;
|
| // When the checkbox is going from hidden to visible, it's because the
|
| @@ -1106,8 +1117,19 @@ void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) {
|
| save_in_chrome_checkbox_->SetVisible(
|
| controller_->ShouldOfferToSaveInChrome() && AtLeastOneSectionIsEditing());
|
|
|
| + const bool has_suggestions =
|
| + controller_->MenuModelForSection(group.section)->GetItemCount() > 0;
|
| +
|
| + if (group.suggested_button)
|
| + group.suggested_button->SetVisible(has_suggestions);
|
| +
|
| + if (group.suggested_info) {
|
| + group.suggested_info->SetEditable(
|
| + !controller_->IsSubmitPausedOn(wallet::VERIFY_CVV));
|
| + }
|
| +
|
| if (group.container) {
|
| - group.container->SetForwardMouseEvents(show_suggestions);
|
| + group.container->SetForwardMouseEvents(has_suggestions && show_suggestions);
|
| group.container->SetVisible(controller_->SectionIsActive(group.section));
|
| }
|
|
|
|
|