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

Side by Side 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, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/autofill/autofill_dialog_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 for (size_t i = 0; i < documents.size(); ++i) { 771 for (size_t i = 0; i < documents.size(); ++i) {
772 size_t link_start = text.find(documents[i]->display_name()); 772 size_t link_start = text.find(documents[i]->display_name());
773 legal_document_link_ranges_.push_back(ui::Range( 773 legal_document_link_ranges_.push_back(ui::Range(
774 link_start, link_start + documents[i]->display_name().size())); 774 link_start, link_start + documents[i]->display_name().size()));
775 } 775 }
776 legal_documents_text_ = text; 776 legal_documents_text_ = text;
777 } 777 }
778 778
779 void AutofillDialogControllerImpl::PrepareDetailInputsForSection( 779 void AutofillDialogControllerImpl::PrepareDetailInputsForSection(
780 DialogSection section) { 780 DialogSection section) {
781 // Reset all previously entered data and stop editing |section|.
782 DetailInputs* inputs = MutableRequestedFieldsForSection(section);
783 for (size_t i = 0; i < inputs->size(); ++i) {
784 (*inputs)[i].initial_value.clear();
785 }
786 section_editing_state_[section] = false; 781 section_editing_state_[section] = false;
782 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section);
787 783
788 // If the chosen item in |model| yields an empty suggestion text, it is 784 // If the chosen item in |model| yields an empty suggestion text, it is
789 // invalid. In this case, show the editing UI with invalid fields highlighted. 785 // invalid. In this case, show the editing UI with invalid fields highlighted.
790 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); 786 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section);
791 if (IsASuggestionItemKey(model->GetItemKeyForCheckedItem()) && 787 if (IsASuggestionItemKey(model->GetItemKeyForCheckedItem()) &&
792 SuggestionTextForSection(section).empty()) { 788 SuggestionTextForSection(section).empty()) {
793 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section);
794 wrapper->FillInputs(MutableRequestedFieldsForSection(section));
795 section_editing_state_[section] = true; 789 section_editing_state_[section] = true;
796 } 790 }
797 791
792 // Reset all previously entered data and stop editing |section|.
793 DetailInputs* inputs = MutableRequestedFieldsForSection(section);
794 for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) {
795 it->initial_value.clear();
796 it->editable = InputIsEditable(*it, section);
797 }
798
799 if (wrapper && section_editing_state_[section])
800 wrapper->FillInputs(inputs);
801
798 if (view_) 802 if (view_)
799 view_->UpdateSection(section); 803 view_->UpdateSection(section);
800 } 804 }
801 805
802 const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( 806 const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection(
803 DialogSection section) const { 807 DialogSection section) const {
804 switch (section) { 808 switch (section) {
805 case SECTION_EMAIL: 809 case SECTION_EMAIL:
806 return requested_email_fields_; 810 return requested_email_fields_;
807 case SECTION_CC: 811 case SECTION_CC:
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 1077
1074 if (section == SECTION_CC_BILLING && IsSubmitPausedOn(wallet::VERIFY_CVV)) 1078 if (section == SECTION_CC_BILLING && IsSubmitPausedOn(wallet::VERIFY_CVV))
1075 return false; 1079 return false;
1076 1080
1077 return true; 1081 return true;
1078 } 1082 }
1079 1083
1080 void AutofillDialogControllerImpl::EditClickedForSection( 1084 void AutofillDialogControllerImpl::EditClickedForSection(
1081 DialogSection section) { 1085 DialogSection section) {
1082 scoped_ptr<DataModelWrapper> model = CreateWrapper(section); 1086 scoped_ptr<DataModelWrapper> model = CreateWrapper(section);
1083 model->FillInputs(MutableRequestedFieldsForSection(section));
1084 section_editing_state_[section] = true; 1087 section_editing_state_[section] = true;
1088
1089 DetailInputs* inputs = MutableRequestedFieldsForSection(section);
1090 for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) {
1091 it->editable = InputIsEditable(*it, section);
1092 }
1093 model->FillInputs(inputs);
1094
1085 view_->UpdateSection(section); 1095 view_->UpdateSection(section);
1086 1096
1087 GetMetricLogger().LogDialogUiEvent( 1097 GetMetricLogger().LogDialogUiEvent(
1088 GetDialogType(), DialogSectionToUiEditEvent(section)); 1098 GetDialogType(), DialogSectionToUiEditEvent(section));
1089 } 1099 }
1090 1100
1091 void AutofillDialogControllerImpl::EditCancelledForSection( 1101 void AutofillDialogControllerImpl::EditCancelledForSection(
1092 DialogSection section) { 1102 DialogSection section) {
1093 PrepareDetailInputsForSection(section); 1103 PrepareDetailInputsForSection(section);
1094 } 1104 }
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 } 2364 }
2355 2365
2356 bool AutofillDialogControllerImpl::IsManuallyEditingAnySection() const { 2366 bool AutofillDialogControllerImpl::IsManuallyEditingAnySection() const {
2357 for (size_t section = SECTION_MIN; section <= SECTION_MAX; ++section) { 2367 for (size_t section = SECTION_MIN; section <= SECTION_MAX; ++section) {
2358 if (IsManuallyEditingSection(static_cast<DialogSection>(section))) 2368 if (IsManuallyEditingSection(static_cast<DialogSection>(section)))
2359 return true; 2369 return true;
2360 } 2370 }
2361 return false; 2371 return false;
2362 } 2372 }
2363 2373
2374 bool AutofillDialogControllerImpl::InputIsEditable(
2375 const DetailInput& input,
2376 DialogSection section) const {
2377 if (input.type != CREDIT_CARD_NUMBER || !IsPayingWithWallet())
2378 return true;
2379
2380 std::map<DialogSection, bool>::const_iterator it =
2381 section_editing_state_.find(section);
2382 if (it != section_editing_state_.end() && it->second)
2383 return false;
2384
2385 return true;
2386 }
2387
2364 bool AutofillDialogControllerImpl::AllSectionsAreValid() const { 2388 bool AutofillDialogControllerImpl::AllSectionsAreValid() const {
2365 for (size_t section = SECTION_MIN; section <= SECTION_MAX; ++section) { 2389 for (size_t section = SECTION_MIN; section <= SECTION_MAX; ++section) {
2366 if (!SectionIsValid(static_cast<DialogSection>(section))) 2390 if (!SectionIsValid(static_cast<DialogSection>(section)))
2367 return false; 2391 return false;
2368 } 2392 }
2369 return true; 2393 return true;
2370 } 2394 }
2371 2395
2372 bool AutofillDialogControllerImpl::SectionIsValid( 2396 bool AutofillDialogControllerImpl::SectionIsValid(
2373 DialogSection section) const { 2397 DialogSection section) const {
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
2847 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; 2871 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL;
2848 } 2872 }
2849 2873
2850 // Has Wallet items. 2874 // Has Wallet items.
2851 return has_autofill_profiles ? 2875 return has_autofill_profiles ?
2852 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : 2876 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
2853 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; 2877 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
2854 } 2878 }
2855 2879
2856 } // namespace autofill 2880 } // namespace autofill
OLDNEW
« 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