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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 15979002: Making credit card number un-editable in Wallet mode. (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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
index ce1a2d12eef334d1af7c0a85133a75cedf87bf0c..0fafc8c04f8a74df95d13800bed94ed1543b4e73 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -778,23 +778,27 @@ void AutofillDialogControllerImpl::EnsureLegalDocumentsText() {
void AutofillDialogControllerImpl::PrepareDetailInputsForSection(
DialogSection section) {
- // Reset all previously entered data and stop editing |section|.
- DetailInputs* inputs = MutableRequestedFieldsForSection(section);
- for (size_t i = 0; i < inputs->size(); ++i) {
- (*inputs)[i].initial_value.clear();
- }
section_editing_state_[section] = false;
+ scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section);
// If the chosen item in |model| yields an empty suggestion text, it is
// invalid. In this case, show the editing UI with invalid fields highlighted.
SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section);
if (IsASuggestionItemKey(model->GetItemKeyForCheckedItem()) &&
SuggestionTextForSection(section).empty()) {
- scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section);
- wrapper->FillInputs(MutableRequestedFieldsForSection(section));
section_editing_state_[section] = true;
}
+ // Reset all previously entered data and stop editing |section|.
+ DetailInputs* inputs = MutableRequestedFieldsForSection(section);
+ for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) {
+ it->initial_value.clear();
+ it->editable = InputIsEditable(*it, section);
+ }
+
+ if (wrapper && section_editing_state_[section])
+ wrapper->FillInputs(inputs);
+
if (view_)
view_->UpdateSection(section);
}
@@ -1080,8 +1084,14 @@ bool AutofillDialogControllerImpl::EditEnabledForSection(
void AutofillDialogControllerImpl::EditClickedForSection(
DialogSection section) {
scoped_ptr<DataModelWrapper> model = CreateWrapper(section);
- model->FillInputs(MutableRequestedFieldsForSection(section));
section_editing_state_[section] = true;
+
+ DetailInputs* inputs = MutableRequestedFieldsForSection(section);
+ for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) {
+ it->editable = InputIsEditable(*it, section);
+ }
+ model->FillInputs(inputs);
+
view_->UpdateSection(section);
GetMetricLogger().LogDialogUiEvent(
@@ -2361,6 +2371,20 @@ bool AutofillDialogControllerImpl::IsManuallyEditingAnySection() const {
return false;
}
+bool AutofillDialogControllerImpl::InputIsEditable(
+ const DetailInput& input,
+ DialogSection section) const {
+ if (input.type != CREDIT_CARD_NUMBER || !IsPayingWithWallet())
+ return true;
+
+ std::map<DialogSection, bool>::const_iterator it =
+ section_editing_state_.find(section);
+ if (it != section_editing_state_.end() && it->second)
+ return false;
+
+ return true;
+}
+
bool AutofillDialogControllerImpl::AllSectionsAreValid() const {
for (size_t section = SECTION_MIN; section <= SECTION_MAX; ++section) {
if (!SectionIsValid(static_cast<DialogSection>(section)))
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller_impl.h ('k') | chrome/browser/ui/autofill/autofill_dialog_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698