blob: 716da3e1e1603c4e96f0924efb5dbb4dd1d5fc51 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/autofill/content/browser/wallet/required_action.h"
#include "base/logging.h"
#include "base/string_util.h"
namespace autofill {
namespace wallet {
bool ActionAppliesToFullWallet(RequiredAction action) {
return action == UPDATE_EXPIRATION_DATE ||
action == VERIFY_CVV ||
action == CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS ||
action == REQUIRE_PHONE_NUMBER;
}
bool ActionAppliesToSaveToWallet(RequiredAction action) {
return action == INVALID_FORM_FIELD ||
action == REQUIRE_PHONE_NUMBER;
}
bool ActionAppliesToWalletItems(RequiredAction action) {
return action == SETUP_WALLET ||
action == CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS ||
action == ACCEPT_TOS ||
action == GAIA_AUTH ||
action == REQUIRE_PHONE_NUMBER ||
action == UPDATE_EXPIRATION_DATE ||
action == UPGRADE_MIN_ADDRESS ||
action == PASSIVE_GAIA_AUTH;
}
RequiredAction ParseRequiredActionFromString(const std::string& str) {
std::string str_lower;
TrimWhitespaceASCII(StringToLowerASCII(str), TRIM_ALL, &str_lower);
if (str_lower == "setup_wallet")
return SETUP_WALLET;
else if (str_lower == "accept_tos")
return ACCEPT_TOS;
else if (str_lower == "gaia_auth")
return GAIA_AUTH;
else if (str_lower == "update_expiration_date")
return UPDATE_EXPIRATION_DATE;
else if (str_lower == "upgrade_min_address")
return UPGRADE_MIN_ADDRESS;
else if (str_lower == "invalid_form_field")
return INVALID_FORM_FIELD;
else if (str_lower == "verify_cvv")
return VERIFY_CVV;
else if (str_lower == "passive_gaia_auth")
return PASSIVE_GAIA_AUTH;
else if (str_lower == "require_phone_number")
return REQUIRE_PHONE_NUMBER;
else if (str_lower == "choose_another_instrument_or_address")
return CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS;
DLOG(ERROR) << "Failed to parse: \"" << str << "\" as a required action";
return UNKNOWN_TYPE;
}
} // namespace wallet
} // namespace autofill
|