Add diagnostics_writer.cc to the list of files allowed to printf.
[chromium-blink-merge.git] / components / autofill / content / browser / wallet / instrument.h
blob01857f8802fba303fa4b45a63f46d5bc039bd256
1 // Copyright 2013 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.
5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_INSTRUMENT_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_INSTRUMENT_H_
8 #include <string>
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h"
13 namespace base {
14 class DictionaryValue;
17 namespace autofill {
19 class AutofillProfile;
20 class CreditCard;
22 namespace wallet {
24 class Address;
26 // This class contains all the data necessary to save a new instrument to a
27 // user's Google Wallet using WalletClient::SaveInstrument or
28 // WalletClient::SaveInstrumentAndAddress.
29 class Instrument {
30 public:
31 enum FormOfPayment {
32 UNKNOWN,
33 VISA,
34 MASTER_CARD,
35 AMEX,
36 DISCOVER,
37 JCB,
40 // Convert the info in |card| to an Instrument using |profile| for address.
41 Instrument(const CreditCard& card,
42 const base::string16& card_verification_number,
43 const AutofillProfile& profile);
45 Instrument(const base::string16& primary_account_number,
46 const base::string16& card_verification_number,
47 int expiration_month,
48 int expiration_year,
49 FormOfPayment form_of_payment,
50 scoped_ptr<Address> address);
52 Instrument(const Instrument& instrument);
54 ~Instrument();
56 scoped_ptr<base::DictionaryValue> ToDictionary() const;
58 const base::string16& primary_account_number() const {
59 return primary_account_number_;
61 const base::string16& card_verification_number() const {
62 return card_verification_number_;
64 int expiration_month() const { return expiration_month_; }
65 int expiration_year() const { return expiration_year_; }
66 const Address* address() const { return address_.get(); }
67 FormOfPayment form_of_payment() const { return form_of_payment_; }
68 const base::string16& last_four_digits() const { return last_four_digits_; }
69 const std::string& object_id() const { return object_id_; }
71 private:
72 void Init();
74 // |primary_account_number_| is expected to be \d{12-19}.
75 base::string16 primary_account_number_;
77 // |card_verification_number_| is expected to be \d{3-4}.
78 base::string16 card_verification_number_;
80 // |expiration month_| should be 1-12.
81 int expiration_month_;
83 // |expiration_year_| should be a 4-digit year.
84 int expiration_year_;
86 // The payment network of the instrument, e.g. Visa.
87 FormOfPayment form_of_payment_;
89 // The billing address of the instrument.
90 scoped_ptr<Address> address_;
92 // The last four digits of |primary_account_number_|.
93 base::string16 last_four_digits_;
95 // Externalized Online Wallet id for this instrument.
96 std::string object_id_;
98 DISALLOW_ASSIGN(Instrument);
101 } // namespace wallet
102 } // namespace autofill
104 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_INSTRUMENT_H_