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