OLD | NEW |
| (Empty) |
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 base::TrimWhitespaceASCII(base::ToLowerASCII(str), base::TRIM_ALL, | |
39 &str_lower); | |
40 | |
41 if (str_lower == "setup_wallet") | |
42 return SETUP_WALLET; | |
43 else if (str_lower == "accept_tos") | |
44 return ACCEPT_TOS; | |
45 else if (str_lower == "gaia_auth") | |
46 return GAIA_AUTH; | |
47 else if (str_lower == "update_expiration_date") | |
48 return UPDATE_EXPIRATION_DATE; | |
49 else if (str_lower == "upgrade_min_address") | |
50 return UPGRADE_MIN_ADDRESS; | |
51 else if (str_lower == "invalid_form_field") | |
52 return INVALID_FORM_FIELD; | |
53 else if (str_lower == "verify_cvv") | |
54 return VERIFY_CVV; | |
55 else if (str_lower == "passive_gaia_auth") | |
56 return PASSIVE_GAIA_AUTH; | |
57 else if (str_lower == "require_phone_number") | |
58 return REQUIRE_PHONE_NUMBER; | |
59 else if (str_lower == "choose_another_instrument_or_address") | |
60 return CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS; | |
61 | |
62 DLOG(ERROR) << "Failed to parse: \"" << str << "\" as a required action"; | |
63 return UNKNOWN_TYPE; | |
64 } | |
65 | |
66 } // namespace wallet | |
67 } // namespace autofill | |
OLD | NEW |