Index: chrome/browser/autofill/wallet/required_action.cc |
diff --git a/chrome/browser/autofill/wallet/required_action.cc b/chrome/browser/autofill/wallet/required_action.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c87b537e848a6593c413b4d60ee5264abcb3c92e |
--- /dev/null |
+++ b/chrome/browser/autofill/wallet/required_action.cc |
@@ -0,0 +1,49 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/autofill/wallet/required_action.h" |
+ |
+#include "base/logging.h" |
+#include "base/string_util.h" |
+ |
+namespace wallet { |
+ |
+bool ActionAppliesToFullWallet(RequiredAction action) { |
+ return action == UPDATE_EXPIRATION_DATE || |
+ action == UPGRADE_MIN_ADDRESS || |
+ action == INVALID_FORM_FIELD || |
+ action == CVC_RISK_CHALLENGE; |
+} |
+ |
+bool ActionAppliesToWalletItems(RequiredAction action) { |
+ return action == SETUP_WALLET || |
+ action == ACCEPT_TOS || |
+ action == GAIA_AUTH || |
+ action == INVALID_FORM_FIELD; |
+} |
+ |
+RequiredAction ParseRequiredActionFromString(const std::string& str) { |
+ std::string str_lower; |
+ TrimWhitespaceASCII(StringToLowerASCII(str), TRIM_ALL, &str_lower); |
+ |
+ if (str_lower == "setup_wallet") |
+ return SETUP_WALLET; |
+ else if (str_lower == "accept_tos") |
+ return ACCEPT_TOS; |
+ else if (str_lower == "gaia_auth") |
+ return GAIA_AUTH; |
+ else if (str_lower == "update_expiration_date") |
+ return UPDATE_EXPIRATION_DATE; |
+ else if (str_lower == "upgrade_min_address") |
+ return UPGRADE_MIN_ADDRESS; |
+ else if (str_lower == "invalid_form_field") |
+ return INVALID_FORM_FIELD; |
+ else if (str_lower == "cvc_risk_challenge") |
+ return CVC_RISK_CHALLENGE; |
+ |
+ DLOG(ERROR) << "Failed to parse: \"" << str << "\" as a required action"; |
+ return UNKNOWN_TYPE; |
+} |
+ |
+} // namespace wallet |