Chromium Code Reviews| 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 f982d5a1908add3e5cd993807d58803a3132a1b3..cf610651f301ad3029fe660ac6b9c22946575bae 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" |
| @@ -312,7 +313,8 @@ AutofillDialogViews::SectionContainer::SectionContainer( |
| views::View* controls, |
| views::Button* proxy_button) |
| : proxy_button_(proxy_button), |
| - forward_mouse_events_(false) { |
| + forward_mouse_events_(false), |
| + active_(false) { |
| set_notify_enter_exit_on_child(true); |
| views::GridLayout* layout = new views::GridLayout(this); |
| @@ -351,16 +353,21 @@ void AutofillDialogViews::SectionContainer::SetForwardMouseEvents( |
| } |
| void AutofillDialogViews::SectionContainer::SetActive(bool active) { |
| - if (active == !!background()) |
| + active_ = active && proxy_button_->visible(); |
| + if (active_ == !!background()) |
| return; |
| - set_background(active ? |
| + set_background(active_ ? |
| // TODO(estade): use the correct color. |
| views::Background::CreateSolidBackground(SK_ColorLTGRAY): |
| NULL); |
| SchedulePaint(); |
| } |
| +void AutofillDialogViews::SectionContainer::Refresh() { |
| + SetActive(active_); |
| +} |
| + |
| void AutofillDialogViews::SectionContainer::OnMouseMoved( |
| const ui::MouseEvent& event) { |
| if (!forward_mouse_events_) |
| @@ -423,7 +430,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 +449,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 +465,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 +638,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 +754,10 @@ bool AutofillDialogViews::Cancel() { |
| } |
| bool AutofillDialogViews::Accept() { |
| - if (!ValidateForm()) |
| - return false; |
| - |
| - controller_->OnSubmit(); |
| + if (ValidateForm()) |
| + controller_->OnAccept(); |
| - // Let |controller_| decide when to hide the dialog. |
| + // |controller_| decides when to hide the dialog. |
| return false; |
| } |
| @@ -777,6 +788,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())); |
| @@ -962,7 +976,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)); |
| @@ -982,14 +996,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(); |
| @@ -1085,6 +1091,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 |
| @@ -1105,9 +1121,20 @@ void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { |
| save_in_chrome_checkbox_->SetVisible( |
| controller_->ShouldOfferToSaveInChrome() && AtLeastOneSectionIsEditing()); |
| + if (group.suggested_button) { |
| + group.suggested_button->SetVisible( |
| + controller_->MenuModelForSection(group.section)->GetItemCount() > 0); |
| + } |
| + |
| + if (group.suggested_info) { |
| + group.suggested_info->SetEditable( |
| + !controller_->IsSubmitPausedOn(wallet::VERIFY_CVV)); |
| + } |
| + |
| if (group.container) { |
| group.container->SetForwardMouseEvents(show_suggestions); |
| group.container->SetVisible(controller_->SectionIsActive(group.section)); |
| + group.container->Refresh(); |
|
Evan Stade
2013/03/27 02:39:38
I think you can piggy back on SetForwardMouseEvent
Dan Beam
2013/03/27 02:50:36
Done.
|
| } |
| ContentsPreferredSizeChanged(); |