| Index: chrome/browser/autofill/wallet/required_action.cc
|
| diff --git a/chrome/browser/autofill/wallet/required_action.cc b/chrome/browser/autofill/wallet/required_action.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f47433ef27d85509af314468d27ca6e5ec347fc6
|
| --- /dev/null
|
| +++ b/chrome/browser/autofill/wallet/required_action.cc
|
| @@ -0,0 +1,86 @@
|
| +// Copyright (c) 2012 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 "chrome/browser/autofill/wallet/required_action.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "base/string_util.h"
|
| +
|
| +namespace wallet {
|
| +
|
| +RequiredAction::RequiredAction() : action_type_(UNKNOWN_TYPE) {}
|
| +
|
| +RequiredAction::RequiredAction(ActionType action_type)
|
| + : action_type_(action_type) {}
|
| +
|
| +RequiredAction::~RequiredAction() {}
|
| +
|
| +// static
|
| +bool RequiredAction::AppliesToFullWallet(ActionType action_type) {
|
| + switch (action_type) {
|
| + case UPDATE_EXPIRATION_DATE:
|
| + case UPGRADE_MIN_ADDRESS:
|
| + case INVALID_FORM_FIELD:
|
| + case CVC_RISK_CHALLENGE:
|
| + return true;
|
| + default:
|
| + return false;
|
| + }
|
| +}
|
| +
|
| +// static
|
| +bool RequiredAction::AppliesToWalletItems(ActionType action_type) {
|
| + switch (action_type) {
|
| + case SETUP_WALLET:
|
| + case ACCEPT_TOS:
|
| + case GAIA_AUTH:
|
| + case INVALID_FORM_FIELD:
|
| + return true;
|
| + default:
|
| + return false;
|
| + }
|
| +}
|
| +
|
| +// static
|
| +RequiredAction::ActionType RequiredAction::ParseFromString(
|
| + 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 == "cvc_risk_challenge")
|
| + return CVC_RISK_CHALLENGE;
|
| +
|
| + DVLOG(1) << "Failed to parse: \"" << str << "\" as a required action";
|
| + return UNKNOWN_TYPE;
|
| +}
|
| +
|
| +bool RequiredAction::AppliesToFullWallet() const {
|
| + return AppliesToFullWallet(action_type());
|
| +}
|
| +
|
| +bool RequiredAction::AppliesToWalletItems() const {
|
| + return AppliesToWalletItems(action_type());
|
| +}
|
| +
|
| +bool RequiredAction::IsKnownType() const {
|
| + return action_type_ != UNKNOWN_TYPE;
|
| +}
|
| +
|
| +bool RequiredAction::operator==(const RequiredAction& action) const {
|
| + return action_type() == action.action_type();
|
| +}
|
| +
|
| +} // namespace wallet
|
|
|