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

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: Fix merge error. 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
« no previous file with comments | « chrome/browser/autofill/credit_card.h ('k') | chrome/browser/autofill/credit_card_field.cc » ('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 6296eba28f861139d08fb3605f72cd54410bf480..20fca4e28d5393967205dbda4568ce57c1cdeeaa 100644
--- a/chrome/browser/autofill/credit_card.cc
+++ b/chrome/browser/autofill/credit_card.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/string_split.h"
#include "base/string_util.h"
#include "base/string_number_conversions.h"
#include "base/string16.h"
@@ -15,6 +16,8 @@
#include "chrome/browser/autofill/field_types.h"
#include "chrome/common/guid.h"
#include "grit/generated_resources.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebRegularExpression.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "ui/base/l10n/l10n_util.h"
namespace {
@@ -329,6 +332,26 @@ const string16 CreditCard::Label() const {
return label_;
}
+void CreditCard::SetInfoForMonthInputType(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::ObfuscatedNumber() const {
if (number().empty())
return string16(); // No CC number, means empty preview.
« no previous file with comments | « chrome/browser/autofill/credit_card.h ('k') | chrome/browser/autofill/credit_card_field.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698