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

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

Issue 13877016: Revert 195316 "Remove "Use billing for shipping" checkbox in fav..." (Closed) Base URL: svn://svn.chromium.org/chrome/
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
« no previous file with comments | « trunk/src/chrome/browser/ui/views/autofill/autofill_dialog_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 495 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
496 } 496 }
497 497
498 AutofillDialogViews::SuggestionView::~SuggestionView() {} 498 AutofillDialogViews::SuggestionView::~SuggestionView() {}
499 499
500 void AutofillDialogViews::SuggestionView::SetEditable(bool editable) { 500 void AutofillDialogViews::SuggestionView::SetEditable(bool editable) {
501 edit_link_->SetVisible(editable); 501 edit_link_->SetVisible(editable);
502 } 502 }
503 503
504 void AutofillDialogViews::SuggestionView::SetSuggestionText( 504 void AutofillDialogViews::SuggestionView::SetSuggestionText(
505 const string16& text, 505 const string16& text) {
506 gfx::Font::FontStyle text_style) {
507 label_->SetFont(ui::ResourceBundle::GetSharedInstance().GetFont(
508 ui::ResourceBundle::BaseFont).DeriveFont(0, text_style));
509
510 // TODO(estade): does this localize well? 506 // TODO(estade): does this localize well?
511 string16 line_return(ASCIIToUTF16("\n")); 507 string16 line_return(ASCIIToUTF16("\n"));
512 size_t position = text.find(line_return); 508 size_t position = text.find(line_return);
513 if (position == string16::npos) { 509 if (position == string16::npos) {
514 label_->SetText(text); 510 label_->SetText(text);
515 label_line_2_->SetVisible(false); 511 label_line_2_->SetVisible(false);
516 } else { 512 } else {
517 label_->SetText(text.substr(0, position)); 513 label_->SetText(text.substr(0, position));
518 label_line_2_->SetText(text.substr(position + line_return.length())); 514 label_line_2_->SetText(text.substr(position + line_return.length()));
519 label_line_2_->SetVisible(true); 515 label_line_2_->SetVisible(true);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 return new AutofillDialogViews(controller); 550 return new AutofillDialogViews(controller);
555 } 551 }
556 552
557 // AutofillDialogViews --------------------------------------------------------- 553 // AutofillDialogViews ---------------------------------------------------------
558 554
559 AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller) 555 AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller)
560 : controller_(controller), 556 : controller_(controller),
561 window_(NULL), 557 window_(NULL),
562 contents_(NULL), 558 contents_(NULL),
563 notification_area_(NULL), 559 notification_area_(NULL),
560 use_billing_for_shipping_(NULL),
564 account_chooser_(NULL), 561 account_chooser_(NULL),
565 sign_in_container_(NULL), 562 sign_in_container_(NULL),
566 cancel_sign_in_(NULL), 563 cancel_sign_in_(NULL),
567 sign_in_webview_(NULL), 564 sign_in_webview_(NULL),
568 main_container_(NULL), 565 main_container_(NULL),
569 details_container_(NULL), 566 details_container_(NULL),
570 button_strip_extra_view_(NULL), 567 button_strip_extra_view_(NULL),
571 save_in_chrome_checkbox_(NULL), 568 save_in_chrome_checkbox_(NULL),
572 autocheckout_progress_bar_view_(NULL), 569 autocheckout_progress_bar_view_(NULL),
573 autocheckout_progress_bar_(NULL), 570 autocheckout_progress_bar_(NULL),
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } 702 }
706 } 703 }
707 704
708 string16 AutofillDialogViews::GetCvc() { 705 string16 AutofillDialogViews::GetCvc() {
709 DialogSection billing_section = controller_->SectionIsActive(SECTION_CC) ? 706 DialogSection billing_section = controller_->SectionIsActive(SECTION_CC) ?
710 SECTION_CC : SECTION_CC_BILLING; 707 SECTION_CC : SECTION_CC_BILLING;
711 return GroupForSection(billing_section)->suggested_info-> 708 return GroupForSection(billing_section)->suggested_info->
712 decorated_textfield()->textfield()->text(); 709 decorated_textfield()->textfield()->text();
713 } 710 }
714 711
712 bool AutofillDialogViews::UseBillingForShipping() {
713 return use_billing_for_shipping_->checked();
714 }
715
715 bool AutofillDialogViews::SaveDetailsLocally() { 716 bool AutofillDialogViews::SaveDetailsLocally() {
716 return save_in_chrome_checkbox_->checked(); 717 return save_in_chrome_checkbox_->checked();
717 } 718 }
718 719
719 const content::NavigationController* AutofillDialogViews::ShowSignIn() { 720 const content::NavigationController* AutofillDialogViews::ShowSignIn() {
720 // TODO(abodenha) We should be able to use the WebContents of the WebView 721 // TODO(abodenha) We should be able to use the WebContents of the WebView
721 // to navigate instead of LoadInitialURL. Figure out why it doesn't work. 722 // to navigate instead of LoadInitialURL. Figure out why it doesn't work.
722 723
723 account_chooser_->SetSignInLinkEnabled(false); 724 account_chooser_->SetSignInLinkEnabled(false);
724 sign_in_webview_->LoadInitialURL(wallet::GetSignInUrl()); 725 sign_in_webview_->LoadInitialURL(wallet::GetSignInUrl());
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 kLegalDocPadding, 821 kLegalDocPadding,
821 kLegalDocPadding, 822 kLegalDocPadding,
822 0)); 823 0));
823 footnote_view_->set_border( 824 footnote_view_->set_border(
824 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor)); 825 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor));
825 footnote_view_->set_background( 826 footnote_view_->set_background(
826 views::Background::CreateSolidBackground(kShadingColor)); 827 views::Background::CreateSolidBackground(kShadingColor));
827 828
828 legal_document_view_ = new views::StyledLabel(string16(), this); 829 legal_document_view_ = new views::StyledLabel(string16(), this);
829 footnote_view_->AddChildView(legal_document_view_); 830 footnote_view_->AddChildView(legal_document_view_);
830 UpdateAccountChooser();
831 831
832 return footnote_view_; 832 return footnote_view_;
833 } 833 }
834 834
835 bool AutofillDialogViews::Cancel() { 835 bool AutofillDialogViews::Cancel() {
836 controller_->OnCancel(); 836 controller_->OnCancel();
837 return true; 837 return true;
838 } 838 }
839 839
840 bool AutofillDialogViews::Accept() { 840 bool AutofillDialogViews::Accept() {
841 if (ValidateForm()) 841 if (ValidateForm())
842 controller_->OnAccept(); 842 controller_->OnAccept();
843 843
844 // |controller_| decides when to hide the dialog. 844 // |controller_| decides when to hide the dialog.
845 return false; 845 return false;
846 } 846 }
847 847
848 // TODO(wittman): Remove this override once we move to the new style frame view 848 // TODO(wittman): Remove this override once we move to the new style frame view
849 // on all dialogs. 849 // on all dialogs.
850 views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView( 850 views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView(
851 views::Widget* widget) { 851 views::Widget* widget) {
852 return CreateConstrainedStyleNonClientFrameView( 852 return CreateConstrainedStyleNonClientFrameView(
853 widget, 853 widget,
854 controller_->web_contents()->GetBrowserContext()); 854 controller_->web_contents()->GetBrowserContext());
855 } 855 }
856 856
857 void AutofillDialogViews::ButtonPressed(views::Button* sender, 857 void AutofillDialogViews::ButtonPressed(views::Button* sender,
858 const ui::Event& event) { 858 const ui::Event& event) {
859 if (sender == cancel_sign_in_) { 859 if (sender == use_billing_for_shipping_) {
860 UpdateDetailsGroupState(*GroupForSection(SECTION_SHIPPING));
861 } else if (sender == cancel_sign_in_) {
860 controller_->EndSignInFlow(); 862 controller_->EndSignInFlow();
861 } else { 863 } else {
862 // TODO(estade): Should the menu be shown on mouse down? 864 // TODO(estade): Should the menu be shown on mouse down?
863 DetailsGroup* group = NULL; 865 DetailsGroup* group = NULL;
864 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 866 for (DetailGroupMap::iterator iter = detail_groups_.begin();
865 iter != detail_groups_.end(); ++iter) { 867 iter != detail_groups_.end(); ++iter) {
866 if (sender == iter->second.suggested_button) { 868 if (sender == iter->second.suggested_button) {
867 group = &iter->second; 869 group = &iter->second;
868 break; 870 break;
869 } 871 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 0, 1065 0,
1064 0); 1066 0);
1065 layout->StartRow(0, kColumnSetId); 1067 layout->StartRow(0, kColumnSetId);
1066 1068
1067 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the 1069 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the
1068 // dialog to toggle which is shown. 1070 // dialog to toggle which is shown.
1069 views::View* info_view = new views::View(); 1071 views::View* info_view = new views::View();
1070 info_view->SetLayoutManager( 1072 info_view->SetLayoutManager(
1071 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 1073 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
1072 1074
1075 if (section == SECTION_SHIPPING) {
1076 use_billing_for_shipping_ =
1077 new views::Checkbox(controller_->UseBillingForShippingText());
1078 use_billing_for_shipping_->SetChecked(true);
1079 use_billing_for_shipping_->set_listener(this);
1080 info_view->AddChildView(use_billing_for_shipping_);
1081 }
1082
1073 views::View* manual_inputs = InitInputsView(section); 1083 views::View* manual_inputs = InitInputsView(section);
1074 info_view->AddChildView(manual_inputs); 1084 info_view->AddChildView(manual_inputs);
1075 SuggestionView* suggested_info = 1085 SuggestionView* suggested_info =
1076 new SuggestionView(controller_->EditSuggestionText(), this); 1086 new SuggestionView(controller_->EditSuggestionText(), this);
1077 info_view->AddChildView(suggested_info); 1087 info_view->AddChildView(suggested_info);
1078 layout->AddView(info_view); 1088 layout->AddView(info_view);
1079 1089
1080 // TODO(estade): Fix the appearance of this button. 1090 // TODO(estade): Fix the appearance of this button.
1081 views::ImageButton* menu_button = new views::ImageButton(this); 1091 views::ImageButton* menu_button = new views::ImageButton(this);
1082 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1092 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 } 1176 }
1167 1177
1168 return view; 1178 return view;
1169 } 1179 }
1170 1180
1171 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { 1181 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) {
1172 const SuggestionState& suggestion_state = 1182 const SuggestionState& suggestion_state =
1173 controller_->SuggestionStateForSection(group.section); 1183 controller_->SuggestionStateForSection(group.section);
1174 bool show_suggestions = !suggestion_state.text.empty(); 1184 bool show_suggestions = !suggestion_state.text.empty();
1175 group.suggested_info->SetVisible(show_suggestions); 1185 group.suggested_info->SetVisible(show_suggestions);
1176 group.suggested_info->SetSuggestionText(suggestion_state.text, 1186 group.suggested_info->SetSuggestionText(suggestion_state.text);
1177 suggestion_state.text_style);
1178 group.suggested_info->SetSuggestionIcon(suggestion_state.icon); 1187 group.suggested_info->SetSuggestionIcon(suggestion_state.icon);
1179 group.suggested_info->SetEditable(suggestion_state.editable); 1188 group.suggested_info->SetEditable(suggestion_state.editable);
1180 1189
1181 if (!suggestion_state.extra_text.empty()) { 1190 if (!suggestion_state.extra_text.empty()) {
1182 group.suggested_info->ShowTextfield( 1191 group.suggested_info->ShowTextfield(
1183 suggestion_state.extra_text, 1192 suggestion_state.extra_text,
1184 suggestion_state.extra_icon.AsImageSkia()); 1193 suggestion_state.extra_icon.AsImageSkia());
1185 } 1194 }
1186 1195
1187 group.manual_input->SetVisible(!show_suggestions); 1196 if (group.section == SECTION_SHIPPING) {
1197 bool show_checkbox = !show_suggestions;
1198 // When the checkbox is going from hidden to visible, it's because the
1199 // user clicked "Enter new address". Reset the checkbox to unchecked in this
1200 // case.
1201 if (show_checkbox && !use_billing_for_shipping_->visible())
1202 use_billing_for_shipping_->SetChecked(false);
1203
1204 use_billing_for_shipping_->SetVisible(show_checkbox);
1205 group.manual_input->SetVisible(
1206 show_checkbox && !use_billing_for_shipping_->checked());
1207 } else {
1208 group.manual_input->SetVisible(!show_suggestions);
1209 }
1188 1210
1189 // Show or hide the "Save in chrome" checkbox. If nothing is in editing mode, 1211 // Show or hide the "Save in chrome" checkbox. If nothing is in editing mode,
1190 // hide. If the controller tells us not to show it, likewise hide. 1212 // hide. If the controller tells us not to show it, likewise hide.
1191 save_in_chrome_checkbox_->SetVisible( 1213 save_in_chrome_checkbox_->SetVisible(
1192 controller_->ShouldOfferToSaveInChrome()); 1214 controller_->ShouldOfferToSaveInChrome());
1193 1215
1194 const bool has_suggestions = 1216 const bool has_suggestions =
1195 controller_->MenuModelForSection(group.section)->GetItemCount() > 0; 1217 controller_->MenuModelForSection(group.section)->GetItemCount() > 0;
1196 1218
1197 if (group.suggested_button) 1219 if (group.suggested_button)
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 1388 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
1367 : section(section), 1389 : section(section),
1368 container(NULL), 1390 container(NULL),
1369 manual_input(NULL), 1391 manual_input(NULL),
1370 suggested_info(NULL), 1392 suggested_info(NULL),
1371 suggested_button(NULL) {} 1393 suggested_button(NULL) {}
1372 1394
1373 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 1395 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
1374 1396
1375 } // namespace autofill 1397 } // namespace autofill
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/ui/views/autofill/autofill_dialog_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698