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

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: Add more tests, fix some format errors and change parsing. 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 26ed7850c2145d73f524b728d387f4aa7d10e0cb..d588316a32a2938181947a9fc138601f07e5ed48 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 {
@@ -455,6 +458,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(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);
+ }
+}
+
honten.org 2011/01/06 07:04:54 Use regular expression to check yyyy-mm.
dhollowa 2011/01/07 03:47:15 Nice. On 2011/01/06 07:04:54, honten wrote:
string16 CreditCard::ExpirationMonthAsString() const {
if (expiration_month_ == 0)
return string16();

Powered by Google App Engine
This is Rietveld 408576698