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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_dialog_views.cc

Issue 12893007: Implementing VERIFY_CVV required action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/views/autofill/autofill_dialog_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" 12 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
13 #include "chrome/browser/ui/views/constrained_window_views.h" 13 #include "chrome/browser/ui/views/constrained_window_views.h"
14 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" 14 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h"
15 #include "components/autofill/browser/wallet/wallet_service_url.h" 15 #include "components/autofill/browser/wallet/wallet_service_url.h"
16 #include "content/public/browser/native_web_keyboard_event.h" 16 #include "content/public/browser/native_web_keyboard_event.h"
17 #include "content/public/browser/navigation_controller.h" 17 #include "content/public/browser/navigation_controller.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "content/public/browser/web_contents_view.h" 19 #include "content/public/browser/web_contents_view.h"
20 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
21 #include "grit/ui_resources.h" 21 #include "grit/ui_resources.h"
22 #include "third_party/skia/include/core/SkColor.h" 22 #include "third_party/skia/include/core/SkColor.h"
23 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/models/combobox_model.h" 24 #include "ui/base/models/combobox_model.h"
25 #include "ui/base/models/menu_model.h"
25 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
26 #include "ui/gfx/canvas.h" 27 #include "ui/gfx/canvas.h"
27 #include "ui/views/background.h" 28 #include "ui/views/background.h"
28 #include "ui/views/border.h" 29 #include "ui/views/border.h"
29 #include "ui/views/controls/button/checkbox.h" 30 #include "ui/views/controls/button/checkbox.h"
30 #include "ui/views/controls/button/image_button.h" 31 #include "ui/views/controls/button/image_button.h"
31 #include "ui/views/controls/combobox/combobox.h" 32 #include "ui/views/controls/combobox/combobox.h"
32 #include "ui/views/controls/image_view.h" 33 #include "ui/views/controls/image_view.h"
33 #include "ui/views/controls/label.h" 34 #include "ui/views/controls/label.h"
34 #include "ui/views/controls/link.h" 35 #include "ui/views/controls/link.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 AutofillDialogViews::SectionContainer::~SectionContainer() {} 345 AutofillDialogViews::SectionContainer::~SectionContainer() {}
345 346
346 void AutofillDialogViews::SectionContainer::SetForwardMouseEvents( 347 void AutofillDialogViews::SectionContainer::SetForwardMouseEvents(
347 bool forward) { 348 bool forward) {
348 forward_mouse_events_ = forward; 349 forward_mouse_events_ = forward;
349 if (!forward) 350 if (!forward)
350 set_background(NULL); 351 set_background(NULL);
351 } 352 }
352 353
353 void AutofillDialogViews::SectionContainer::SetActive(bool active) { 354 void AutofillDialogViews::SectionContainer::SetActive(bool active) {
354 if (active == !!background()) 355 bool is_active = active && proxy_button_->visible();
356 if (is_active == !!background())
355 return; 357 return;
356 358
357 set_background(active ? 359 set_background(is_active ?
358 // TODO(estade): use the correct color. 360 // TODO(estade): use the correct color.
359 views::Background::CreateSolidBackground(SK_ColorLTGRAY): 361 views::Background::CreateSolidBackground(SK_ColorLTGRAY):
360 NULL); 362 NULL);
361 SchedulePaint(); 363 SchedulePaint();
362 } 364 }
363 365
364 void AutofillDialogViews::SectionContainer::OnMouseMoved( 366 void AutofillDialogViews::SectionContainer::OnMouseMoved(
365 const ui::MouseEvent& event) { 367 const ui::MouseEvent& event) {
366 if (!forward_mouse_events_) 368 if (!forward_mouse_events_)
367 return; 369 return;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // AutofilDialogViews::SuggestionView ------------------------------------------ 418 // AutofilDialogViews::SuggestionView ------------------------------------------
417 419
418 AutofillDialogViews::SuggestionView::SuggestionView( 420 AutofillDialogViews::SuggestionView::SuggestionView(
419 const string16& edit_label, 421 const string16& edit_label,
420 AutofillDialogViews* autofill_dialog) 422 AutofillDialogViews* autofill_dialog)
421 : label_(new views::Label()), 423 : label_(new views::Label()),
422 label_line_2_(new views::Label()), 424 label_line_2_(new views::Label()),
423 icon_(new views::ImageView()), 425 icon_(new views::ImageView()),
424 label_container_(new views::View()), 426 label_container_(new views::View()),
425 decorated_( 427 decorated_(
426 new DecoratedTextfield(string16(), string16(), autofill_dialog)) { 428 new DecoratedTextfield(string16(), string16(), autofill_dialog)),
429 edit_link_(new views::Link(edit_label)) {
427 // Label and icon. 430 // Label and icon.
428 label_container_->SetLayoutManager( 431 label_container_->SetLayoutManager(
429 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 432 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
430 kAroundTextPadding)); 433 kAroundTextPadding));
431 label_container_->AddChildView(icon_); 434 label_container_->AddChildView(icon_);
432 label_container_->AddChildView(label_); 435 label_container_->AddChildView(label_);
433 label_container_->AddChildView(decorated_); 436 label_container_->AddChildView(decorated_);
434 decorated_->SetVisible(false); 437 decorated_->SetVisible(false);
435 // TODO(estade): get the sizing and spacing right on this textfield. 438 // TODO(estade): get the sizing and spacing right on this textfield.
436 decorated_->textfield()->set_default_width_in_chars(10); 439 decorated_->textfield()->set_default_width_in_chars(10);
437 AddChildView(label_container_); 440 AddChildView(label_container_);
438 441
439 label_line_2_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 442 label_line_2_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
440 label_line_2_->SetVisible(false); 443 label_line_2_->SetVisible(false);
441 AddChildView(label_line_2_); 444 AddChildView(label_line_2_);
442 445
443 // TODO(estade): The link needs to have a different color when hovered. 446 // TODO(estade): The link needs to have a different color when hovered.
444 views::Link* edit_link = new views::Link(edit_label); 447 edit_link_->set_listener(autofill_dialog);
445 edit_link->set_listener(autofill_dialog); 448 edit_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
446 edit_link->SetHorizontalAlignment(gfx::ALIGN_LEFT); 449 edit_link_->SetUnderline(false);
447 edit_link->SetUnderline(false);
448 450
449 // This container prevents the edit link from being horizontally stretched. 451 // This container prevents the edit link from being horizontally stretched.
450 views::View* link_container = new views::View(); 452 views::View* link_container = new views::View();
451 link_container->SetLayoutManager( 453 link_container->SetLayoutManager(
452 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 454 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
453 link_container->AddChildView(edit_link); 455 link_container->AddChildView(edit_link_);
454 AddChildView(link_container); 456 AddChildView(link_container);
455 457
456 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 458 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
457 } 459 }
458 460
459 AutofillDialogViews::SuggestionView::~SuggestionView() {} 461 AutofillDialogViews::SuggestionView::~SuggestionView() {}
460 462
463 void AutofillDialogViews::SuggestionView::SetEditable(bool editable) {
464 edit_link_->SetVisible(editable);
465 }
466
461 void AutofillDialogViews::SuggestionView::SetSuggestionText( 467 void AutofillDialogViews::SuggestionView::SetSuggestionText(
462 const string16& text) { 468 const string16& text) {
463 // TODO(estade): does this localize well? 469 // TODO(estade): does this localize well?
464 string16 line_return(ASCIIToUTF16("\n")); 470 string16 line_return(ASCIIToUTF16("\n"));
465 size_t position = text.find(line_return); 471 size_t position = text.find(line_return);
466 if (position == string16::npos) { 472 if (position == string16::npos) {
467 label_->SetText(text); 473 label_->SetText(text);
468 label_line_2_->SetVisible(false); 474 label_line_2_->SetVisible(false);
469 } else { 475 } else {
470 label_->SetText(text.substr(0, position)); 476 label_->SetText(text.substr(0, position));
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 output->insert(std::make_pair(it->first, it->second->textfield()->text())); 626 output->insert(std::make_pair(it->first, it->second->textfield()->text()));
621 } 627 }
622 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); 628 for (ComboboxMap::const_iterator it = group->comboboxes.begin();
623 it != group->comboboxes.end(); ++it) { 629 it != group->comboboxes.end(); ++it) {
624 output->insert(std::make_pair(it->first, 630 output->insert(std::make_pair(it->first,
625 it->second->model()->GetItemAt(it->second->selected_index()))); 631 it->second->model()->GetItemAt(it->second->selected_index())));
626 } 632 }
627 } 633 }
628 634
629 string16 AutofillDialogViews::GetCvc() { 635 string16 AutofillDialogViews::GetCvc() {
630 return GroupForSection(SECTION_CC)->suggested_info->decorated_textfield()-> 636 DialogSection billing_section = controller_->SectionIsActive(SECTION_CC) ?
631 textfield()->text(); 637 SECTION_CC : SECTION_CC_BILLING;
638 return GroupForSection(billing_section)->suggested_info->
639 decorated_textfield()->textfield()->text();
632 } 640 }
633 641
634 bool AutofillDialogViews::UseBillingForShipping() { 642 bool AutofillDialogViews::UseBillingForShipping() {
635 return use_billing_for_shipping_->checked(); 643 return use_billing_for_shipping_->checked();
636 } 644 }
637 645
638 bool AutofillDialogViews::SaveDetailsInWallet() { 646 bool AutofillDialogViews::SaveDetailsInWallet() {
639 return notification_area_->CheckboxIsChecked(); 647 return notification_area_->CheckboxIsChecked();
640 } 648 }
641 649
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 // TODO(estade): add a view to contain the terms of service. 742 // TODO(estade): add a view to contain the terms of service.
735 return NULL; 743 return NULL;
736 } 744 }
737 745
738 bool AutofillDialogViews::Cancel() { 746 bool AutofillDialogViews::Cancel() {
739 controller_->OnCancel(); 747 controller_->OnCancel();
740 return true; 748 return true;
741 } 749 }
742 750
743 bool AutofillDialogViews::Accept() { 751 bool AutofillDialogViews::Accept() {
744 if (!ValidateForm()) 752 if (ValidateForm())
745 return false; 753 controller_->OnAccept();
746 754
747 controller_->OnSubmit(); 755 // |controller_| decides when to hide the dialog.
748
749 // Let |controller_| decide when to hide the dialog.
750 return false; 756 return false;
751 } 757 }
752 758
753 // TODO(wittman): Remove this override once we move to the new style frame view 759 // TODO(wittman): Remove this override once we move to the new style frame view
754 // on all dialogs. 760 // on all dialogs.
755 views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView( 761 views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView(
756 views::Widget* widget) { 762 views::Widget* widget) {
757 return CreateConstrainedStyleNonClientFrameView( 763 return CreateConstrainedStyleNonClientFrameView(
758 widget, 764 widget,
759 controller_->web_contents()->GetBrowserContext()); 765 controller_->web_contents()->GetBrowserContext());
(...skipping 10 matching lines...) Expand all
770 DetailsGroup* group = NULL; 776 DetailsGroup* group = NULL;
771 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 777 for (DetailGroupMap::iterator iter = detail_groups_.begin();
772 iter != detail_groups_.end(); ++iter) { 778 iter != detail_groups_.end(); ++iter) {
773 if (sender == iter->second.suggested_button) { 779 if (sender == iter->second.suggested_button) {
774 group = &iter->second; 780 group = &iter->second;
775 break; 781 break;
776 } 782 }
777 } 783 }
778 DCHECK(group); 784 DCHECK(group);
779 785
786 if (!group->suggested_button->visible())
787 return;
788
780 views::MenuModelAdapter adapter( 789 views::MenuModelAdapter adapter(
781 controller_->MenuModelForSection(group->section)); 790 controller_->MenuModelForSection(group->section));
782 menu_runner_.reset(new views::MenuRunner(adapter.CreateMenu())); 791 menu_runner_.reset(new views::MenuRunner(adapter.CreateMenu()));
783 792
784 group->container->SetActive(true); 793 group->container->SetActive(true);
785 // Ignore the result since we don't need to handle a deleted menu specially. 794 // Ignore the result since we don't need to handle a deleted menu specially.
786 ignore_result( 795 ignore_result(
787 menu_runner_->RunMenuAt(sender->GetWidget(), 796 menu_runner_->RunMenuAt(sender->GetWidget(),
788 NULL, 797 NULL,
789 group->suggested_button->GetBoundsInScreen(), 798 group->suggested_button->GetBoundsInScreen(),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 } 832 }
824 833
825 void AutofillDialogViews::OnDidChangeFocus( 834 void AutofillDialogViews::OnDidChangeFocus(
826 views::View* focused_before, 835 views::View* focused_before,
827 views::View* focused_now) { 836 views::View* focused_now) {
828 if (!focused_before) 837 if (!focused_before)
829 return; 838 return;
830 839
831 // If user leaves an edit-field, revalidate the group it belongs to. 840 // If user leaves an edit-field, revalidate the group it belongs to.
832 DetailsGroup* group = GroupForView(focused_before); 841 DetailsGroup* group = GroupForView(focused_before);
833 if (group) 842 if (group && group->container->visible())
834 ValidateGroup(group, AutofillDialogController::VALIDATE_EDIT); 843 ValidateGroup(group, AutofillDialogController::VALIDATE_EDIT);
835 } 844 }
836 845
837 void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) { 846 void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) {
838 // Edit links. 847 // Edit links.
839 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 848 for (DetailGroupMap::iterator iter = detail_groups_.begin();
840 iter != detail_groups_.end(); ++iter) { 849 iter != detail_groups_.end(); ++iter) {
841 if (iter->second.suggested_info->Contains(source)) { 850 if (iter->second.suggested_info->Contains(source)) {
842 controller_->EditClickedForSection(iter->first); 851 controller_->EditClickedForSection(iter->first);
843 return; 852 return;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 0); 965 0);
957 column_set->AddColumn(views::GridLayout::CENTER, 966 column_set->AddColumn(views::GridLayout::CENTER,
958 views::GridLayout::LEADING, 967 views::GridLayout::LEADING,
959 0, 968 0,
960 views::GridLayout::USE_PREF, 969 views::GridLayout::USE_PREF,
961 0, 970 0,
962 0); 971 0);
963 layout->StartRow(0, kColumnSetId); 972 layout->StartRow(0, kColumnSetId);
964 973
965 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the 974 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the
966 // dialog toggle which is shown. 975 // dialog to toggle which is shown.
967 views::View* info_view = new views::View(); 976 views::View* info_view = new views::View();
968 info_view->SetLayoutManager( 977 info_view->SetLayoutManager(
969 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 978 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
970 979
971 if (section == SECTION_SHIPPING) { 980 if (section == SECTION_SHIPPING) {
972 use_billing_for_shipping_ = 981 use_billing_for_shipping_ =
973 new views::Checkbox(controller_->UseBillingForShippingText()); 982 new views::Checkbox(controller_->UseBillingForShippingText());
974 use_billing_for_shipping_->SetChecked(true); 983 use_billing_for_shipping_->SetChecked(true);
975 use_billing_for_shipping_->set_listener(this); 984 use_billing_for_shipping_->set_listener(this);
976 info_view->AddChildView(use_billing_for_shipping_); 985 info_view->AddChildView(use_billing_for_shipping_);
977 } 986 }
978 987
979 views::View* manual_inputs = InitInputsView(section); 988 views::View* manual_inputs = InitInputsView(section);
980 info_view->AddChildView(manual_inputs); 989 info_view->AddChildView(manual_inputs);
981 SuggestionView* suggested_info = 990 SuggestionView* suggested_info =
982 new SuggestionView(controller_->EditSuggestionText(), this); 991 new SuggestionView(controller_->EditSuggestionText(), this);
983 info_view->AddChildView(suggested_info); 992 info_view->AddChildView(suggested_info);
984 layout->AddView(info_view); 993 layout->AddView(info_view);
985 994
986 if (section == SECTION_CC) {
987 // TODO(estade): don't hardcode this string.
988 suggested_info->ShowTextfield(
989 ASCIIToUTF16("CVC"),
990 controller_->IconForField(CREDIT_CARD_VERIFICATION_CODE,
991 string16()).AsImageSkia());
992 }
993
994 // TODO(estade): Fix the appearance of this button. 995 // TODO(estade): Fix the appearance of this button.
995 views::ImageButton* menu_button = new views::ImageButton(this); 996 views::ImageButton* menu_button = new views::ImageButton(this);
996 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 997 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
997 menu_button->SetImage(views::CustomButton::STATE_NORMAL, 998 menu_button->SetImage(views::CustomButton::STATE_NORMAL,
998 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON)); 999 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON));
999 menu_button->SetImage(views::CustomButton::STATE_PRESSED, 1000 menu_button->SetImage(views::CustomButton::STATE_PRESSED,
1000 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON_P)); 1001 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON_P));
1001 layout->AddView(menu_button); 1002 layout->AddView(menu_button);
1002 1003
1003 DetailsGroup* group = GroupForSection(section); 1004 DetailsGroup* group = GroupForSection(section);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 1080
1080 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { 1081 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) {
1081 string16 suggestion_text = 1082 string16 suggestion_text =
1082 controller_->SuggestionTextForSection(group.section); 1083 controller_->SuggestionTextForSection(group.section);
1083 bool show_suggestions = !suggestion_text.empty(); 1084 bool show_suggestions = !suggestion_text.empty();
1084 group.suggested_info->SetVisible(show_suggestions); 1085 group.suggested_info->SetVisible(show_suggestions);
1085 group.suggested_info->SetSuggestionText(suggestion_text); 1086 group.suggested_info->SetSuggestionText(suggestion_text);
1086 gfx::Image icon = controller_->SuggestionIconForSection(group.section); 1087 gfx::Image icon = controller_->SuggestionIconForSection(group.section);
1087 group.suggested_info->SetSuggestionIcon(icon); 1088 group.suggested_info->SetSuggestionIcon(icon);
1088 1089
1090 if (group.section == SECTION_CC ||
1091 (group.section == SECTION_CC_BILLING &&
1092 controller_->IsSubmitPausedOn(wallet::VERIFY_CVV))) {
Evan Stade 2013/03/29 20:50:08 I think this logic should move to the controller.
Dan Beam 2013/03/29 21:00:32 talking with estade@ we actually want a suggestion
Dan Beam 2013/03/29 23:50:10 Done.
1093 // TODO(estade): don't hardcode this string.
1094 group.suggested_info->ShowTextfield(
1095 ASCIIToUTF16("CVC"),
1096 controller_->IconForField(CREDIT_CARD_VERIFICATION_CODE,
1097 string16()).AsImageSkia());
1098 }
1099
1089 if (group.section == SECTION_SHIPPING) { 1100 if (group.section == SECTION_SHIPPING) {
1090 bool show_checkbox = !show_suggestions; 1101 bool show_checkbox = !show_suggestions;
1091 // When the checkbox is going from hidden to visible, it's because the 1102 // When the checkbox is going from hidden to visible, it's because the
1092 // user clicked "Enter new address". Reset the checkbox to unchecked in this 1103 // user clicked "Enter new address". Reset the checkbox to unchecked in this
1093 // case. 1104 // case.
1094 if (show_checkbox && !use_billing_for_shipping_->visible()) 1105 if (show_checkbox && !use_billing_for_shipping_->visible())
1095 use_billing_for_shipping_->SetChecked(false); 1106 use_billing_for_shipping_->SetChecked(false);
1096 1107
1097 use_billing_for_shipping_->SetVisible(show_checkbox); 1108 use_billing_for_shipping_->SetVisible(show_checkbox);
1098 group.manual_input->SetVisible( 1109 group.manual_input->SetVisible(
1099 show_checkbox && !use_billing_for_shipping_->checked()); 1110 show_checkbox && !use_billing_for_shipping_->checked());
1100 } else { 1111 } else {
1101 group.manual_input->SetVisible(!show_suggestions); 1112 group.manual_input->SetVisible(!show_suggestions);
1102 } 1113 }
1103 1114
1104 // Show or hide the "Save in chrome" checkbox. If nothing is in editing mode, 1115 // Show or hide the "Save in chrome" checkbox. If nothing is in editing mode,
1105 // hide. If the controller tells us not to show it, likewise hide. 1116 // hide. If the controller tells us not to show it, likewise hide.
1106 save_in_chrome_checkbox_->SetVisible( 1117 save_in_chrome_checkbox_->SetVisible(
1107 controller_->ShouldOfferToSaveInChrome() && AtLeastOneSectionIsEditing()); 1118 controller_->ShouldOfferToSaveInChrome() && AtLeastOneSectionIsEditing());
1108 1119
1120 const bool has_suggestions =
1121 controller_->MenuModelForSection(group.section)->GetItemCount() > 0;
1122
1123 if (group.suggested_button)
1124 group.suggested_button->SetVisible(has_suggestions);
1125
1126 if (group.suggested_info) {
1127 group.suggested_info->SetEditable(
1128 !controller_->IsSubmitPausedOn(wallet::VERIFY_CVV));
1129 }
1130
1109 if (group.container) { 1131 if (group.container) {
1110 group.container->SetForwardMouseEvents(show_suggestions); 1132 group.container->SetForwardMouseEvents(has_suggestions && show_suggestions);
1111 group.container->SetVisible(controller_->SectionIsActive(group.section)); 1133 group.container->SetVisible(controller_->SectionIsActive(group.section));
1112 } 1134 }
1113 1135
1114 ContentsPreferredSizeChanged(); 1136 ContentsPreferredSizeChanged();
1115 } 1137 }
1116 1138
1117 bool AutofillDialogViews::AtLeastOneSectionIsEditing() { 1139 bool AutofillDialogViews::AtLeastOneSectionIsEditing() {
1118 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 1140 for (DetailGroupMap::iterator iter = detail_groups_.begin();
1119 iter != detail_groups_.end(); ++iter) { 1141 iter != detail_groups_.end(); ++iter) {
1120 if (iter->second.manual_input && iter->second.manual_input->visible()) 1142 if (iter->second.manual_input && iter->second.manual_input->visible())
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 } 1203 }
1182 1204
1183 bool AutofillDialogViews::ValidateForm() { 1205 bool AutofillDialogViews::ValidateForm() {
1184 bool all_valid = true; 1206 bool all_valid = true;
1185 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 1207 for (DetailGroupMap::iterator iter = detail_groups_.begin();
1186 iter != detail_groups_.end(); ++iter) { 1208 iter != detail_groups_.end(); ++iter) {
1187 DetailsGroup* group = &iter->second; 1209 DetailsGroup* group = &iter->second;
1188 if (!group->container->visible()) 1210 if (!group->container->visible())
1189 continue; 1211 continue;
1190 1212
1191 if (!ValidateGroup(group, AutofillDialogController::VALIDATE_FINAL)) 1213 if (!ValidateGroup(group, AutofillDialogController::VALIDATE_FINAL))
1192 all_valid = false; 1214 all_valid = false;
1193 } 1215 }
1194 1216
1195 return all_valid; 1217 return all_valid;
1196 } 1218 }
1197 1219
1198 void AutofillDialogViews::TextfieldEditedOrActivated( 1220 void AutofillDialogViews::TextfieldEditedOrActivated(
1199 views::Textfield* textfield, 1221 views::Textfield* textfield,
1200 bool was_edit) { 1222 bool was_edit) {
1201 DetailsGroup* group = GroupForView(textfield); 1223 DetailsGroup* group = GroupForView(textfield);
1202 DCHECK(group); 1224 DCHECK(group);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 1308 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
1287 : section(section), 1309 : section(section),
1288 container(NULL), 1310 container(NULL),
1289 manual_input(NULL), 1311 manual_input(NULL),
1290 suggested_info(NULL), 1312 suggested_info(NULL),
1291 suggested_button(NULL) {} 1313 suggested_button(NULL) {}
1292 1314
1293 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 1315 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
1294 1316
1295 } // namespace autofill 1317 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698