| Index: chrome/browser/autofill/wallet/wallet_client.h
|
| diff --git a/chrome/browser/autofill/wallet/wallet_client.h b/chrome/browser/autofill/wallet/wallet_client.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..203d590379a8914965514bd9984628bcdb6732b7
|
| --- /dev/null
|
| +++ b/chrome/browser/autofill/wallet/wallet_client.h
|
| @@ -0,0 +1,121 @@
|
| +// Copyright (c) 2012 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 CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_
|
| +#define CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_
|
| +
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/memory/ref_counted.h"
|
| +
|
| +namespace net {
|
| +class URLRequestContextGetter;
|
| +}
|
| +
|
| +namespace wallet {
|
| +
|
| +class Address;
|
| +class Cart;
|
| +class FullWallet;
|
| +class WalletItems;
|
| +
|
| +// WalletClient is responsible for making calls to the Online Wallet backend on
|
| +// the user's behalf.
|
| +class WalletClient {
|
| + public:
|
| + // WalletClientObserver is to be implemented any classes making calls with
|
| + // WalletClient. The appropriate callback method will be called on
|
| + // WalletClientObserver with the response from the Online Wallet backend.
|
| + class WalletClientObserver {
|
| + public:
|
| + // Called when an AcceptLegalDocuments request finishes successfully.
|
| + virtual void OnAcceptLegalDocuments() = 0;
|
| +
|
| + // Called when an EncryptOtp request finishes successfully.
|
| + virtual void OnEncryptOtp(const std::string& encrypted_otp,
|
| + const std::string& session_material) = 0;
|
| +
|
| + // Called when a GetFullWallet request finishes successfully. Caller owns
|
| + // the input pointer.
|
| + virtual void OnGetFullWallet(FullWallet* full_wallet) = 0;
|
| +
|
| + // Called when a GetWalletItems request finishes successfully. Caller owns
|
| + // the input pointer.
|
| + virtual void OnGetWalletItems(WalletItems* wallet_items) = 0;
|
| +
|
| + // Called when a SendExtendedAutofillStatus request finishes successfully.
|
| + virtual void OnSendExtendedAutofillStatus() = 0;
|
| +
|
| + // TODO(ahutter): This is going to need more arguments, probably an error
|
| + // code and a message for the user.
|
| + // Called when a request fails due to an Online Wallet error.
|
| + virtual void OnWalletError() = 0;
|
| +
|
| + // Called when a request fails due to a network error or if the response was
|
| + // invalid.
|
| + virtual void OnNetworkError(int response_code) = 0;
|
| +
|
| + protected:
|
| + virtual ~WalletClientObserver() {}
|
| + };
|
| + explicit WalletClient(net::URLRequestContextGetter* context_getter);
|
| + ~WalletClient();
|
| +
|
| + // GetWalletItems retrieves the user's online wallet. The WalletItems
|
| + // returned may require additional action such as presenting legal documents
|
| + // to the user to be accepted.
|
| + void GetWalletItems(WalletClientObserver* observer);
|
| +
|
| + // The GetWalletItems call to the Online Wallet backend may require the user
|
| + // to accept various legal documents before a FullWallet can be generated.
|
| + // The |document_ids| and |google_transaction_id| are provided in the response
|
| + // to the GetWalletItems call.
|
| + void AcceptLegalDocuments(const std::vector<std::string>& document_ids,
|
| + const std::string& google_transaction_id,
|
| + WalletClientObserver* observer);
|
| +
|
| + // Before calling GetFullWallet, the client must encrypt a one time pad,
|
| + // |otp|, of crytographically secure random bytes. These bytes must be
|
| + // generated using crypto/random.h.
|
| + void EncryptOtp(const void* otp,
|
| + size_t length,
|
| + WalletClientObserver* observer);
|
| +
|
| + // GetFullWallet retrieves the a FullWallet for the user. |instrument_id| and
|
| + // |adddress_id| should have been selected by the user in some UI,
|
| + // |merchant_domain| should come from the BrowserContext, the |cart|
|
| + // information will have been provided by the browser, |google_transaction_id|
|
| + // is the same one that GetWalletItems returns, and |encrypted_otp| and
|
| + // |session_material| are the results of the EncryptOtp call.
|
| + void GetFullWallet(const std::string& instrument_id,
|
| + const std::string& address_id,
|
| + const std::string& merchant_domain,
|
| + const Cart& cart,
|
| + const std::string& google_transaction_id,
|
| + const std::string& encrypted_otp,
|
| + const std::string& session_material,
|
| + WalletClientObserver* observer);
|
| +
|
| + // SendExtendedAutofillStatus is used for tracking the success of
|
| + // WalletClient. |success| is a flag for success, |merchant_domain| is the
|
| + // domain where the purchase occured, if the purchase was not successful
|
| + // |reason| is populated, and |google_transaction_id| is the same as the one
|
| + // provided by GetWalletItems.
|
| + void SendExtendedAutofillStatus(bool success,
|
| + const std::string& merchant_domain,
|
| + const std::string& reason,
|
| + const std::string& google_transaction_id,
|
| + WalletClientObserver* observer);
|
| +
|
| + private:
|
| + class Core;
|
| + scoped_refptr<Core> core_;
|
| + DISALLOW_COPY_AND_ASSIGN(WalletClient);
|
| +};
|
| +
|
| +} // namespace wallet
|
| +
|
| +#endif // CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_
|
| +
|
|
|