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

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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 arrow_centering_anchor_.get(); 306 arrow_centering_anchor_.get();
306 } 307 }
307 308
308 // AutofillDialogViews::SectionContainer --------------------------------------- 309 // AutofillDialogViews::SectionContainer ---------------------------------------
309 310
310 AutofillDialogViews::SectionContainer::SectionContainer( 311 AutofillDialogViews::SectionContainer::SectionContainer(
311 const string16& label, 312 const string16& label,
312 views::View* controls, 313 views::View* controls,
313 views::Button* proxy_button) 314 views::Button* proxy_button)
314 : proxy_button_(proxy_button), 315 : proxy_button_(proxy_button),
315 forward_mouse_events_(false) { 316 forward_mouse_events_(false),
317 active_(false) {
316 set_notify_enter_exit_on_child(true); 318 set_notify_enter_exit_on_child(true);
317 319
318 views::GridLayout* layout = new views::GridLayout(this); 320 views::GridLayout* layout = new views::GridLayout(this);
319 SetLayoutManager(layout); 321 SetLayoutManager(layout);
320 322
321 const int kColumnSetId = 0; 323 const int kColumnSetId = 0;
322 views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId); 324 views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId);
323 // TODO(estade): pull out these constants, and figure out better values 325 // TODO(estade): pull out these constants, and figure out better values
324 // for them. 326 // for them.
325 column_set->AddColumn(views::GridLayout::FILL, 327 column_set->AddColumn(views::GridLayout::FILL,
(...skipping 18 matching lines...) Expand all
344 AutofillDialogViews::SectionContainer::~SectionContainer() {} 346 AutofillDialogViews::SectionContainer::~SectionContainer() {}
345 347
346 void AutofillDialogViews::SectionContainer::SetForwardMouseEvents( 348 void AutofillDialogViews::SectionContainer::SetForwardMouseEvents(
347 bool forward) { 349 bool forward) {
348 forward_mouse_events_ = forward; 350 forward_mouse_events_ = forward;
349 if (!forward) 351 if (!forward)
350 set_background(NULL); 352 set_background(NULL);
351 } 353 }
352 354
353 void AutofillDialogViews::SectionContainer::SetActive(bool active) { 355 void AutofillDialogViews::SectionContainer::SetActive(bool active) {
354 if (active == !!background()) 356 active_ = active && proxy_button_->visible();
357 if (active_ == !!background())
355 return; 358 return;
356 359
357 set_background(active ? 360 set_background(active_ ?
358 // TODO(estade): use the correct color. 361 // TODO(estade): use the correct color.
359 views::Background::CreateSolidBackground(SK_ColorLTGRAY): 362 views::Background::CreateSolidBackground(SK_ColorLTGRAY):
360 NULL); 363 NULL);
361 SchedulePaint(); 364 SchedulePaint();
362 } 365 }
363 366
367 void AutofillDialogViews::SectionContainer::Refresh() {
368 SetActive(active_);
369 }
370
364 void AutofillDialogViews::SectionContainer::OnMouseMoved( 371 void AutofillDialogViews::SectionContainer::OnMouseMoved(
365 const ui::MouseEvent& event) { 372 const ui::MouseEvent& event) {
366 if (!forward_mouse_events_) 373 if (!forward_mouse_events_)
367 return; 374 return;
368 375
369 SetActive(true); 376 SetActive(true);
370 } 377 }
371 378
372 void AutofillDialogViews::SectionContainer::OnMouseEntered( 379 void AutofillDialogViews::SectionContainer::OnMouseEntered(
373 const ui::MouseEvent& event) { 380 const ui::MouseEvent& event) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // AutofilDialogViews::SuggestionView ------------------------------------------ 423 // AutofilDialogViews::SuggestionView ------------------------------------------
417 424
418 AutofillDialogViews::SuggestionView::SuggestionView( 425 AutofillDialogViews::SuggestionView::SuggestionView(
419 const string16& edit_label, 426 const string16& edit_label,
420 AutofillDialogViews* autofill_dialog) 427 AutofillDialogViews* autofill_dialog)
421 : label_(new views::Label()), 428 : label_(new views::Label()),
422 label_line_2_(new views::Label()), 429 label_line_2_(new views::Label()),
423 icon_(new views::ImageView()), 430 icon_(new views::ImageView()),
424 label_container_(new views::View()), 431 label_container_(new views::View()),
425 decorated_( 432 decorated_(
426 new DecoratedTextfield(string16(), string16(), autofill_dialog)) { 433 new DecoratedTextfield(string16(), string16(), autofill_dialog)),
434 edit_link_(new views::Link(edit_label)) {
427 // Label and icon. 435 // Label and icon.
428 label_container_->SetLayoutManager( 436 label_container_->SetLayoutManager(
429 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 437 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
430 kAroundTextPadding)); 438 kAroundTextPadding));
431 label_container_->AddChildView(icon_); 439 label_container_->AddChildView(icon_);
432 label_container_->AddChildView(label_); 440 label_container_->AddChildView(label_);
433 label_container_->AddChildView(decorated_); 441 label_container_->AddChildView(decorated_);
434 decorated_->SetVisible(false); 442 decorated_->SetVisible(false);
435 // TODO(estade): get the sizing and spacing right on this textfield. 443 // TODO(estade): get the sizing and spacing right on this textfield.
436 decorated_->textfield()->set_default_width_in_chars(10); 444 decorated_->textfield()->set_default_width_in_chars(10);
437 AddChildView(label_container_); 445 AddChildView(label_container_);
438 446
439 label_line_2_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 447 label_line_2_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
440 label_line_2_->SetVisible(false); 448 label_line_2_->SetVisible(false);
441 AddChildView(label_line_2_); 449 AddChildView(label_line_2_);
442 450
443 // TODO(estade): The link needs to have a different color when hovered. 451 // TODO(estade): The link needs to have a different color when hovered.
444 views::Link* edit_link = new views::Link(edit_label); 452 edit_link_->set_listener(autofill_dialog);
445 edit_link->set_listener(autofill_dialog); 453 edit_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
446 edit_link->SetHorizontalAlignment(gfx::ALIGN_LEFT); 454 edit_link_->SetUnderline(false);
447 edit_link->SetUnderline(false);
448 455
449 // This container prevents the edit link from being horizontally stretched. 456 // This container prevents the edit link from being horizontally stretched.
450 views::View* link_container = new views::View(); 457 views::View* link_container = new views::View();
451 link_container->SetLayoutManager( 458 link_container->SetLayoutManager(
452 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 459 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
453 link_container->AddChildView(edit_link); 460 link_container->AddChildView(edit_link_);
454 AddChildView(link_container); 461 AddChildView(link_container);
455 462
456 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 463 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
457 } 464 }
458 465
459 AutofillDialogViews::SuggestionView::~SuggestionView() {} 466 AutofillDialogViews::SuggestionView::~SuggestionView() {}
460 467
468 void AutofillDialogViews::SuggestionView::SetEditable(bool editable) {
469 edit_link_->SetVisible(editable);
470 }
471
461 void AutofillDialogViews::SuggestionView::SetSuggestionText( 472 void AutofillDialogViews::SuggestionView::SetSuggestionText(
462 const string16& text) { 473 const string16& text) {
463 // TODO(estade): does this localize well? 474 // TODO(estade): does this localize well?
464 string16 line_return(ASCIIToUTF16("\n")); 475 string16 line_return(ASCIIToUTF16("\n"));
465 size_t position = text.find(line_return); 476 size_t position = text.find(line_return);
466 if (position == string16::npos) { 477 if (position == string16::npos) {
467 label_->SetText(text); 478 label_->SetText(text);
468 label_line_2_->SetVisible(false); 479 label_line_2_->SetVisible(false);
469 } else { 480 } else {
470 label_->SetText(text.substr(0, position)); 481 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())); 631 output->insert(std::make_pair(it->first, it->second->textfield()->text()));
621 } 632 }
622 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); 633 for (ComboboxMap::const_iterator it = group->comboboxes.begin();
623 it != group->comboboxes.end(); ++it) { 634 it != group->comboboxes.end(); ++it) {
624 output->insert(std::make_pair(it->first, 635 output->insert(std::make_pair(it->first,
625 it->second->model()->GetItemAt(it->second->selected_index()))); 636 it->second->model()->GetItemAt(it->second->selected_index())));
626 } 637 }
627 } 638 }
628 639
629 string16 AutofillDialogViews::GetCvc() { 640 string16 AutofillDialogViews::GetCvc() {
630 return GroupForSection(SECTION_CC)->suggested_info->decorated_textfield()-> 641 DialogSection billing_section = controller_->SectionIsActive(SECTION_CC) ?
631 textfield()->text(); 642 SECTION_CC : SECTION_CC_BILLING;
643 return GroupForSection(billing_section)->suggested_info->
644 decorated_textfield()->textfield()->text();
632 } 645 }
633 646
634 bool AutofillDialogViews::UseBillingForShipping() { 647 bool AutofillDialogViews::UseBillingForShipping() {
635 return use_billing_for_shipping_->checked(); 648 return use_billing_for_shipping_->checked();
636 } 649 }
637 650
638 bool AutofillDialogViews::SaveDetailsInWallet() { 651 bool AutofillDialogViews::SaveDetailsInWallet() {
639 return notification_area_->CheckboxIsChecked(); 652 return notification_area_->CheckboxIsChecked();
640 } 653 }
641 654
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 // TODO(estade): add a view to contain the terms of service. 747 // TODO(estade): add a view to contain the terms of service.
735 return NULL; 748 return NULL;
736 } 749 }
737 750
738 bool AutofillDialogViews::Cancel() { 751 bool AutofillDialogViews::Cancel() {
739 controller_->OnCancel(); 752 controller_->OnCancel();
740 return true; 753 return true;
741 } 754 }
742 755
743 bool AutofillDialogViews::Accept() { 756 bool AutofillDialogViews::Accept() {
744 if (!ValidateForm()) 757 if (ValidateForm())
745 return false; 758 controller_->OnAccept();
746 759
747 controller_->OnSubmit(); 760 // |controller_| decides when to hide the dialog.
748
749 // Let |controller_| decide when to hide the dialog.
750 return false; 761 return false;
751 } 762 }
752 763
753 // TODO(wittman): Remove this override once we move to the new style frame view 764 // TODO(wittman): Remove this override once we move to the new style frame view
754 // on all dialogs. 765 // on all dialogs.
755 views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView( 766 views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView(
756 views::Widget* widget) { 767 views::Widget* widget) {
757 return CreateConstrainedStyleNonClientFrameView( 768 return CreateConstrainedStyleNonClientFrameView(
758 widget, 769 widget,
759 controller_->web_contents()->GetBrowserContext()); 770 controller_->web_contents()->GetBrowserContext());
(...skipping 10 matching lines...) Expand all
770 DetailsGroup* group = NULL; 781 DetailsGroup* group = NULL;
771 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 782 for (DetailGroupMap::iterator iter = detail_groups_.begin();
772 iter != detail_groups_.end(); ++iter) { 783 iter != detail_groups_.end(); ++iter) {
773 if (sender == iter->second.suggested_button) { 784 if (sender == iter->second.suggested_button) {
774 group = &iter->second; 785 group = &iter->second;
775 break; 786 break;
776 } 787 }
777 } 788 }
778 DCHECK(group); 789 DCHECK(group);
779 790
791 if (!group->suggested_button->visible())
792 return;
793
780 views::MenuModelAdapter adapter( 794 views::MenuModelAdapter adapter(
781 controller_->MenuModelForSection(group->section)); 795 controller_->MenuModelForSection(group->section));
782 menu_runner_.reset(new views::MenuRunner(adapter.CreateMenu())); 796 menu_runner_.reset(new views::MenuRunner(adapter.CreateMenu()));
783 797
784 group->container->SetActive(true); 798 group->container->SetActive(true);
785 // Ignore the result since we don't need to handle a deleted menu specially. 799 // Ignore the result since we don't need to handle a deleted menu specially.
786 ignore_result( 800 ignore_result(
787 menu_runner_->RunMenuAt(sender->GetWidget(), 801 menu_runner_->RunMenuAt(sender->GetWidget(),
788 NULL, 802 NULL,
789 group->suggested_button->GetBoundsInScreen(), 803 group->suggested_button->GetBoundsInScreen(),
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 0); 969 0);
956 column_set->AddColumn(views::GridLayout::CENTER, 970 column_set->AddColumn(views::GridLayout::CENTER,
957 views::GridLayout::LEADING, 971 views::GridLayout::LEADING,
958 0, 972 0,
959 views::GridLayout::USE_PREF, 973 views::GridLayout::USE_PREF,
960 0, 974 0,
961 0); 975 0);
962 layout->StartRow(0, kColumnSetId); 976 layout->StartRow(0, kColumnSetId);
963 977
964 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the 978 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the
965 // dialog toggle which is shown. 979 // dialog to toggle which is shown.
966 views::View* info_view = new views::View(); 980 views::View* info_view = new views::View();
967 info_view->SetLayoutManager( 981 info_view->SetLayoutManager(
968 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 982 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
969 983
970 if (section == SECTION_SHIPPING) { 984 if (section == SECTION_SHIPPING) {
971 use_billing_for_shipping_ = 985 use_billing_for_shipping_ =
972 new views::Checkbox(controller_->UseBillingForShippingText()); 986 new views::Checkbox(controller_->UseBillingForShippingText());
973 use_billing_for_shipping_->SetChecked(true); 987 use_billing_for_shipping_->SetChecked(true);
974 use_billing_for_shipping_->set_listener(this); 988 use_billing_for_shipping_->set_listener(this);
975 info_view->AddChildView(use_billing_for_shipping_); 989 info_view->AddChildView(use_billing_for_shipping_);
976 } 990 }
977 991
978 views::View* manual_inputs = InitInputsView(section); 992 views::View* manual_inputs = InitInputsView(section);
979 info_view->AddChildView(manual_inputs); 993 info_view->AddChildView(manual_inputs);
980 SuggestionView* suggested_info = 994 SuggestionView* suggested_info =
981 new SuggestionView(controller_->EditSuggestionText(), this); 995 new SuggestionView(controller_->EditSuggestionText(), this);
982 info_view->AddChildView(suggested_info); 996 info_view->AddChildView(suggested_info);
983 layout->AddView(info_view); 997 layout->AddView(info_view);
984 998
985 if (section == SECTION_CC) {
986 // TODO(estade): don't hardcode this string.
987 suggested_info->ShowTextfield(
988 ASCIIToUTF16("CVC"),
989 controller_->IconForField(CREDIT_CARD_VERIFICATION_CODE,
990 string16()).AsImageSkia());
991 }
992
993 // TODO(estade): Fix the appearance of this button. 999 // TODO(estade): Fix the appearance of this button.
994 views::ImageButton* menu_button = new views::ImageButton(this); 1000 views::ImageButton* menu_button = new views::ImageButton(this);
995 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1001 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
996 menu_button->SetImage(views::CustomButton::STATE_NORMAL, 1002 menu_button->SetImage(views::CustomButton::STATE_NORMAL,
997 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON)); 1003 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON));
998 menu_button->SetImage(views::CustomButton::STATE_PRESSED, 1004 menu_button->SetImage(views::CustomButton::STATE_PRESSED,
999 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON_P)); 1005 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON_P));
1000 layout->AddView(menu_button); 1006 layout->AddView(menu_button);
1001 1007
1002 DetailsGroup* group = GroupForSection(section); 1008 DetailsGroup* group = GroupForSection(section);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1084
1079 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { 1085 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) {
1080 string16 suggestion_text = 1086 string16 suggestion_text =
1081 controller_->SuggestionTextForSection(group.section); 1087 controller_->SuggestionTextForSection(group.section);
1082 bool show_suggestions = !suggestion_text.empty(); 1088 bool show_suggestions = !suggestion_text.empty();
1083 group.suggested_info->SetVisible(show_suggestions); 1089 group.suggested_info->SetVisible(show_suggestions);
1084 group.suggested_info->SetSuggestionText(suggestion_text); 1090 group.suggested_info->SetSuggestionText(suggestion_text);
1085 gfx::Image icon = controller_->SuggestionIconForSection(group.section); 1091 gfx::Image icon = controller_->SuggestionIconForSection(group.section);
1086 group.suggested_info->SetSuggestionIcon(icon); 1092 group.suggested_info->SetSuggestionIcon(icon);
1087 1093
1094 if (group.section == SECTION_CC ||
1095 (group.section == SECTION_CC_BILLING &&
1096 controller_->IsSubmitPausedOn(wallet::VERIFY_CVV))) {
1097 // TODO(estade): don't hardcode this string.
1098 group.suggested_info->ShowTextfield(
1099 ASCIIToUTF16("CVC"),
1100 controller_->IconForField(CREDIT_CARD_VERIFICATION_CODE,
1101 string16()).AsImageSkia());
1102 }
1103
1088 if (group.section == SECTION_SHIPPING) { 1104 if (group.section == SECTION_SHIPPING) {
1089 bool show_checkbox = !show_suggestions; 1105 bool show_checkbox = !show_suggestions;
1090 // When the checkbox is going from hidden to visible, it's because the 1106 // When the checkbox is going from hidden to visible, it's because the
1091 // user clicked "Enter new address". Reset the checkbox to unchecked in this 1107 // user clicked "Enter new address". Reset the checkbox to unchecked in this
1092 // case. 1108 // case.
1093 if (show_checkbox && !use_billing_for_shipping_->visible()) 1109 if (show_checkbox && !use_billing_for_shipping_->visible())
1094 use_billing_for_shipping_->SetChecked(false); 1110 use_billing_for_shipping_->SetChecked(false);
1095 1111
1096 use_billing_for_shipping_->SetVisible(show_checkbox); 1112 use_billing_for_shipping_->SetVisible(show_checkbox);
1097 group.manual_input->SetVisible( 1113 group.manual_input->SetVisible(
1098 show_checkbox && !use_billing_for_shipping_->checked()); 1114 show_checkbox && !use_billing_for_shipping_->checked());
1099 } else { 1115 } else {
1100 group.manual_input->SetVisible(!show_suggestions); 1116 group.manual_input->SetVisible(!show_suggestions);
1101 } 1117 }
1102 1118
1103 // Show or hide the "Save in chrome" checkbox. If nothing is in editing mode, 1119 // Show or hide the "Save in chrome" checkbox. If nothing is in editing mode,
1104 // hide. If the controller tells us not to show it, likewise hide. 1120 // hide. If the controller tells us not to show it, likewise hide.
1105 save_in_chrome_checkbox_->SetVisible( 1121 save_in_chrome_checkbox_->SetVisible(
1106 controller_->ShouldOfferToSaveInChrome() && AtLeastOneSectionIsEditing()); 1122 controller_->ShouldOfferToSaveInChrome() && AtLeastOneSectionIsEditing());
1107 1123
1124 if (group.suggested_button) {
1125 group.suggested_button->SetVisible(
1126 controller_->MenuModelForSection(group.section)->GetItemCount() > 0);
1127 }
1128
1129 if (group.suggested_info) {
1130 group.suggested_info->SetEditable(
1131 !controller_->IsSubmitPausedOn(wallet::VERIFY_CVV));
1132 }
1133
1108 if (group.container) { 1134 if (group.container) {
1109 group.container->SetForwardMouseEvents(show_suggestions); 1135 group.container->SetForwardMouseEvents(show_suggestions);
1110 group.container->SetVisible(controller_->SectionIsActive(group.section)); 1136 group.container->SetVisible(controller_->SectionIsActive(group.section));
1137 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.
1111 } 1138 }
1112 1139
1113 ContentsPreferredSizeChanged(); 1140 ContentsPreferredSizeChanged();
1114 } 1141 }
1115 1142
1116 bool AutofillDialogViews::AtLeastOneSectionIsEditing() { 1143 bool AutofillDialogViews::AtLeastOneSectionIsEditing() {
1117 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 1144 for (DetailGroupMap::iterator iter = detail_groups_.begin();
1118 iter != detail_groups_.end(); ++iter) { 1145 iter != detail_groups_.end(); ++iter) {
1119 if (iter->second.manual_input && iter->second.manual_input->visible()) 1146 if (iter->second.manual_input && iter->second.manual_input->visible())
1120 return true; 1147 return true;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 1283 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
1257 : section(section), 1284 : section(section),
1258 container(NULL), 1285 container(NULL),
1259 manual_input(NULL), 1286 manual_input(NULL),
1260 suggested_info(NULL), 1287 suggested_info(NULL),
1261 suggested_button(NULL) {} 1288 suggested_button(NULL) {}
1262 1289
1263 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 1290 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
1264 1291
1265 } // namespace autofill 1292 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698