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 wallet { | |
11 | |
12 bool AppliesToFullWallet(RequiredAction action) { | |
13 switch (action) { | |
14 case UPDATE_EXPIRATION_DATE: | |
15 case UPGRADE_MIN_ADDRESS: | |
16 case INVALID_FORM_FIELD: | |
17 case CVC_RISK_CHALLENGE: | |
18 return true; | |
19 default: | |
20 return false; | |
21 } | |
Ilya Sherman
2013/01/05 23:30:49
Optional nit: I would write this as "return action
Dan Beam
2013/01/07 15:44:53
Done.
| |
22 } | |
23 | |
24 bool AppliesToWalletItems(RequiredAction action) { | |
25 switch (action) { | |
26 case SETUP_WALLET: | |
27 case ACCEPT_TOS: | |
28 case GAIA_AUTH: | |
29 case INVALID_FORM_FIELD: | |
30 return true; | |
31 default: | |
32 return false; | |
33 } | |
34 } | |
35 | |
36 RequiredAction ParseFromString(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 == "cvc_risk_challenge") | |
53 return CVC_RISK_CHALLENGE; | |
54 | |
55 DLOG(ERROR) << "Failed to parse: \"" << str << "\" as a required action"; | |
56 return UNKNOWN_TYPE; | |
57 } | |
58 | |
59 } // namespace wallet | |
OLD | NEW |