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