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