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

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

Issue 14425010: Handle expired Autofill credit cards in autofill dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 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"
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 834
835 void AutofillDialogViews::UpdateProgressBar(double value) { 835 void AutofillDialogViews::UpdateProgressBar(double value) {
836 autocheckout_progress_bar_->SetValue(value); 836 autocheckout_progress_bar_->SetValue(value);
837 } 837 }
838 838
839 void AutofillDialogViews::ModelChanged() { 839 void AutofillDialogViews::ModelChanged() {
840 menu_runner_.reset(); 840 menu_runner_.reset();
841 841
842 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 842 for (DetailGroupMap::iterator iter = detail_groups_.begin();
843 iter != detail_groups_.end(); ++iter) { 843 iter != detail_groups_.end(); ++iter) {
844 UpdateDetailsGroupState(iter->second); 844 UpdateDetailsGroupState(&iter->second);
845 } 845 }
846 } 846 }
847 847
848 TestableAutofillDialogView* AutofillDialogViews::GetTestableView() { 848 TestableAutofillDialogView* AutofillDialogViews::GetTestableView() {
849 return this; 849 return this;
850 } 850 }
851 851
852 void AutofillDialogViews::SubmitForTesting() { 852 void AutofillDialogViews::SubmitForTesting() {
853 Accept(); 853 Accept();
854 } 854 }
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 void AutofillDialogViews::CreateDetailsSection(DialogSection section) { 1170 void AutofillDialogViews::CreateDetailsSection(DialogSection section) {
1171 // Inputs container (manual inputs + combobox). 1171 // Inputs container (manual inputs + combobox).
1172 views::View* inputs_container = CreateInputsContainer(section); 1172 views::View* inputs_container = CreateInputsContainer(section);
1173 1173
1174 DetailsGroup* group = GroupForSection(section); 1174 DetailsGroup* group = GroupForSection(section);
1175 // Container (holds label + inputs). 1175 // Container (holds label + inputs).
1176 group->container = new SectionContainer( 1176 group->container = new SectionContainer(
1177 controller_->LabelForSection(section), 1177 controller_->LabelForSection(section),
1178 inputs_container, 1178 inputs_container,
1179 group->suggested_button); 1179 group->suggested_button);
1180 UpdateDetailsGroupState(*group); 1180 UpdateDetailsGroupState(group);
1181 } 1181 }
1182 1182
1183 views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) { 1183 views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) {
1184 views::View* inputs_container = new views::View(); 1184 views::View* inputs_container = new views::View();
1185 views::GridLayout* layout = new views::GridLayout(inputs_container); 1185 views::GridLayout* layout = new views::GridLayout(inputs_container);
1186 inputs_container->SetLayoutManager(layout); 1186 inputs_container->SetLayoutManager(layout);
1187 1187
1188 int kColumnSetId = 0; 1188 int kColumnSetId = 0;
1189 views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId); 1189 views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId);
1190 column_set->AddColumn(views::GridLayout::FILL, 1190 column_set->AddColumn(views::GridLayout::FILL,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 views::Combobox* combobox = combo_mapping->second; 1332 views::Combobox* combobox = combo_mapping->second;
1333 for (int i = 0; i < combobox->model()->GetItemCount(); ++i) { 1333 for (int i = 0; i < combobox->model()->GetItemCount(); ++i) {
1334 if (input.initial_value == combobox->model()->GetItemAt(i)) { 1334 if (input.initial_value == combobox->model()->GetItemAt(i)) {
1335 combobox->SetSelectedIndex(i); 1335 combobox->SetSelectedIndex(i);
1336 break; 1336 break;
1337 } 1337 }
1338 } 1338 }
1339 } 1339 }
1340 } 1340 }
1341 1341
1342 UpdateDetailsGroupState(*group); 1342 UpdateDetailsGroupState(group);
1343 if (group->container && group->container->visible())
1344 ValidateGroup(group, AutofillDialogController::VALIDATE_EDIT);
1345 } 1343 }
1346 1344
1347 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { 1345 void AutofillDialogViews::UpdateDetailsGroupState(DetailsGroup* group) {
1348 const SuggestionState& suggestion_state = 1346 const SuggestionState& suggestion_state =
1349 controller_->SuggestionStateForSection(group.section); 1347 controller_->SuggestionStateForSection(group->section);
1350 bool show_suggestions = !suggestion_state.text.empty(); 1348 bool show_suggestions = !suggestion_state.text.empty();
1351 group.suggested_info->SetVisible(show_suggestions); 1349 group->suggested_info->SetVisible(show_suggestions);
1352 group.suggested_info->SetSuggestionText(suggestion_state.text, 1350 group->suggested_info->SetSuggestionText(suggestion_state.text,
1353 suggestion_state.text_style); 1351 suggestion_state.text_style);
1354 group.suggested_info->SetSuggestionIcon(suggestion_state.icon); 1352 group->suggested_info->SetSuggestionIcon(suggestion_state.icon);
1355 group.suggested_info->SetEditable(suggestion_state.editable); 1353 group->suggested_info->SetEditable(suggestion_state.editable);
1356 1354
1357 if (!suggestion_state.extra_text.empty()) { 1355 if (!suggestion_state.extra_text.empty()) {
1358 group.suggested_info->ShowTextfield( 1356 group->suggested_info->ShowTextfield(
1359 suggestion_state.extra_text, 1357 suggestion_state.extra_text,
1360 suggestion_state.extra_icon.AsImageSkia()); 1358 suggestion_state.extra_icon.AsImageSkia());
1361 } 1359 }
1362 1360
1363 group.manual_input->SetVisible(!show_suggestions); 1361 group->manual_input->SetVisible(!show_suggestions);
1364 1362
1365 // Show or hide the "Save in chrome" checkbox. If nothing is in editing mode, 1363 // Show or hide the "Save in chrome" checkbox. If nothing is in editing mode,
1366 // hide. If the controller tells us not to show it, likewise hide. 1364 // hide. If the controller tells us not to show it, likewise hide.
1367 save_in_chrome_checkbox_->SetVisible( 1365 save_in_chrome_checkbox_->SetVisible(
1368 controller_->ShouldOfferToSaveInChrome()); 1366 controller_->ShouldOfferToSaveInChrome());
1369 1367
1370 const bool has_suggestions = 1368 const bool has_menu =
1371 controller_->MenuModelForSection(group.section)->GetItemCount() > 0; 1369 controller_->MenuModelForSection(group->section)->GetItemCount() > 0;
1372 1370
1373 if (group.suggested_button) 1371 if (group->suggested_button)
1374 group.suggested_button->SetVisible(has_suggestions); 1372 group->suggested_button->SetVisible(has_menu);
1375 1373
1376 if (group.container) { 1374 if (group->container) {
1377 group.container->SetForwardMouseEvents(has_suggestions && show_suggestions); 1375 group->container->SetForwardMouseEvents(has_menu && show_suggestions);
1378 group.container->SetVisible(controller_->SectionIsActive(group.section)); 1376 group->container->SetVisible(controller_->SectionIsActive(group->section));
1377 if (group->container->visible())
1378 ValidateGroup(group, AutofillDialogController::VALIDATE_EDIT);
1379 } 1379 }
1380 1380
1381 ContentsPreferredSizeChanged(); 1381 ContentsPreferredSizeChanged();
1382 } 1382 }
1383 1383
1384 bool AutofillDialogViews::ValidateGroup( 1384 bool AutofillDialogViews::ValidateGroup(
1385 DetailsGroup* group, 1385 DetailsGroup* group,
1386 AutofillDialogController::ValidationType validation_type) { 1386 AutofillDialogController::ValidationType validation_type) {
1387 DCHECK(group->container->visible()); 1387 DCHECK(group->container->visible());
1388 1388
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 1573 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
1574 : section(section), 1574 : section(section),
1575 container(NULL), 1575 container(NULL),
1576 manual_input(NULL), 1576 manual_input(NULL),
1577 suggested_info(NULL), 1577 suggested_info(NULL),
1578 suggested_button(NULL) {} 1578 suggested_button(NULL) {}
1579 1579
1580 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 1580 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
1581 1581
1582 } // namespace autofill 1582 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698