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..3ee3ce19290fc59b9d9ba58b1c5332062b4cf3bd 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,6 +352,7 @@ void AutofillDialogViews::SectionContainer::SetForwardMouseEvents( |
} |
void AutofillDialogViews::SectionContainer::SetActive(bool active) { |
+ active &= can_activate_; |
Evan Stade
2013/03/26 19:29:54
I don't like that you're using a bitwise operator
Dan Beam
2013/03/27 00:38:27
Done.
|
if (active == !!background()) |
return; |
@@ -361,6 +363,12 @@ void AutofillDialogViews::SectionContainer::SetActive(bool active) { |
SchedulePaint(); |
} |
+void AutofillDialogViews::SectionContainer::SetCanActivate(bool can_activate) { |
+ can_activate_ = can_activate; |
+ if (!can_activate_) |
+ SetActive(false); |
+} |
+ |
void AutofillDialogViews::SectionContainer::OnMouseMoved( |
const ui::MouseEvent& event) { |
if (!forward_mouse_events_) |
@@ -627,8 +635,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 +751,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 +785,9 @@ void AutofillDialogViews::ButtonPressed(views::Button* sender, |
} |
DCHECK(group); |
+ if (group->container && !group->container->can_activate()) |
+ return; |
+ |
views::MenuModelAdapter adapter( |
controller_->MenuModelForSection(group->section)); |
menu_runner_.reset(new views::MenuRunner(adapter.CreateMenu())); |
@@ -962,7 +973,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 +993,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 +1088,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,11 +1118,18 @@ void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { |
save_in_chrome_checkbox_->SetVisible( |
controller_->ShouldOfferToSaveInChrome() && AtLeastOneSectionIsEditing()); |
+ const bool can_activate = |
+ controller_->MenuModelForSection(group.section)->GetItemCount() > 0; |
+ |
if (group.container) { |
+ group.container->SetCanActivate(can_activate); |
Evan Stade
2013/03/26 19:29:54
"can activate" can just be controlled by whether p
Dan Beam
2013/03/27 00:38:27
Done.
|
group.container->SetForwardMouseEvents(show_suggestions); |
group.container->SetVisible(controller_->SectionIsActive(group.section)); |
} |
+ if (group.suggested_button) |
+ group.suggested_button->SetVisible(can_activate); |
+ |
ContentsPreferredSizeChanged(); |
} |