OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_ |
6 #define CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_ | 6 #define CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 // WalletClientObserver with the response from the Online Wallet backend. | 34 // WalletClientObserver with the response from the Online Wallet backend. |
35 class WalletClientObserver { | 35 class WalletClientObserver { |
36 public: | 36 public: |
37 // Called when an AcceptLegalDocuments request finishes successfully. | 37 // Called when an AcceptLegalDocuments request finishes successfully. |
38 virtual void OnAcceptLegalDocuments() = 0; | 38 virtual void OnAcceptLegalDocuments() = 0; |
39 | 39 |
40 // Called when an EncryptOtp request finishes successfully. | 40 // Called when an EncryptOtp request finishes successfully. |
41 virtual void OnEncryptOtp(const std::string& encrypted_otp, | 41 virtual void OnEncryptOtp(const std::string& encrypted_otp, |
42 const std::string& session_material) = 0; | 42 const std::string& session_material) = 0; |
43 | 43 |
| 44 // Called when an EscrowSensitiveInformation request finishes successfully. |
| 45 // |escrow_handle| must be used when saving a new instrument using |
| 46 // SaveInstrument or SaveAdressAndInstrument. |
| 47 virtual void OnDidEscrowSensitiveInformation( |
| 48 const std::string& escrow_handle) = 0; |
| 49 |
44 // Called when a GetFullWallet request finishes successfully. Caller owns | 50 // Called when a GetFullWallet request finishes successfully. Caller owns |
45 // the input pointer. | 51 // the input pointer. |
46 virtual void OnGetFullWallet(FullWallet* full_wallet) = 0; | 52 virtual void OnGetFullWallet(FullWallet* full_wallet) = 0; |
47 | 53 |
48 // Called when a GetWalletItems request finishes successfully. Caller owns | 54 // Called when a GetWalletItems request finishes successfully. Caller owns |
49 // the input pointer. | 55 // the input pointer. |
50 virtual void OnGetWalletItems(WalletItems* wallet_items) = 0; | 56 virtual void OnGetWalletItems(WalletItems* wallet_items) = 0; |
51 | 57 |
52 // Called when a SendExtendedAutofillStatus request finishes successfully. | 58 // Called when a SendExtendedAutofillStatus request finishes successfully. |
53 virtual void OnSendExtendedAutofillStatus() = 0; | 59 virtual void OnSendExtendedAutofillStatus() = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
80 const std::string& google_transaction_id, | 86 const std::string& google_transaction_id, |
81 WalletClientObserver* observer); | 87 WalletClientObserver* observer); |
82 | 88 |
83 // Before calling GetFullWallet, the client must encrypt a one time pad, | 89 // Before calling GetFullWallet, the client must encrypt a one time pad, |
84 // |otp|, of crytographically secure random bytes. These bytes must be | 90 // |otp|, of crytographically secure random bytes. These bytes must be |
85 // generated using crypto/random.h. | 91 // generated using crypto/random.h. |
86 void EncryptOtp(const void* otp, | 92 void EncryptOtp(const void* otp, |
87 size_t length, | 93 size_t length, |
88 WalletClientObserver* observer); | 94 WalletClientObserver* observer); |
89 | 95 |
| 96 // Before calling SaveInstrument or SaveAddressAndInstrument, the client must |
| 97 // escrow |primary_account_number| and |card_verfication_number| with Google |
| 98 // Wallet. |
| 99 void EscrowSensitiveInformation(const std::string& primary_account_number, |
| 100 const std::string& card_verification_number, |
| 101 const std::string& obfuscated_gaia_id, |
| 102 WalletClientObserver* observer); |
| 103 |
90 // GetFullWallet retrieves the a FullWallet for the user. |instrument_id| and | 104 // GetFullWallet retrieves the a FullWallet for the user. |instrument_id| and |
91 // |adddress_id| should have been selected by the user in some UI, | 105 // |adddress_id| should have been selected by the user in some UI, |
92 // |merchant_domain| should come from the BrowserContext, the |cart| | 106 // |merchant_domain| should come from the BrowserContext, the |cart| |
93 // information will have been provided by the browser, |google_transaction_id| | 107 // information will have been provided by the browser, |google_transaction_id| |
94 // is the same one that GetWalletItems returns, and |encrypted_otp| and | 108 // is the same one that GetWalletItems returns, and |encrypted_otp| and |
95 // |session_material| are the results of the EncryptOtp call. | 109 // |session_material| are the results of the EncryptOtp call. |
96 void GetFullWallet(const std::string& instrument_id, | 110 void GetFullWallet(const std::string& instrument_id, |
97 const std::string& address_id, | 111 const std::string& address_id, |
98 const std::string& merchant_domain, | 112 const std::string& merchant_domain, |
99 const Cart& cart, | 113 const Cart& cart, |
(...skipping 14 matching lines...) Expand all Loading... |
114 WalletClientObserver* observer); | 128 WalletClientObserver* observer); |
115 | 129 |
116 private: | 130 private: |
117 // TODO(ahutter): Implement this. | 131 // TODO(ahutter): Implement this. |
118 std::string GetRiskParams() { return ""; } | 132 std::string GetRiskParams() { return ""; } |
119 | 133 |
120 enum RequestType { | 134 enum RequestType { |
121 NO_PENDING_REQUEST, | 135 NO_PENDING_REQUEST, |
122 ACCEPT_LEGAL_DOCUMENTS, | 136 ACCEPT_LEGAL_DOCUMENTS, |
123 ENCRYPT_OTP, | 137 ENCRYPT_OTP, |
| 138 ESCROW_SENSITIVE_INFORMATION, |
124 GET_FULL_WALLET, | 139 GET_FULL_WALLET, |
125 GET_WALLET_ITEMS, | 140 GET_WALLET_ITEMS, |
126 SEND_STATUS, | 141 SEND_STATUS, |
127 }; | 142 }; |
128 | 143 |
129 void MakeWalletRequest(const GURL& url, | 144 void MakeWalletRequest(const GURL& url, |
130 const std::string& post_body, | 145 const std::string& post_body, |
131 WalletClient::WalletClientObserver* observer, | 146 WalletClient::WalletClientObserver* observer, |
132 const std::string& content_type); | 147 const std::string& content_type); |
133 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 148 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
134 | 149 |
135 // The context for the request. Ensures the gdToken cookie is set as a header | 150 // The context for the request. Ensures the gdToken cookie is set as a header |
136 // in the requests to Online Wallet if it is present. | 151 // in the requests to Online Wallet if it is present. |
137 scoped_refptr<net::URLRequestContextGetter> context_getter_; | 152 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
138 // Observer class that has its various On* methods called based on the results | 153 // Observer class that has its various On* methods called based on the results |
139 // of a request to Online Wallet. | 154 // of a request to Online Wallet. |
140 WalletClientObserver* observer_; | 155 WalletClientObserver* observer_; |
141 // The current request object. | 156 // The current request object. |
142 scoped_ptr<net::URLFetcher> request_; | 157 scoped_ptr<net::URLFetcher> request_; |
143 // The type of the current request. Must be NO_PENDING_REQUEST for a request | 158 // The type of the current request. Must be NO_PENDING_REQUEST for a request |
144 // to be initiated as only one request may be running at a given time. | 159 // to be initiated as only one request may be running at a given time. |
145 RequestType request_type_; | 160 RequestType request_type_; |
146 DISALLOW_COPY_AND_ASSIGN(WalletClient); | 161 DISALLOW_COPY_AND_ASSIGN(WalletClient); |
147 }; | 162 }; |
148 | 163 |
149 } // namespace wallet | 164 } // namespace wallet |
150 | 165 |
151 #endif // CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_ | 166 #endif // CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_ |
152 | 167 |
OLD | NEW |