| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/autofill/wallet/required_action.h" | 5 #include "chrome/browser/autofill/wallet/required_action.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 | 9 |
| 10 namespace wallet { | 10 namespace wallet { |
| 11 | 11 |
| 12 bool ActionAppliesToFullWallet(RequiredAction action) { | 12 bool ActionAppliesToFullWallet(RequiredAction action) { |
| 13 return action == UPDATE_EXPIRATION_DATE || | 13 return action == UPDATE_EXPIRATION_DATE || |
| 14 action == UPGRADE_MIN_ADDRESS || | 14 action == UPGRADE_MIN_ADDRESS || |
| 15 action == INVALID_FORM_FIELD || | 15 action == INVALID_FORM_FIELD || |
| 16 action == CVC_RISK_CHALLENGE; | 16 action == CVC_RISK_CHALLENGE; |
| 17 } | 17 } |
| 18 | 18 |
| 19 bool ActionAppliesToWalletItems(RequiredAction action) { | 19 bool ActionAppliesToWalletItems(RequiredAction action) { |
| 20 return action == SETUP_WALLET || | 20 return action == SETUP_WALLET || |
| 21 action == ACCEPT_TOS || | 21 action == ACCEPT_TOS || |
| 22 action == GAIA_AUTH || | 22 action == GAIA_AUTH || |
| 23 action == INVALID_FORM_FIELD; | 23 action == INVALID_FORM_FIELD || |
| 24 action == PASSIVE_GAIA_AUTH; |
| 24 } | 25 } |
| 25 | 26 |
| 26 RequiredAction ParseRequiredActionFromString(const std::string& str) { | 27 RequiredAction ParseRequiredActionFromString(const std::string& str) { |
| 27 std::string str_lower; | 28 std::string str_lower; |
| 28 TrimWhitespaceASCII(StringToLowerASCII(str), TRIM_ALL, &str_lower); | 29 TrimWhitespaceASCII(StringToLowerASCII(str), TRIM_ALL, &str_lower); |
| 29 | 30 |
| 30 if (str_lower == "setup_wallet") | 31 if (str_lower == "setup_wallet") |
| 31 return SETUP_WALLET; | 32 return SETUP_WALLET; |
| 32 else if (str_lower == "accept_tos") | 33 else if (str_lower == "accept_tos") |
| 33 return ACCEPT_TOS; | 34 return ACCEPT_TOS; |
| 34 else if (str_lower == "gaia_auth") | 35 else if (str_lower == "gaia_auth") |
| 35 return GAIA_AUTH; | 36 return GAIA_AUTH; |
| 36 else if (str_lower == "update_expiration_date") | 37 else if (str_lower == "update_expiration_date") |
| 37 return UPDATE_EXPIRATION_DATE; | 38 return UPDATE_EXPIRATION_DATE; |
| 38 else if (str_lower == "upgrade_min_address") | 39 else if (str_lower == "upgrade_min_address") |
| 39 return UPGRADE_MIN_ADDRESS; | 40 return UPGRADE_MIN_ADDRESS; |
| 40 else if (str_lower == "invalid_form_field") | 41 else if (str_lower == "invalid_form_field") |
| 41 return INVALID_FORM_FIELD; | 42 return INVALID_FORM_FIELD; |
| 42 else if (str_lower == "cvc_risk_challenge") | 43 else if (str_lower == "cvc_risk_challenge") |
| 43 return CVC_RISK_CHALLENGE; | 44 return CVC_RISK_CHALLENGE; |
| 45 else if (str_lower == "passive_gaia_auth") |
| 46 return PASSIVE_GAIA_AUTH; |
| 44 | 47 |
| 45 DLOG(ERROR) << "Failed to parse: \"" << str << "\" as a required action"; | 48 DLOG(ERROR) << "Failed to parse: \"" << str << "\" as a required action"; |
| 46 return UNKNOWN_TYPE; | 49 return UNKNOWN_TYPE; |
| 47 } | 50 } |
| 48 | 51 |
| 49 } // namespace wallet | 52 } // namespace wallet |
| OLD | NEW |