| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "components/payments/content/payment_request.h" | 5 #include "components/payments/content/payment_request.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "components/payments/content/can_make_payment_query_factory.h" | 11 #include "components/payments/content/can_make_payment_query_factory.h" |
| 12 #include "components/payments/content/origin_security_checker.h" | 12 #include "components/payments/content/origin_security_checker.h" |
| 13 #include "components/payments/content/payment_details_validation.h" | 13 #include "components/payments/content/payment_details_validation.h" |
| 14 #include "components/payments/content/payment_request_web_contents_manager.h" | 14 #include "components/payments/content/payment_request_web_contents_manager.h" |
| 15 #include "components/payments/core/can_make_payment_query.h" | 15 #include "components/payments/core/can_make_payment_query.h" |
| 16 #include "components/payments/core/payment_prefs.h" |
| 17 #include "components/prefs/pref_service.h" |
| 16 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
| 18 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 19 | 21 |
| 20 namespace payments { | 22 namespace payments { |
| 21 | 23 |
| 22 PaymentRequest::PaymentRequest( | 24 PaymentRequest::PaymentRequest( |
| 23 content::RenderFrameHost* render_frame_host, | 25 content::RenderFrameHost* render_frame_host, |
| 24 content::WebContents* web_contents, | 26 content::WebContents* web_contents, |
| 25 std::unique_ptr<PaymentRequestDelegate> delegate, | 27 std::unique_ptr<PaymentRequestDelegate> delegate, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 160 |
| 159 void PaymentRequest::Complete(mojom::PaymentComplete result) { | 161 void PaymentRequest::Complete(mojom::PaymentComplete result) { |
| 160 if (!client_.is_bound()) | 162 if (!client_.is_bound()) |
| 161 return; | 163 return; |
| 162 | 164 |
| 163 if (result != mojom::PaymentComplete::SUCCESS) { | 165 if (result != mojom::PaymentComplete::SUCCESS) { |
| 164 delegate_->ShowErrorMessage(); | 166 delegate_->ShowErrorMessage(); |
| 165 } else { | 167 } else { |
| 166 journey_logger_.RecordJourneyStatsHistograms( | 168 journey_logger_.RecordJourneyStatsHistograms( |
| 167 JourneyLogger::COMPLETION_STATUS_COMPLETED); | 169 JourneyLogger::COMPLETION_STATUS_COMPLETED); |
| 170 delegate_->GetPrefService()->SetBoolean(kPaymentsFirstTransactionCompleted, |
| 171 true); |
| 168 // When the renderer closes the connection, | 172 // When the renderer closes the connection, |
| 169 // PaymentRequest::OnConnectionTerminated will be called. | 173 // PaymentRequest::OnConnectionTerminated will be called. |
| 170 client_->OnComplete(); | 174 client_->OnComplete(); |
| 171 } | 175 } |
| 172 } | 176 } |
| 173 | 177 |
| 174 void PaymentRequest::CanMakePayment() { | 178 void PaymentRequest::CanMakePayment() { |
| 175 bool can_make_payment = state()->CanMakePayment(); | 179 bool can_make_payment = state()->CanMakePayment(); |
| 176 if (delegate_->IsIncognito()) { | 180 if (delegate_->IsIncognito()) { |
| 177 client_->OnCanMakePayment( | 181 client_->OnCanMakePayment( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 if (observer_for_testing_) | 251 if (observer_for_testing_) |
| 248 observer_for_testing_->OnConnectionTerminated(); | 252 observer_for_testing_->OnConnectionTerminated(); |
| 249 manager_->DestroyRequest(this); | 253 manager_->DestroyRequest(this); |
| 250 } | 254 } |
| 251 | 255 |
| 252 void PaymentRequest::Pay() { | 256 void PaymentRequest::Pay() { |
| 253 state_->GeneratePaymentResponse(); | 257 state_->GeneratePaymentResponse(); |
| 254 } | 258 } |
| 255 | 259 |
| 256 } // namespace payments | 260 } // namespace payments |
| OLD | NEW |