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.
5 #include "components/autofill/content/browser/wallet/required_action.h"
7 #include "base/logging.h"
8 #include "base/strings/string_util.h"
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
;
20 bool ActionAppliesToSaveToWallet(RequiredAction action
) {
21 return action
== INVALID_FORM_FIELD
||
22 action
== REQUIRE_PHONE_NUMBER
;
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
;
36 RequiredAction
ParseRequiredActionFromString(const std::string
& str
) {
37 std::string str_lower
;
38 base::TrimWhitespaceASCII(base::StringToLowerASCII(str
), base::TRIM_ALL
,
41 if (str_lower
== "setup_wallet")
43 else if (str_lower
== "accept_tos")
45 else if (str_lower
== "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")
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
;
62 DLOG(ERROR
) << "Failed to parse: \"" << str
<< "\" as a required action";
67 } // namespace autofill