| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/autofill/wallet/required_action.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/string_util.h" | |
| 9 | |
| 10 namespace autofill { | |
| 11 namespace wallet { | |
| 12 | |
| 13 bool ActionAppliesToFullWallet(RequiredAction action) { | |
| 14 return action == UPDATE_EXPIRATION_DATE || | |
| 15 action == UPGRADE_MIN_ADDRESS || | |
| 16 action == INVALID_FORM_FIELD || | |
| 17 action == VERIFY_CVV || | |
| 18 action == REQUIRE_PHONE_NUMBER; | |
| 19 } | |
| 20 | |
| 21 bool ActionAppliesToSaveToWallet(RequiredAction action) { | |
| 22 return action == INVALID_FORM_FIELD || | |
| 23 action == REQUIRE_PHONE_NUMBER; | |
| 24 } | |
| 25 | |
| 26 bool ActionAppliesToWalletItems(RequiredAction action) { | |
| 27 return action == SETUP_WALLET || | |
| 28 action == ACCEPT_TOS || | |
| 29 action == GAIA_AUTH || | |
| 30 action == INVALID_FORM_FIELD || | |
| 31 action == REQUIRE_PHONE_NUMBER || | |
| 32 action == PASSIVE_GAIA_AUTH; | |
| 33 } | |
| 34 | |
| 35 RequiredAction ParseRequiredActionFromString(const std::string& str) { | |
| 36 std::string str_lower; | |
| 37 TrimWhitespaceASCII(StringToLowerASCII(str), TRIM_ALL, &str_lower); | |
| 38 | |
| 39 if (str_lower == "setup_wallet") | |
| 40 return SETUP_WALLET; | |
| 41 else if (str_lower == "accept_tos") | |
| 42 return ACCEPT_TOS; | |
| 43 else if (str_lower == "gaia_auth") | |
| 44 return GAIA_AUTH; | |
| 45 else if (str_lower == "update_expiration_date") | |
| 46 return UPDATE_EXPIRATION_DATE; | |
| 47 else if (str_lower == "upgrade_min_address") | |
| 48 return UPGRADE_MIN_ADDRESS; | |
| 49 else if (str_lower == "invalid_form_field") | |
| 50 return INVALID_FORM_FIELD; | |
| 51 else if (str_lower == "verify_cvv") | |
| 52 return VERIFY_CVV; | |
| 53 else if (str_lower == "passive_gaia_auth") | |
| 54 return PASSIVE_GAIA_AUTH; | |
| 55 else if (str_lower == "require_phone_number") | |
| 56 return REQUIRE_PHONE_NUMBER; | |
| 57 | |
| 58 DLOG(ERROR) << "Failed to parse: \"" << str << "\" as a required action"; | |
| 59 return UNKNOWN_TYPE; | |
| 60 } | |
| 61 | |
| 62 } // namespace wallet | |
| 63 } // namespace autofill | |
| OLD | NEW |