OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 }; | 51 }; |
52 | 52 |
53 // PaymentsClient issues Payments RPCs and manages responses and failure | 53 // PaymentsClient issues Payments RPCs and manages responses and failure |
54 // conditions. Only one request may be active at a time. Initiating a new | 54 // conditions. Only one request may be active at a time. Initiating a new |
55 // request will cancel a pending request. | 55 // request will cancel a pending request. |
56 // Tests are located in | 56 // Tests are located in |
57 // src/components/autofill/content/browser/payments/payments_client_unittest.cc. | 57 // src/components/autofill/content/browser/payments/payments_client_unittest.cc. |
58 class PaymentsClient : public net::URLFetcherDelegate, | 58 class PaymentsClient : public net::URLFetcherDelegate, |
59 public OAuth2TokenService::Consumer { | 59 public OAuth2TokenService::Consumer { |
60 public: | 60 public: |
| 61 // The name of the field used to send names as part of an address. Used in the |
| 62 // implementation and in tests which verify that this value is set or not at |
| 63 // appropriate times. |
| 64 static const std::string kRecipientName; |
| 65 |
61 // A collection of the information required to make a credit card unmask | 66 // A collection of the information required to make a credit card unmask |
62 // request. | 67 // request. |
63 struct UnmaskRequestDetails { | 68 struct UnmaskRequestDetails { |
64 UnmaskRequestDetails(); | 69 UnmaskRequestDetails(); |
65 ~UnmaskRequestDetails(); | 70 ~UnmaskRequestDetails(); |
66 | 71 |
67 CreditCard card; | 72 CreditCard card; |
68 std::string risk_data; | 73 std::string risk_data; |
69 CardUnmaskDelegate::UnmaskResponse user_response; | 74 CardUnmaskDelegate::UnmaskResponse user_response; |
70 }; | 75 }; |
(...skipping 25 matching lines...) Expand all Loading... |
96 // requests. Called as an optimization, but not strictly necessary. Should | 101 // requests. Called as an optimization, but not strictly necessary. Should |
97 // *not* be called in advance of GetUploadDetails or UploadCard because | 102 // *not* be called in advance of GetUploadDetails or UploadCard because |
98 // identifying information should not be sent until the user has explicitly | 103 // identifying information should not be sent until the user has explicitly |
99 // accepted an upload prompt. | 104 // accepted an upload prompt. |
100 void Prepare(); | 105 void Prepare(); |
101 | 106 |
102 // The user has attempted to unmask a card with the given cvc. | 107 // The user has attempted to unmask a card with the given cvc. |
103 void UnmaskCard(const UnmaskRequestDetails& request_details); | 108 void UnmaskCard(const UnmaskRequestDetails& request_details); |
104 | 109 |
105 // Determine if the user meets the Payments service's conditions for upload. | 110 // Determine if the user meets the Payments service's conditions for upload. |
106 // If so, the required legal message for display will be returned via | 111 // The service uses |addresses| (from which names are removed) and |
107 // OnDidGetUploadDetails. | 112 // |app_locale| to determine which legal message to display. If the conditions |
108 virtual void GetUploadDetails(const std::string& app_locale); | 113 // are met, the legal message will be returned via OnDidGetUploadDetails. |
| 114 virtual void GetUploadDetails(const std::vector<AutofillProfile>& addresses, |
| 115 const std::string& app_locale); |
109 | 116 |
110 // The user has indicated that they would like to upload a card with the given | 117 // The user has indicated that they would like to upload a card with the given |
111 // cvc. This request will fail server-side if a successful call to | 118 // cvc. This request will fail server-side if a successful call to |
112 // GetUploadDetails has not already been made. | 119 // GetUploadDetails has not already been made. |
113 virtual void UploadCard(const UploadRequestDetails& details); | 120 virtual void UploadCard(const UploadRequestDetails& details); |
114 | 121 |
115 // Cancels and clears the current |request_|. | 122 // Cancels and clears the current |request_|. |
116 void CancelRequest(); | 123 void CancelRequest(); |
117 | 124 |
118 private: | 125 private: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 173 |
167 base::WeakPtrFactory<PaymentsClient> weak_ptr_factory_; | 174 base::WeakPtrFactory<PaymentsClient> weak_ptr_factory_; |
168 | 175 |
169 DISALLOW_COPY_AND_ASSIGN(PaymentsClient); | 176 DISALLOW_COPY_AND_ASSIGN(PaymentsClient); |
170 }; | 177 }; |
171 | 178 |
172 } // namespace payments | 179 } // namespace payments |
173 } // namespace autofill | 180 } // namespace autofill |
174 | 181 |
175 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_ | 182 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_ |
OLD | NEW |