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

Side by Side 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: Fixes from code review 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_
6 #define CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/memory/ref_counted.h"
12
13 namespace net {
14 class URLRequestContextGetter;
15 }
16
17 namespace wallet {
18
19 class Address;
20 class Cart;
21 class FullWallet;
22 class WalletItems;
23
24 // WalletClient is responsible for making calls to the Online Wallet backend on
25 // the user's behalf.
26 class WalletClient {
27 public:
28 // WalletClientObserver is to be implemented any classes making calls with
29 // WalletClient. The appropriate callback method will be called on
30 // WalletClientObserver with the response from the Online Wallet backend.
31 class WalletClientObserver {
32 public:
33 // Called when an AcceptLegalDocuments request finishes successfully.
34 virtual void OnAcceptLegalDocuments() = 0;
35
36 // Called when an EncryptOtp request finishes successfully.
37 virtual void OnEncryptOtp(const std::string& encrypted_otp,
38 const std::string& session_material) = 0;
39
40 // Called when a GetFullWallet request finishes successfully. Caller owns
41 // the input pointer.
42 virtual void OnGetFullWallet(FullWallet* full_wallet) = 0;
43
44 // Called when a GetWalletItems request finishes successfully. Caller owns
45 // the input pointer.
46 virtual void OnGetWalletItems(WalletItems* wallet_items) = 0;
47
48 // Called when a SendExtendedAutofillStatus request finishes successfully.
49 virtual void OnSendExtendedAutofillStatus() = 0;
50
51 // TODO(ahutter): This is going to need more arguments, probably an error
52 // code and a message for the user.
53 // Called when a request fails due to an Online Wallet error.
54 virtual void OnWalletError() = 0;
55
56 // Called when a request fails due to a network error or if the response was
57 // invalid.
58 virtual void OnNetworkError(int response_code) = 0;
59
60 protected:
61 virtual ~WalletClientObserver() {}
62 };
63 explicit WalletClient(net::URLRequestContextGetter* context_getter);
64 ~WalletClient();
65
66 // GetWalletItems retrieves the user's online wallet. The WalletItems
67 // returned may require additional action such as presenting legal documents
68 // to the user to be accepted.
69 void GetWalletItems(WalletClientObserver* observer);
70
71 // The GetWalletItems call to the Online Wallet backend may require the user
72 // to accept various legal documents before a FullWallet can be generated.
73 // The |document_ids| and |google_transaction_id| are provided in the response
74 // to the GetWalletItems call.
75 void AcceptLegalDocuments(const std::vector<std::string>& document_ids,
76 const std::string& google_transaction_id,
77 WalletClientObserver* observer);
78
79 // Before calling GetFullWallet, the client must encrypt a one time pad,
80 // |otp|, of crytographically secure random bytes. These bytes must be
81 // generated using crypto/random.h.
82 void EncryptOtp(const void* otp,
83 size_t length,
84 WalletClientObserver* observer);
85
86 // GetFullWallet retrieves the a FullWallet for the user. |instrument_id| and
87 // |adddress_id| should have been selected by the user in some UI,
88 // |merchant_domain| should come from the BrowserContext, the |cart|
89 // information will have been provided by the browser, |google_transaction_id|
90 // is the same one that GetWalletItems returns, and |encrypted_otp| and
91 // |session_material| are the results of the EncryptOtp call.
92 void GetFullWallet(const std::string& instrument_id,
93 const std::string& address_id,
94 const std::string& merchant_domain,
95 const Cart& cart,
96 const std::string& google_transaction_id,
97 const std::string& encrypted_otp,
98 const std::string& session_material,
99 WalletClientObserver* observer);
100
101 // SendExtendedAutofillStatus is used for tracking the success of
102 // WalletClient. |success| is a flag for success, |merchant_domain| is the
103 // domain where the purchase occured, if the purchase was not successful
104 // |reason| is populated, and |google_transaction_id| is the same as the one
105 // provided by GetWalletItems.
106 void SendExtendedAutofillStatus(bool success,
107 const std::string& merchant_domain,
108 const std::string& reason,
109 const std::string& google_transaction_id,
110 WalletClientObserver* observer);
111
112 private:
113 class Core;
114 scoped_refptr<Core> core_;
115 DISALLOW_COPY_AND_ASSIGN(WalletClient);
116 };
117
118 } // namespace wallet
119
120 #endif // CHROME_BROWSER_AUTOFILL_WALLET_WALLET_CLIENT_H_
121
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698