Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1570)

Unified Diff: chrome/browser/autofill/wallet/wallet_client.h

Issue 11293078: Integrating Online Wallet into Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed linter issue Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..0014fadf1050d755348d14b4a67ebf13bf62125d
--- /dev/null
+++ b/chrome/browser/autofill/wallet/wallet_client.h
@@ -0,0 +1,120 @@
+// 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 will be 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.
+ 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, the merchant
+ // domain should come from the BrowserContext, the cart information will have
+ // been provided by the browser, the google_transaction_id is the same one
+ // that GetWalletItems returns, and the 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_;
Ilya Sherman 2012/12/14 04:56:43 Why does this need to be reference counted?
ahutter 2012/12/15 01:06:31 I was emulating other users of URLFetcherDelegate.
Ilya Sherman 2012/12/15 01:23:59 If that's the only reason, then yes, please get ri
+ DISALLOW_COPY_AND_ASSIGN(WalletClient);
+};
+
+} // end wallet namespace
+
+#endif // CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_
+

Powered by Google App Engine
This is Rietveld 408576698