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

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, 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 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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 legal_document_link_ranges_.push_back(ui::Range( 754 legal_document_link_ranges_.push_back(ui::Range(
755 link_start, link_start + documents[i]->display_name().size())); 755 link_start, link_start + documents[i]->display_name().size()));
756 } 756 }
757 legal_documents_text_ = text; 757 legal_documents_text_ = text;
758 } 758 }
759 759
760 void AutofillDialogControllerImpl::PrepareDetailInputsForSection( 760 void AutofillDialogControllerImpl::PrepareDetailInputsForSection(
761 DialogSection section) { 761 DialogSection section) {
762 // Reset all previously entered data and stop editing |section|. 762 // Reset all previously entered data and stop editing |section|.
763 DetailInputs* inputs = MutableRequestedFieldsForSection(section); 763 DetailInputs* inputs = MutableRequestedFieldsForSection(section);
764 for (size_t i = 0; i < inputs->size(); ++i) { 764 for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) {
765 (*inputs)[i].initial_value.clear(); 765 it->initial_value.clear();
766 it->enabled = InputIsEnabled(*it, section);
766 } 767 }
767 section_editing_state_[section] = false; 768 section_editing_state_[section] = false;
768 769
769 // If the chosen item in |model| yields an empty suggestion text, it is 770 // If the chosen item in |model| yields an empty suggestion text, it is
770 // invalid. In this case, show the editing UI with invalid fields highlighted. 771 // invalid. In this case, show the editing UI with invalid fields highlighted.
771 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); 772 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section);
772 if (IsASuggestionItemKey(model->GetItemKeyForCheckedItem()) && 773 if (IsASuggestionItemKey(model->GetItemKeyForCheckedItem()) &&
773 SuggestionTextForSection(section).empty()) { 774 SuggestionTextForSection(section).empty()) {
774 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); 775 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section);
775 wrapper->FillInputs(MutableRequestedFieldsForSection(section)); 776 wrapper->FillInputs(MutableRequestedFieldsForSection(section));
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 } 2255 }
2255 2256
2256 bool AutofillDialogControllerImpl::IsManuallyEditingAnySection() const { 2257 bool AutofillDialogControllerImpl::IsManuallyEditingAnySection() const {
2257 for (size_t section = SECTION_MIN; section <= SECTION_MAX; ++section) { 2258 for (size_t section = SECTION_MIN; section <= SECTION_MAX; ++section) {
2258 if (IsManuallyEditingSection(static_cast<DialogSection>(section))) 2259 if (IsManuallyEditingSection(static_cast<DialogSection>(section)))
2259 return true; 2260 return true;
2260 } 2261 }
2261 return false; 2262 return false;
2262 } 2263 }
2263 2264
2265 bool AutofillDialogControllerImpl::InputIsEnabled(const DetailInput& input,
2266 DialogSection section) const {
2267 return !(IsPayingWithWallet() &&
2268 input.type == CREDIT_CARD_NUMBER &&
2269 section_editing_state_[SECTION_CC_BILLING]);
2270 }
2271
2264 bool AutofillDialogControllerImpl::InputIsValid(AutofillFieldType type, 2272 bool AutofillDialogControllerImpl::InputIsValid(AutofillFieldType type,
2265 const string16& value) const { 2273 const string16& value) const {
2266 switch (AutofillType::GetEquivalentFieldType(type)) { 2274 switch (AutofillType::GetEquivalentFieldType(type)) {
2267 case EMAIL_ADDRESS: 2275 case EMAIL_ADDRESS:
2268 return IsValidEmailAddress(value); 2276 return IsValidEmailAddress(value);
2269 2277
2270 case CREDIT_CARD_NUMBER: 2278 case CREDIT_CARD_NUMBER:
2271 return autofill::IsValidCreditCardNumber(value); 2279 return autofill::IsValidCreditCardNumber(value);
2272 case CREDIT_CARD_NAME: 2280 case CREDIT_CARD_NAME:
2273 break; 2281 break;
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
2777 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; 2785 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL;
2778 } 2786 }
2779 2787
2780 // Has Wallet items. 2788 // Has Wallet items.
2781 return has_autofill_profiles ? 2789 return has_autofill_profiles ?
2782 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : 2790 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
2783 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; 2791 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
2784 } 2792 }
2785 2793
2786 } // namespace autofill 2794 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698