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 names of the fields used to send non-location elements as part of an |
| 62 // address. Used in the implementation and in tests which verify that these |
| 63 // values are set or not at appropriate times. |
| 64 static const char kRecipientName[]; |
| 65 static const char kPhoneNumber[]; |
| 66 |
61 // A collection of the information required to make a credit card unmask | 67 // A collection of the information required to make a credit card unmask |
62 // request. | 68 // request. |
63 struct UnmaskRequestDetails { | 69 struct UnmaskRequestDetails { |
64 UnmaskRequestDetails(); | 70 UnmaskRequestDetails(); |
65 ~UnmaskRequestDetails(); | 71 ~UnmaskRequestDetails(); |
66 | 72 |
67 CreditCard card; | 73 CreditCard card; |
68 std::string risk_data; | 74 std::string risk_data; |
69 CardUnmaskDelegate::UnmaskResponse user_response; | 75 CardUnmaskDelegate::UnmaskResponse user_response; |
70 }; | 76 }; |
(...skipping 25 matching lines...) Expand all Loading... |
96 // requests. Called as an optimization, but not strictly necessary. Should | 102 // requests. Called as an optimization, but not strictly necessary. Should |
97 // *not* be called in advance of GetUploadDetails or UploadCard because | 103 // *not* be called in advance of GetUploadDetails or UploadCard because |
98 // identifying information should not be sent until the user has explicitly | 104 // identifying information should not be sent until the user has explicitly |
99 // accepted an upload prompt. | 105 // accepted an upload prompt. |
100 void Prepare(); | 106 void Prepare(); |
101 | 107 |
102 // The user has attempted to unmask a card with the given cvc. | 108 // The user has attempted to unmask a card with the given cvc. |
103 void UnmaskCard(const UnmaskRequestDetails& request_details); | 109 void UnmaskCard(const UnmaskRequestDetails& request_details); |
104 | 110 |
105 // Determine if the user meets the Payments service's conditions for upload. | 111 // 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 | 112 // The service uses |addresses| (from which names and phone numbers are |
| 113 // removed) and |app_locale| to determine which legal message to display. If |
| 114 // the conditions are met, the legal message will be returned via |
107 // OnDidGetUploadDetails. | 115 // OnDidGetUploadDetails. |
108 virtual void GetUploadDetails(const std::string& app_locale); | 116 virtual void GetUploadDetails(const std::vector<AutofillProfile>& addresses, |
| 117 const std::string& app_locale); |
109 | 118 |
110 // The user has indicated that they would like to upload a card with the given | 119 // 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 | 120 // cvc. This request will fail server-side if a successful call to |
112 // GetUploadDetails has not already been made. | 121 // GetUploadDetails has not already been made. |
113 virtual void UploadCard(const UploadRequestDetails& details); | 122 virtual void UploadCard(const UploadRequestDetails& details); |
114 | 123 |
115 // Cancels and clears the current |request_|. | 124 // Cancels and clears the current |request_|. |
116 void CancelRequest(); | 125 void CancelRequest(); |
117 | 126 |
118 private: | 127 private: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 175 |
167 base::WeakPtrFactory<PaymentsClient> weak_ptr_factory_; | 176 base::WeakPtrFactory<PaymentsClient> weak_ptr_factory_; |
168 | 177 |
169 DISALLOW_COPY_AND_ASSIGN(PaymentsClient); | 178 DISALLOW_COPY_AND_ASSIGN(PaymentsClient); |
170 }; | 179 }; |
171 | 180 |
172 } // namespace payments | 181 } // namespace payments |
173 } // namespace autofill | 182 } // namespace autofill |
174 | 183 |
175 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_ | 184 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_ |
OLD | NEW |