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/instrument.h | |
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/instrument.h')
-rw-r--r-- | components/autofill/content/browser/wallet/instrument.h | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/components/autofill/content/browser/wallet/instrument.h b/components/autofill/content/browser/wallet/instrument.h new file mode 100644 index 0000000..97ee2e8 --- /dev/null +++ b/components/autofill/content/browser/wallet/instrument.h @@ -0,0 +1,104 @@ +// 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. + +#ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_INSTRUMENT_H_ +#define COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_INSTRUMENT_H_ + +#include <string> +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" +#include "base/string16.h" + +namespace base { +class DictionaryValue; +} + +namespace autofill { + +class AutofillProfile; +class CreditCard; + +namespace wallet { + +class Address; + +// This class contains all the data necessary to save a new instrument to a +// user's Google Wallet using WalletClient::SaveInstrument or +// WalletClient::SaveInstrumentAndAddress. +class Instrument { + public: + enum FormOfPayment { + UNKNOWN, + VISA, + MASTER_CARD, + AMEX, + DISCOVER, + JCB, + }; + + // Convert the info in |card| to an Instrument using |profile| for address. + Instrument(const CreditCard& card, + const base::string16& card_verification_number, + const AutofillProfile& profile); + + Instrument(const base::string16& primary_account_number, + const base::string16& card_verification_number, + int expiration_month, + int expiration_year, + FormOfPayment form_of_payment, + scoped_ptr<Address> address); + + Instrument(const Instrument& instrument); + + ~Instrument(); + + scoped_ptr<base::DictionaryValue> ToDictionary() const; + + // Users of this class should call IsValid to check that the inputs provided + // in the constructor were valid for use with Google Wallet. + bool IsValid() const; + + const base::string16& primary_account_number() const { + return primary_account_number_; + } + const base::string16& card_verification_number() const { + return card_verification_number_; + } + int expiration_month() const { return expiration_month_; } + int expiration_year() const { return expiration_year_; } + const Address& address() const { return *address_; } + FormOfPayment form_of_payment() const { return form_of_payment_; } + const base::string16& last_four_digits() { return last_four_digits_; } + + private: + void Init(); + + // |primary_account_number_| is expected to be \d{12-19}. + base::string16 primary_account_number_; + + // |card_verification_number_| is expected to be \d{3-4}. + base::string16 card_verification_number_; + + // |expiration month_| should be 1-12. + int expiration_month_; + + // |expiration_year_| should be a 4-digit year. + int expiration_year_; + + // The payment network of the instrument, e.g. Visa. + FormOfPayment form_of_payment_; + + // The billing address of the instrument. + scoped_ptr<Address> address_; + + // The last four digits of |primary_account_number_|. + base::string16 last_four_digits_; + + DISALLOW_ASSIGN(Instrument); +}; + +} // namespace wallet +} // namespace autofill + +#endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_INSTRUMENT_H_ |