diff options
author | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-10 19:02:01 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-10 19:02:01 +0000 |
commit | 0407b4ba756c944996db3e37e8932f087f47549a (patch) | |
tree | 065f53c1d9f9be4ba50b349e77072463931abed5 /components/autofill/content/browser/wallet/required_action.cc | |
parent | a38c64e3c5b18bacb2af9abe24bc940ef15744f9 (diff) | |
download | chromium_src-0407b4ba756c944996db3e37e8932f087f47549a.zip chromium_src-0407b4ba756c944996db3e37e8932f087f47549a.tar.gz chromium_src-0407b4ba756c944996db3e37e8932f087f47549a.tar.bz2 |
In components/autofill, move browser/wallet/ to content/browser/wallet/
This change is part of moving components/autofill into its eventual structure
as a layered component. As part of this move, this CL renames the
autofill_test_util target (which contains only util code for testing wallet) to
autofill_content_test_util.
TBR=joi, thakis
BUG=247015
Review URL: https://chromiumcodereview.appspot.com/16579003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205259 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/autofill/content/browser/wallet/required_action.cc')
-rw-r--r-- | components/autofill/content/browser/wallet/required_action.cc | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/components/autofill/content/browser/wallet/required_action.cc b/components/autofill/content/browser/wallet/required_action.cc new file mode 100644 index 0000000..716da3e --- /dev/null +++ b/components/autofill/content/browser/wallet/required_action.cc @@ -0,0 +1,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 |