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

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

Issue 6033010: Support autocompletion for HTMl5 tags:"email", "month" and "tel". (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: unroll tests. Created 9 years, 11 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
Index: chrome/browser/autofill/credit_card.cc
diff --git a/chrome/browser/autofill/credit_card.cc b/chrome/browser/autofill/credit_card.cc
index 115f2e81170c4a0d6b2ba8f7c1d6bbc67eaab4d0..bbf012af33ef9a43668ab4bc2f847ea5f8393181 100644
--- a/chrome/browser/autofill/credit_card.cc
+++ b/chrome/browser/autofill/credit_card.cc
@@ -8,6 +8,7 @@
#include "app/l10n_util.h"
#include "base/basictypes.h"
+#include "base/string_split.h"
#include "base/string_util.h"
#include "base/string_number_conversions.h"
#include "base/string16.h"
@@ -16,6 +17,8 @@
#include "chrome/browser/autofill/field_types.h"
#include "chrome/common/guid.h"
#include "grit/generated_resources.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebRegularExpression.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
namespace {
@@ -443,6 +446,26 @@ bool CreditCard::IsEmpty() const {
return types.empty();
}
+void CreditCard::SetMonthInputInfo(const string16& value) {
+ // Check if |text| is "yyyy-mm" format first, and check normal month format.
+ WebKit::WebRegularExpression re(WebKit::WebString("^[0-9]{4}\\-[0-9]{1,2}$"),
+ WebKit::WebTextCaseInsensitive);
+ bool match = re.match(WebKit::WebString(StringToLowerASCII(value))) != -1;
+ if (match) {
+ std::vector<string16> year_month;
+ base::SplitString(value, L'-', &year_month);
+ DCHECK_EQ((int)year_month.size(), 2);
+ int num = 0;
+ bool converted = false;
+ converted = base::StringToInt(year_month[0], &num);
+ DCHECK(converted);
+ set_expiration_year(num);
+ converted = base::StringToInt(year_month[1], &num);
+ DCHECK(converted);
+ set_expiration_month(num);
+ }
+}
+
string16 CreditCard::ExpirationMonthAsString() const {
if (expiration_month_ == 0)
return string16();

Powered by Google App Engine
This is Rietveld 408576698