Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: chrome/browser/autofill/wallet/required_action.cc

Issue 11777007: Adds wallet::RequiredAction for when we start interacting with Online Wallet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fix Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 RequiredAction::RequiredAction() : action_type_(UNKNOWN_TYPE) {}
13
14 RequiredAction::RequiredAction(ActionType action_type)
15 : action_type_(action_type) {}
16
17 RequiredAction::~RequiredAction() {}
18
19 // static
20 bool RequiredAction::AppliesToFullWallet(ActionType action_type) {
21 switch (action_type) {
22 case UPDATE_EXPIRATION_DATE:
23 case UPGRADE_MIN_ADDRESS:
24 case INVALID_FORM_FIELD:
25 case CVC_RISK_CHALLENGE:
26 return true;
27 default:
28 return false;
29 }
30 }
31
32 // static
33 bool RequiredAction::AppliesToWalletItems(ActionType action_type) {
34 switch (action_type) {
35 case SETUP_WALLET:
36 case ACCEPT_TOS:
37 case GAIA_AUTH:
38 case INVALID_FORM_FIELD:
39 return true;
40 default:
41 return false;
42 }
43 }
44
45 // static
46 RequiredAction::ActionType RequiredAction::ParseFromString(
47 const std::string& str) {
48 std::string str_lower;
49 TrimWhitespaceASCII(StringToLowerASCII(str), TRIM_ALL, &str_lower);
50
51 if (str_lower == "setup_wallet")
52 return SETUP_WALLET;
53 else if (str_lower == "accept_tos")
54 return ACCEPT_TOS;
55 else if (str_lower == "gaia_auth")
56 return GAIA_AUTH;
57 else if (str_lower == "update_expiration_date")
58 return UPDATE_EXPIRATION_DATE;
59 else if (str_lower == "upgrade_min_address")
60 return UPGRADE_MIN_ADDRESS;
61 else if (str_lower == "invalid_form_field")
62 return INVALID_FORM_FIELD;
63 else if (str_lower == "cvc_risk_challenge")
64 return CVC_RISK_CHALLENGE;
65
66 DVLOG(1) << "Failed to parse: \"" << str << "\" as a required action";
67 return UNKNOWN_TYPE;
68 }
69
70 bool RequiredAction::AppliesToFullWallet() const {
71 return AppliesToFullWallet(action_type());
72 }
73
74 bool RequiredAction::AppliesToWalletItems() const {
75 return AppliesToWalletItems(action_type());
76 }
77
78 bool RequiredAction::IsKnownType() const {
79 return action_type_ != UNKNOWN_TYPE;
80 }
81
82 bool RequiredAction::operator==(const RequiredAction& action) const {
83 return action_type() == action.action_type();
84 }
85
86 } // namespace wallet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698