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

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, 8 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 0); 341 0);
341 342
342 layout->StartRow(0, kColumnSetId); 343 layout->StartRow(0, kColumnSetId);
343 layout->AddView(CreateDetailsSectionLabel(label)); 344 layout->AddView(CreateDetailsSectionLabel(label));
344 layout->AddView(controls); 345 layout->AddView(controls);
345 } 346 }
346 347
347 AutofillDialogViews::SectionContainer::~SectionContainer() {} 348 AutofillDialogViews::SectionContainer::~SectionContainer() {}
348 349
349 void AutofillDialogViews::SectionContainer::SetActive(bool active) { 350 void AutofillDialogViews::SectionContainer::SetActive(bool active) {
350 if (active == !!background()) 351 bool is_active = active && proxy_button_->visible();
352 if (is_active == !!background())
351 return; 353 return;
352 354
353 set_background(active ? 355 set_background(is_active ?
354 views::Background::CreateSolidBackground(SkColorSetARGB(9, 0, 0, 0)): 356 views::Background::CreateSolidBackground(SkColorSetARGB(9, 0, 0, 0)):
355 NULL); 357 NULL);
356 SchedulePaint(); 358 SchedulePaint();
357 } 359 }
358 360
359 void AutofillDialogViews::SectionContainer::SetForwardMouseEvents( 361 void AutofillDialogViews::SectionContainer::SetForwardMouseEvents(
360 bool forward) { 362 bool forward) {
361 forward_mouse_events_ = forward; 363 forward_mouse_events_ = forward;
362 if (!forward) 364 if (!forward)
363 set_background(NULL); 365 set_background(NULL);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 // AutofilDialogViews::SuggestionView ------------------------------------------ 420 // AutofilDialogViews::SuggestionView ------------------------------------------
419 421
420 AutofillDialogViews::SuggestionView::SuggestionView( 422 AutofillDialogViews::SuggestionView::SuggestionView(
421 const string16& edit_label, 423 const string16& edit_label,
422 AutofillDialogViews* autofill_dialog) 424 AutofillDialogViews* autofill_dialog)
423 : label_(new views::Label()), 425 : label_(new views::Label()),
424 label_line_2_(new views::Label()), 426 label_line_2_(new views::Label()),
425 icon_(new views::ImageView()), 427 icon_(new views::ImageView()),
426 label_container_(new views::View()), 428 label_container_(new views::View()),
427 decorated_( 429 decorated_(
428 new DecoratedTextfield(string16(), string16(), autofill_dialog)) { 430 new DecoratedTextfield(string16(), string16(), autofill_dialog)),
431 edit_link_(new views::Link(edit_label)) {
429 // Label and icon. 432 // Label and icon.
430 label_container_->SetLayoutManager( 433 label_container_->SetLayoutManager(
431 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 434 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
432 kAroundTextPadding)); 435 kAroundTextPadding));
433 label_container_->AddChildView(icon_); 436 label_container_->AddChildView(icon_);
434 label_container_->AddChildView(label_); 437 label_container_->AddChildView(label_);
435 label_container_->AddChildView(decorated_); 438 label_container_->AddChildView(decorated_);
436 decorated_->SetVisible(false); 439 decorated_->SetVisible(false);
437 // TODO(estade): get the sizing and spacing right on this textfield. 440 // TODO(estade): get the sizing and spacing right on this textfield.
438 decorated_->textfield()->set_default_width_in_chars(10); 441 decorated_->textfield()->set_default_width_in_chars(10);
439 AddChildView(label_container_); 442 AddChildView(label_container_);
440 443
441 label_line_2_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 444 label_line_2_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
442 label_line_2_->SetVisible(false); 445 label_line_2_->SetVisible(false);
443 AddChildView(label_line_2_); 446 AddChildView(label_line_2_);
444 447
445 // TODO(estade): The link needs to have a different color when hovered. 448 // TODO(estade): The link needs to have a different color when hovered.
446 views::Link* edit_link = new views::Link(edit_label); 449 edit_link_->set_listener(autofill_dialog);
447 edit_link->set_listener(autofill_dialog); 450 edit_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
448 edit_link->SetHorizontalAlignment(gfx::ALIGN_LEFT); 451 edit_link_->SetUnderline(false);
449 edit_link->SetUnderline(false);
450 452
451 // This container prevents the edit link from being horizontally stretched. 453 // This container prevents the edit link from being horizontally stretched.
452 views::View* link_container = new views::View(); 454 views::View* link_container = new views::View();
453 link_container->SetLayoutManager( 455 link_container->SetLayoutManager(
454 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 456 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
455 link_container->AddChildView(edit_link); 457 link_container->AddChildView(edit_link_);
456 AddChildView(link_container); 458 AddChildView(link_container);
457 459
458 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 460 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
459 } 461 }
460 462
461 AutofillDialogViews::SuggestionView::~SuggestionView() {} 463 AutofillDialogViews::SuggestionView::~SuggestionView() {}
462 464
465 void AutofillDialogViews::SuggestionView::SetEditable(bool editable) {
466 edit_link_->SetVisible(editable);
467 }
468
463 void AutofillDialogViews::SuggestionView::SetSuggestionText( 469 void AutofillDialogViews::SuggestionView::SetSuggestionText(
464 const string16& text) { 470 const string16& text) {
465 // TODO(estade): does this localize well? 471 // TODO(estade): does this localize well?
466 string16 line_return(ASCIIToUTF16("\n")); 472 string16 line_return(ASCIIToUTF16("\n"));
467 size_t position = text.find(line_return); 473 size_t position = text.find(line_return);
468 if (position == string16::npos) { 474 if (position == string16::npos) {
469 label_->SetText(text); 475 label_->SetText(text);
470 label_line_2_->SetVisible(false); 476 label_line_2_->SetVisible(false);
471 } else { 477 } else {
472 label_->SetText(text.substr(0, position)); 478 label_->SetText(text.substr(0, position));
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 output->insert(std::make_pair(it->first, it->second->textfield()->text())); 642 output->insert(std::make_pair(it->first, it->second->textfield()->text()));
637 } 643 }
638 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); 644 for (ComboboxMap::const_iterator it = group->comboboxes.begin();
639 it != group->comboboxes.end(); ++it) { 645 it != group->comboboxes.end(); ++it) {
640 output->insert(std::make_pair(it->first, 646 output->insert(std::make_pair(it->first,
641 it->second->model()->GetItemAt(it->second->selected_index()))); 647 it->second->model()->GetItemAt(it->second->selected_index())));
642 } 648 }
643 } 649 }
644 650
645 string16 AutofillDialogViews::GetCvc() { 651 string16 AutofillDialogViews::GetCvc() {
646 return GroupForSection(SECTION_CC)->suggested_info->decorated_textfield()-> 652 DialogSection billing_section = controller_->SectionIsActive(SECTION_CC) ?
647 textfield()->text(); 653 SECTION_CC : SECTION_CC_BILLING;
654 return GroupForSection(billing_section)->suggested_info->
655 decorated_textfield()->textfield()->text();
648 } 656 }
649 657
650 bool AutofillDialogViews::UseBillingForShipping() { 658 bool AutofillDialogViews::UseBillingForShipping() {
651 return use_billing_for_shipping_->checked(); 659 return use_billing_for_shipping_->checked();
652 } 660 }
653 661
654 bool AutofillDialogViews::SaveDetailsInWallet() { 662 bool AutofillDialogViews::SaveDetailsInWallet() {
655 return notification_area_->CheckboxIsChecked(); 663 return notification_area_->CheckboxIsChecked();
656 } 664 }
657 665
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 footnote_view_ = new views::StyledLabel(string16(), this); 758 footnote_view_ = new views::StyledLabel(string16(), this);
751 return footnote_view_; 759 return footnote_view_;
752 } 760 }
753 761
754 bool AutofillDialogViews::Cancel() { 762 bool AutofillDialogViews::Cancel() {
755 controller_->OnCancel(); 763 controller_->OnCancel();
756 return true; 764 return true;
757 } 765 }
758 766
759 bool AutofillDialogViews::Accept() { 767 bool AutofillDialogViews::Accept() {
760 if (!ValidateForm()) 768 if (ValidateForm())
761 return false; 769 controller_->OnAccept();
762 770
763 controller_->OnSubmit(); 771 // |controller_| decides when to hide the dialog.
764
765 // Let |controller_| decide when to hide the dialog.
766 return false; 772 return false;
767 } 773 }
768 774
769 // TODO(wittman): Remove this override once we move to the new style frame view 775 // TODO(wittman): Remove this override once we move to the new style frame view
770 // on all dialogs. 776 // on all dialogs.
771 views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView( 777 views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView(
772 views::Widget* widget) { 778 views::Widget* widget) {
773 return CreateConstrainedStyleNonClientFrameView( 779 return CreateConstrainedStyleNonClientFrameView(
774 widget, 780 widget,
775 controller_->web_contents()->GetBrowserContext()); 781 controller_->web_contents()->GetBrowserContext());
(...skipping 10 matching lines...) Expand all
786 DetailsGroup* group = NULL; 792 DetailsGroup* group = NULL;
787 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 793 for (DetailGroupMap::iterator iter = detail_groups_.begin();
788 iter != detail_groups_.end(); ++iter) { 794 iter != detail_groups_.end(); ++iter) {
789 if (sender == iter->second.suggested_button) { 795 if (sender == iter->second.suggested_button) {
790 group = &iter->second; 796 group = &iter->second;
791 break; 797 break;
792 } 798 }
793 } 799 }
794 DCHECK(group); 800 DCHECK(group);
795 801
802 if (!group->suggested_button->visible())
803 return;
804
796 menu_runner_.reset(new views::MenuRunner( 805 menu_runner_.reset(new views::MenuRunner(
797 controller_->MenuModelForSection(group->section))); 806 controller_->MenuModelForSection(group->section)));
798 807
799 group->container->SetActive(true); 808 group->container->SetActive(true);
800 // Ignore the result since we don't need to handle a deleted menu specially. 809 // Ignore the result since we don't need to handle a deleted menu specially.
801 ignore_result( 810 ignore_result(
802 menu_runner_->RunMenuAt(sender->GetWidget(), 811 menu_runner_->RunMenuAt(sender->GetWidget(),
803 NULL, 812 NULL,
804 group->suggested_button->GetBoundsInScreen(), 813 group->suggested_button->GetBoundsInScreen(),
805 views::MenuItemView::TOPRIGHT, 814 views::MenuItemView::TOPRIGHT,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 } 847 }
839 848
840 void AutofillDialogViews::OnDidChangeFocus( 849 void AutofillDialogViews::OnDidChangeFocus(
841 views::View* focused_before, 850 views::View* focused_before,
842 views::View* focused_now) { 851 views::View* focused_now) {
843 if (!focused_before) 852 if (!focused_before)
844 return; 853 return;
845 854
846 // If user leaves an edit-field, revalidate the group it belongs to. 855 // If user leaves an edit-field, revalidate the group it belongs to.
847 DetailsGroup* group = GroupForView(focused_before); 856 DetailsGroup* group = GroupForView(focused_before);
848 if (group) 857 if (group && group->container->visible())
849 ValidateGroup(group, AutofillDialogController::VALIDATE_EDIT); 858 ValidateGroup(group, AutofillDialogController::VALIDATE_EDIT);
850 } 859 }
851 860
852 void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) { 861 void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) {
853 // Edit links. 862 // Edit links.
854 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 863 for (DetailGroupMap::iterator iter = detail_groups_.begin();
855 iter != detail_groups_.end(); ++iter) { 864 iter != detail_groups_.end(); ++iter) {
856 if (iter->second.suggested_info->Contains(source)) { 865 if (iter->second.suggested_info->Contains(source)) {
857 controller_->EditClickedForSection(iter->first); 866 controller_->EditClickedForSection(iter->first);
858 return; 867 return;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 0); 984 0);
976 column_set->AddColumn(views::GridLayout::CENTER, 985 column_set->AddColumn(views::GridLayout::CENTER,
977 views::GridLayout::LEADING, 986 views::GridLayout::LEADING,
978 0, 987 0,
979 views::GridLayout::USE_PREF, 988 views::GridLayout::USE_PREF,
980 0, 989 0,
981 0); 990 0);
982 layout->StartRow(0, kColumnSetId); 991 layout->StartRow(0, kColumnSetId);
983 992
984 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the 993 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the
985 // dialog toggle which is shown. 994 // dialog to toggle which is shown.
986 views::View* info_view = new views::View(); 995 views::View* info_view = new views::View();
987 info_view->SetLayoutManager( 996 info_view->SetLayoutManager(
988 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 997 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
989 998
990 if (section == SECTION_SHIPPING) { 999 if (section == SECTION_SHIPPING) {
991 use_billing_for_shipping_ = 1000 use_billing_for_shipping_ =
992 new views::Checkbox(controller_->UseBillingForShippingText()); 1001 new views::Checkbox(controller_->UseBillingForShippingText());
993 use_billing_for_shipping_->SetChecked(true); 1002 use_billing_for_shipping_->SetChecked(true);
994 use_billing_for_shipping_->set_listener(this); 1003 use_billing_for_shipping_->set_listener(this);
995 info_view->AddChildView(use_billing_for_shipping_); 1004 info_view->AddChildView(use_billing_for_shipping_);
996 } 1005 }
997 1006
998 views::View* manual_inputs = InitInputsView(section); 1007 views::View* manual_inputs = InitInputsView(section);
999 info_view->AddChildView(manual_inputs); 1008 info_view->AddChildView(manual_inputs);
1000 SuggestionView* suggested_info = 1009 SuggestionView* suggested_info =
1001 new SuggestionView(controller_->EditSuggestionText(), this); 1010 new SuggestionView(controller_->EditSuggestionText(), this);
1002 info_view->AddChildView(suggested_info); 1011 info_view->AddChildView(suggested_info);
1003 layout->AddView(info_view); 1012 layout->AddView(info_view);
1004 1013
1005 if (section == SECTION_CC) {
1006 // TODO(estade): don't hardcode this string.
1007 suggested_info->ShowTextfield(
1008 ASCIIToUTF16("CVC"),
1009 controller_->IconForField(CREDIT_CARD_VERIFICATION_CODE,
1010 string16()).AsImageSkia());
1011 }
1012
1013 // TODO(estade): Fix the appearance of this button. 1014 // TODO(estade): Fix the appearance of this button.
1014 views::ImageButton* menu_button = new views::ImageButton(this); 1015 views::ImageButton* menu_button = new views::ImageButton(this);
1015 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1016 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
1016 menu_button->SetImage(views::CustomButton::STATE_NORMAL, 1017 menu_button->SetImage(views::CustomButton::STATE_NORMAL,
1017 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON)); 1018 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON));
1018 menu_button->SetImage(views::CustomButton::STATE_PRESSED, 1019 menu_button->SetImage(views::CustomButton::STATE_PRESSED,
1019 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON_P)); 1020 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON_P));
1020 layout->AddView(menu_button); 1021 layout->AddView(menu_button);
1021 1022
1022 DetailsGroup* group = GroupForSection(section); 1023 DetailsGroup* group = GroupForSection(section);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 1091
1091 textfields->insert(std::make_pair(&input, field)); 1092 textfields->insert(std::make_pair(&input, field));
1092 layout->AddView(field); 1093 layout->AddView(field);
1093 } 1094 }
1094 } 1095 }
1095 1096
1096 return view; 1097 return view;
1097 } 1098 }
1098 1099
1099 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { 1100 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) {
1100 string16 suggestion_text = 1101 const SuggestionState& suggestion_state =
1101 controller_->SuggestionTextForSection(group.section); 1102 controller_->SuggestionStateForSection(group.section);
1102 bool show_suggestions = !suggestion_text.empty(); 1103 bool show_suggestions = !suggestion_state.text.empty();
1103 group.suggested_info->SetVisible(show_suggestions); 1104 group.suggested_info->SetVisible(show_suggestions);
1104 group.suggested_info->SetSuggestionText(suggestion_text); 1105 group.suggested_info->SetSuggestionText(suggestion_state.text);
1105 gfx::Image icon = controller_->SuggestionIconForSection(group.section); 1106 group.suggested_info->SetSuggestionIcon(suggestion_state.icon);
1106 group.suggested_info->SetSuggestionIcon(icon); 1107 group.suggested_info->SetEditable(suggestion_state.editable);
1108
1109 if (!suggestion_state.extra_text.empty()) {
1110 group.suggested_info->ShowTextfield(
1111 suggestion_state.extra_text,
1112 suggestion_state.extra_icon.AsImageSkia());
1113 }
1107 1114
1108 if (group.section == SECTION_SHIPPING) { 1115 if (group.section == SECTION_SHIPPING) {
1109 bool show_checkbox = !show_suggestions; 1116 bool show_checkbox = !show_suggestions;
1110 // When the checkbox is going from hidden to visible, it's because the 1117 // When the checkbox is going from hidden to visible, it's because the
1111 // user clicked "Enter new address". Reset the checkbox to unchecked in this 1118 // user clicked "Enter new address". Reset the checkbox to unchecked in this
1112 // case. 1119 // case.
1113 if (show_checkbox && !use_billing_for_shipping_->visible()) 1120 if (show_checkbox && !use_billing_for_shipping_->visible())
1114 use_billing_for_shipping_->SetChecked(false); 1121 use_billing_for_shipping_->SetChecked(false);
1115 1122
1116 use_billing_for_shipping_->SetVisible(show_checkbox); 1123 use_billing_for_shipping_->SetVisible(show_checkbox);
1117 group.manual_input->SetVisible( 1124 group.manual_input->SetVisible(
1118 show_checkbox && !use_billing_for_shipping_->checked()); 1125 show_checkbox && !use_billing_for_shipping_->checked());
1119 } else { 1126 } else {
1120 group.manual_input->SetVisible(!show_suggestions); 1127 group.manual_input->SetVisible(!show_suggestions);
1121 } 1128 }
1122 1129
1123 // Show or hide the "Save in chrome" checkbox. If nothing is in editing mode, 1130 // Show or hide the "Save in chrome" checkbox. If nothing is in editing mode,
1124 // hide. If the controller tells us not to show it, likewise hide. 1131 // hide. If the controller tells us not to show it, likewise hide.
1125 save_in_chrome_checkbox_->SetVisible( 1132 save_in_chrome_checkbox_->SetVisible(
1126 controller_->ShouldOfferToSaveInChrome() && AtLeastOneSectionIsEditing()); 1133 controller_->ShouldOfferToSaveInChrome() && AtLeastOneSectionIsEditing());
1127 1134
1135 const bool has_suggestions =
1136 controller_->MenuModelForSection(group.section)->GetItemCount() > 0;
1137
1138 if (group.suggested_button)
1139 group.suggested_button->SetVisible(has_suggestions);
1140
1128 if (group.container) { 1141 if (group.container) {
1129 group.container->SetForwardMouseEvents(show_suggestions); 1142 group.container->SetForwardMouseEvents(has_suggestions && show_suggestions);
1130 group.container->SetVisible(controller_->SectionIsActive(group.section)); 1143 group.container->SetVisible(controller_->SectionIsActive(group.section));
1131 } 1144 }
1132 1145
1133 ContentsPreferredSizeChanged(); 1146 ContentsPreferredSizeChanged();
1134 } 1147 }
1135 1148
1136 bool AutofillDialogViews::AtLeastOneSectionIsEditing() { 1149 bool AutofillDialogViews::AtLeastOneSectionIsEditing() {
1137 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 1150 for (DetailGroupMap::iterator iter = detail_groups_.begin();
1138 iter != detail_groups_.end(); ++iter) { 1151 iter != detail_groups_.end(); ++iter) {
1139 if (iter->second.manual_input && iter->second.manual_input->visible()) 1152 if (iter->second.manual_input && iter->second.manual_input->visible())
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 } 1213 }
1201 1214
1202 bool AutofillDialogViews::ValidateForm() { 1215 bool AutofillDialogViews::ValidateForm() {
1203 bool all_valid = true; 1216 bool all_valid = true;
1204 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 1217 for (DetailGroupMap::iterator iter = detail_groups_.begin();
1205 iter != detail_groups_.end(); ++iter) { 1218 iter != detail_groups_.end(); ++iter) {
1206 DetailsGroup* group = &iter->second; 1219 DetailsGroup* group = &iter->second;
1207 if (!group->container->visible()) 1220 if (!group->container->visible())
1208 continue; 1221 continue;
1209 1222
1210 if (!ValidateGroup(group, AutofillDialogController::VALIDATE_FINAL)) 1223 if (!ValidateGroup(group, AutofillDialogController::VALIDATE_FINAL))
1211 all_valid = false; 1224 all_valid = false;
1212 } 1225 }
1213 1226
1214 return all_valid; 1227 return all_valid;
1215 } 1228 }
1216 1229
1217 void AutofillDialogViews::TextfieldEditedOrActivated( 1230 void AutofillDialogViews::TextfieldEditedOrActivated(
1218 views::Textfield* textfield, 1231 views::Textfield* textfield,
1219 bool was_edit) { 1232 bool was_edit) {
1220 DetailsGroup* group = GroupForView(textfield); 1233 DetailsGroup* group = GroupForView(textfield);
1221 DCHECK(group); 1234 DCHECK(group);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 1318 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
1306 : section(section), 1319 : section(section),
1307 container(NULL), 1320 container(NULL),
1308 manual_input(NULL), 1321 manual_input(NULL),
1309 suggested_info(NULL), 1322 suggested_info(NULL),
1310 suggested_button(NULL) {} 1323 suggested_button(NULL) {}
1311 1324
1312 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 1325 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
1313 1326
1314 } // namespace autofill 1327 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698