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

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

Issue 11360055: [Autofill] Rename GetInfo and SetInfo to GetRawInfo and SetRawInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix names in more tests Created 8 years, 1 month 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/autofill/credit_card.h" 5 #include "chrome/browser/autofill/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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 void CreditCard::GetSupportedTypes(FieldTypeSet* supported_types) const { 207 void CreditCard::GetSupportedTypes(FieldTypeSet* supported_types) const {
208 supported_types->insert(CREDIT_CARD_NAME); 208 supported_types->insert(CREDIT_CARD_NAME);
209 supported_types->insert(CREDIT_CARD_NUMBER); 209 supported_types->insert(CREDIT_CARD_NUMBER);
210 supported_types->insert(CREDIT_CARD_EXP_MONTH); 210 supported_types->insert(CREDIT_CARD_EXP_MONTH);
211 supported_types->insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); 211 supported_types->insert(CREDIT_CARD_EXP_2_DIGIT_YEAR);
212 supported_types->insert(CREDIT_CARD_EXP_4_DIGIT_YEAR); 212 supported_types->insert(CREDIT_CARD_EXP_4_DIGIT_YEAR);
213 supported_types->insert(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR); 213 supported_types->insert(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR);
214 supported_types->insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR); 214 supported_types->insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR);
215 } 215 }
216 216
217 string16 CreditCard::GetInfo(AutofillFieldType type) const { 217 string16 CreditCard::GetRawInfo(AutofillFieldType type) const {
218 switch (type) { 218 switch (type) {
219 case CREDIT_CARD_NAME: 219 case CREDIT_CARD_NAME:
220 return name_on_card_; 220 return name_on_card_;
221 221
222 case CREDIT_CARD_EXP_MONTH: 222 case CREDIT_CARD_EXP_MONTH:
223 return ExpirationMonthAsString(); 223 return ExpirationMonthAsString();
224 224
225 case CREDIT_CARD_EXP_2_DIGIT_YEAR: 225 case CREDIT_CARD_EXP_2_DIGIT_YEAR:
226 return Expiration2DigitYearAsString(); 226 return Expiration2DigitYearAsString();
227 227
(...skipping 26 matching lines...) Expand all
254 case CREDIT_CARD_VERIFICATION_CODE: 254 case CREDIT_CARD_VERIFICATION_CODE:
255 NOTREACHED(); 255 NOTREACHED();
256 return string16(); 256 return string16();
257 257
258 default: 258 default:
259 // ComputeDataPresentForArray will hit this repeatedly. 259 // ComputeDataPresentForArray will hit this repeatedly.
260 return string16(); 260 return string16();
261 } 261 }
262 } 262 }
263 263
264 void CreditCard::SetInfo(AutofillFieldType type, const string16& value) { 264 void CreditCard::SetRawInfo(AutofillFieldType type, const string16& value) {
265 switch (type) { 265 switch (type) {
266 case CREDIT_CARD_NAME: 266 case CREDIT_CARD_NAME:
267 name_on_card_ = value; 267 name_on_card_ = value;
268 break; 268 break;
269 269
270 case CREDIT_CARD_EXP_MONTH: 270 case CREDIT_CARD_EXP_MONTH:
271 SetExpirationMonthFromString(value); 271 SetExpirationMonthFromString(value);
272 break; 272 break;
273 273
274 case CREDIT_CARD_EXP_2_DIGIT_YEAR: 274 case CREDIT_CARD_EXP_2_DIGIT_YEAR:
(...skipping 30 matching lines...) Expand all
305 default: 305 default:
306 NOTREACHED() << "Attempting to set unknown info-type " << type; 306 NOTREACHED() << "Attempting to set unknown info-type " << type;
307 break; 307 break;
308 } 308 }
309 } 309 }
310 310
311 string16 CreditCard::GetCanonicalizedInfo(AutofillFieldType type) const { 311 string16 CreditCard::GetCanonicalizedInfo(AutofillFieldType type) const {
312 if (type == CREDIT_CARD_NUMBER) 312 if (type == CREDIT_CARD_NUMBER)
313 return StripSeparators(number_); 313 return StripSeparators(number_);
314 314
315 return GetInfo(type); 315 return GetRawInfo(type);
316 } 316 }
317 317
318 bool CreditCard::SetCanonicalizedInfo(AutofillFieldType type, 318 bool CreditCard::SetCanonicalizedInfo(AutofillFieldType type,
319 const string16& value) { 319 const string16& value) {
320 if (type == CREDIT_CARD_NUMBER) 320 if (type == CREDIT_CARD_NUMBER)
321 SetInfo(type, StripSeparators(value)); 321 SetRawInfo(type, StripSeparators(value));
322 else 322 else
323 SetInfo(type, value); 323 SetRawInfo(type, value);
324 324
325 return true; 325 return true;
326 } 326 }
327 327
328 void CreditCard::GetMatchingTypes(const string16& text, 328 void CreditCard::GetMatchingTypes(const string16& text,
329 FieldTypeSet* matching_types) const { 329 FieldTypeSet* matching_types) const {
330 FormGroup::GetMatchingTypes(text, matching_types); 330 FormGroup::GetMatchingTypes(text, matching_types);
331 331
332 string16 card_number = GetCanonicalizedInfo(CREDIT_CARD_NUMBER); 332 string16 card_number = GetCanonicalizedInfo(CREDIT_CARD_NUMBER);
333 if (!card_number.empty() && StripSeparators(text) == card_number) 333 if (!card_number.empty() && StripSeparators(text) == card_number)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 432
433 int CreditCard::Compare(const CreditCard& credit_card) const { 433 int CreditCard::Compare(const CreditCard& credit_card) const {
434 // The following CreditCard field types are the only types we store in the 434 // The following CreditCard field types are the only types we store in the
435 // WebDB so far, so we're only concerned with matching these types in the 435 // WebDB so far, so we're only concerned with matching these types in the
436 // credit card. 436 // credit card.
437 const AutofillFieldType types[] = { CREDIT_CARD_NAME, 437 const AutofillFieldType types[] = { CREDIT_CARD_NAME,
438 CREDIT_CARD_NUMBER, 438 CREDIT_CARD_NUMBER,
439 CREDIT_CARD_EXP_MONTH, 439 CREDIT_CARD_EXP_MONTH,
440 CREDIT_CARD_EXP_4_DIGIT_YEAR }; 440 CREDIT_CARD_EXP_4_DIGIT_YEAR };
441 for (size_t index = 0; index < arraysize(types); ++index) { 441 for (size_t index = 0; index < arraysize(types); ++index) {
442 int comparison = GetInfo(types[index]).compare( 442 int comparison = GetRawInfo(types[index]).compare(
443 credit_card.GetInfo(types[index])); 443 credit_card.GetRawInfo(types[index]));
444 if (comparison != 0) 444 if (comparison != 0)
445 return comparison; 445 return comparison;
446 } 446 }
447 447
448 return 0; 448 return 0;
449 } 449 }
450 450
451 bool CreditCard::operator==(const CreditCard& credit_card) const { 451 bool CreditCard::operator==(const CreditCard& credit_card) const {
452 if (guid_ != credit_card.guid_) 452 if (guid_ != credit_card.guid_)
453 return false; 453 return false;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 expiration_year_ = expiration_year; 572 expiration_year_ = expiration_year;
573 } 573 }
574 574
575 // So we can compare CreditCards with EXPECT_EQ(). 575 // So we can compare CreditCards with EXPECT_EQ().
576 std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card) { 576 std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card) {
577 return os 577 return os
578 << UTF16ToUTF8(credit_card.Label()) 578 << UTF16ToUTF8(credit_card.Label())
579 << " " 579 << " "
580 << credit_card.guid() 580 << credit_card.guid()
581 << " " 581 << " "
582 << UTF16ToUTF8(credit_card.GetInfo(CREDIT_CARD_NAME)) 582 << UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NAME))
583 << " " 583 << " "
584 << UTF16ToUTF8(credit_card.GetInfo(CREDIT_CARD_TYPE)) 584 << UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_TYPE))
585 << " " 585 << " "
586 << UTF16ToUTF8(credit_card.GetInfo(CREDIT_CARD_NUMBER)) 586 << UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NUMBER))
587 << " " 587 << " "
588 << UTF16ToUTF8(credit_card.GetInfo(CREDIT_CARD_EXP_MONTH)) 588 << UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_EXP_MONTH))
589 << " " 589 << " "
590 << UTF16ToUTF8(credit_card.GetInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); 590 << UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
591 } 591 }
592 592
593 // These values must match the values in WebKitPlatformSupportImpl in 593 // These values must match the values in WebKitPlatformSupportImpl in
594 // webkit/glue. We send these strings to WebKit, which then asks 594 // webkit/glue. We send these strings to WebKit, which then asks
595 // WebKitPlatformSupportImpl to load the image data. 595 // WebKitPlatformSupportImpl to load the image data.
596 const char* const kAmericanExpressCard = "americanExpressCC"; 596 const char* const kAmericanExpressCard = "americanExpressCC";
597 const char* const kDinersCard = "dinersCC"; 597 const char* const kDinersCard = "dinersCC";
598 const char* const kDiscoverCard = "discoverCC"; 598 const char* const kDiscoverCard = "discoverCC";
599 const char* const kGenericCard = "genericCC"; 599 const char* const kGenericCard = "genericCC";
600 const char* const kJCBCard = "jcbCC"; 600 const char* const kJCBCard = "jcbCC";
601 const char* const kMasterCard = "masterCardCC"; 601 const char* const kMasterCard = "masterCardCC";
602 const char* const kSoloCard = "soloCC"; 602 const char* const kSoloCard = "soloCC";
603 const char* const kVisaCard = "visaCC"; 603 const char* const kVisaCard = "visaCC";
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698