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

Unified Diff: chrome/browser/autofill/credit_card.cc

Issue 6673079: Reduce boxing and unboxing of AutofillFieldType (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 9 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
« no previous file with comments | « chrome/browser/autofill/credit_card.h ('k') | chrome/browser/autofill/form_group.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/credit_card.cc
diff --git a/chrome/browser/autofill/credit_card.cc b/chrome/browser/autofill/credit_card.cc
index 4360e6a749919afb074edba547d9147471f8ef0a..813761b0e6099e7f05f51c4b869d6a5c4f84249d 100644
--- a/chrome/browser/autofill/credit_card.cc
+++ b/chrome/browser/autofill/credit_card.cc
@@ -185,18 +185,18 @@ void CreditCard::GetAvailableFieldTypes(FieldTypeSet* available_types) const {
available_types->insert(CREDIT_CARD_NUMBER);
}
-void CreditCard::FindInfoMatches(const AutofillType& type,
+void CreditCard::FindInfoMatches(AutofillFieldType type,
const string16& info,
std::vector<string16>* matched_text) const {
DCHECK(matched_text);
string16 match;
- switch (type.field_type()) {
+ switch (type) {
case CREDIT_CARD_NUMBER: {
// Because the credit card number is encrypted and we are not able to do
// comparisons with it we will say that any field that is known to be a
// credit card number field will match all credit card numbers.
- string16 text = GetPreviewText(AutofillType(CREDIT_CARD_NUMBER));
+ string16 text = GetPreviewText(CREDIT_CARD_NUMBER);
if (!text.empty())
matched_text->push_back(text);
break;
@@ -214,14 +214,14 @@ void CreditCard::FindInfoMatches(const AutofillType& type,
break;
default:
- if (FindInfoMatchesHelper(type.field_type(), info, &match))
+ if (FindInfoMatchesHelper(type, info, &match))
matched_text->push_back(match);
break;
}
}
-string16 CreditCard::GetFieldText(const AutofillType& type) const {
- switch (type.field_type()) {
+string16 CreditCard::GetFieldText(AutofillFieldType type) const {
+ switch (type) {
case CREDIT_CARD_NAME:
return name_on_card();
@@ -267,8 +267,8 @@ string16 CreditCard::GetFieldText(const AutofillType& type) const {
}
}
-string16 CreditCard::GetPreviewText(const AutofillType& type) const {
- switch (type.field_type()) {
+string16 CreditCard::GetPreviewText(AutofillFieldType type) const {
+ switch (type) {
case CREDIT_CARD_NUMBER:
return last_four_digits();
@@ -281,8 +281,8 @@ string16 CreditCard::GetPreviewText(const AutofillType& type) const {
}
}
-void CreditCard::SetInfo(const AutofillType& type, const string16& value) {
- switch (type.field_type()) {
+void CreditCard::SetInfo(AutofillFieldType type, const string16& value) {
+ switch (type) {
case CREDIT_CARD_NAME:
set_name_on_card(value);
break;
@@ -322,8 +322,7 @@ void CreditCard::SetInfo(const AutofillType& type, const string16& value) {
break;
default:
- DLOG(ERROR) << "Attempting to set unknown info-type "
- << type.field_type();
+ DLOG(ERROR) << "Attempting to set unknown info-type " << type;
break;
}
}
@@ -412,8 +411,8 @@ int CreditCard::Compare(const CreditCard& credit_card) const {
CREDIT_CARD_EXP_MONTH,
CREDIT_CARD_EXP_4_DIGIT_YEAR };
for (size_t index = 0; index < arraysize(types); ++index) {
- int comparison = GetFieldText(AutofillType(types[index])).compare(
- credit_card.GetFieldText(AutofillType(types[index])));
+ int comparison = GetFieldText(types[index]).compare(
+ credit_card.GetFieldText(types[index]));
if (comparison != 0)
return comparison;
}
@@ -529,7 +528,7 @@ void CreditCard::set_expiration_year(int expiration_year) {
expiration_year_ = expiration_year;
}
-bool CreditCard::FindInfoMatchesHelper(const AutofillFieldType& field_type,
+bool CreditCard::FindInfoMatchesHelper(AutofillFieldType field_type,
const string16& info,
string16* match) const {
DCHECK(match);
@@ -642,17 +641,15 @@ std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card) {
<< " "
<< credit_card.guid()
<< " "
- << UTF16ToUTF8(credit_card.GetFieldText(AutofillType(CREDIT_CARD_NAME)))
+ << UTF16ToUTF8(credit_card.GetFieldText(CREDIT_CARD_NAME))
<< " "
- << UTF16ToUTF8(credit_card.GetFieldText(AutofillType(CREDIT_CARD_TYPE)))
+ << UTF16ToUTF8(credit_card.GetFieldText(CREDIT_CARD_TYPE))
<< " "
- << UTF16ToUTF8(credit_card.GetFieldText(AutofillType(CREDIT_CARD_NUMBER)))
+ << UTF16ToUTF8(credit_card.GetFieldText(CREDIT_CARD_NUMBER))
<< " "
- << UTF16ToUTF8(credit_card.GetFieldText(
- AutofillType(CREDIT_CARD_EXP_MONTH)))
+ << UTF16ToUTF8(credit_card.GetFieldText(CREDIT_CARD_EXP_MONTH))
<< " "
- << UTF16ToUTF8(credit_card.GetFieldText(
- AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)));
+ << UTF16ToUTF8(credit_card.GetFieldText(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
// These values must match the values in WebKitClientImpl in webkit/glue. We
« no previous file with comments | « chrome/browser/autofill/credit_card.h ('k') | chrome/browser/autofill/form_group.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698