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

Side by Side Diff: components/autofill/browser/credit_card.cc

Issue 16034018: [Autofill] Support "importing" verified profiles and credit cards. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix up comments 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 (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 "components/autofill/browser/credit_card.h" 5 #include "components/autofill/browser/credit_card.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <ostream> 9 #include <ostream>
10 #include <string> 10 #include <string>
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 set_origin(credit_card.origin()); 491 set_origin(credit_card.origin());
492 } 492 }
493 493
494 bool CreditCard::UpdateFromImportedCard(const CreditCard& imported_card, 494 bool CreditCard::UpdateFromImportedCard(const CreditCard& imported_card,
495 const std::string& app_locale) { 495 const std::string& app_locale) {
496 if (this->GetInfo(CREDIT_CARD_NUMBER, app_locale) != 496 if (this->GetInfo(CREDIT_CARD_NUMBER, app_locale) !=
497 imported_card.GetInfo(CREDIT_CARD_NUMBER, app_locale)) { 497 imported_card.GetInfo(CREDIT_CARD_NUMBER, app_locale)) {
498 return false; 498 return false;
499 } 499 }
500 500
501 DCHECK(!imported_card.IsVerified()); 501 // Heuristically aggregated data should never overwrite verified data.
502 if (this->IsVerified()) 502 // Instead, discard any heuristically aggregated credit cards that disagree
503 // with explicitly entered data, so that the UI is not cluttered with
504 // duplicate cards.
505 if (this->IsVerified() && !imported_card.IsVerified())
503 return true; 506 return true;
504 507
508 set_origin(imported_card.origin());
509
505 // Note that the card number is intentionally not updated, so as to preserve 510 // Note that the card number is intentionally not updated, so as to preserve
506 // any formatting (i.e. separator characters). Since the card number is not 511 // any formatting (i.e. separator characters). Since the card number is not
507 // updated, there is no reason to update the card type, either. 512 // updated, there is no reason to update the card type, either.
508 if (!imported_card.name_on_card_.empty()) 513 if (!imported_card.name_on_card_.empty())
509 name_on_card_ = imported_card.name_on_card_; 514 name_on_card_ = imported_card.name_on_card_;
510 515
511 // The expiration date for |imported_card| should always be set. 516 // The expiration date for |imported_card| should always be set.
512 DCHECK(imported_card.expiration_month_ && imported_card.expiration_year_); 517 DCHECK(imported_card.expiration_month_ && imported_card.expiration_year_);
513 expiration_month_ = imported_card.expiration_month_; 518 expiration_month_ = imported_card.expiration_month_;
514 expiration_year_ = imported_card.expiration_year_; 519 expiration_year_ = imported_card.expiration_year_;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 const char* const kAmericanExpressCard = "americanExpressCC"; 687 const char* const kAmericanExpressCard = "americanExpressCC";
683 const char* const kDinersCard = "dinersCC"; 688 const char* const kDinersCard = "dinersCC";
684 const char* const kDiscoverCard = "discoverCC"; 689 const char* const kDiscoverCard = "discoverCC";
685 const char* const kGenericCard = "genericCC"; 690 const char* const kGenericCard = "genericCC";
686 const char* const kJCBCard = "jcbCC"; 691 const char* const kJCBCard = "jcbCC";
687 const char* const kMasterCard = "masterCardCC"; 692 const char* const kMasterCard = "masterCardCC";
688 const char* const kSoloCard = "soloCC"; 693 const char* const kSoloCard = "soloCC";
689 const char* const kVisaCard = "visaCC"; 694 const char* const kVisaCard = "visaCC";
690 695
691 } // namespace autofill 696 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698