krb | 7f6421b | 2016-11-18 17:46:21 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
rouslan | 908248c | 2017-02-27 21:30:24 | [diff] [blame] | 5 | #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ |
| 6 | #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ |
mathp | f709499d | 2017-01-09 20:48:36 | [diff] [blame] | 7 | |
| 8 | #include <memory> |
tmartino | 68c0a27 | 2017-01-19 17:44:08 | [diff] [blame] | 9 | #include <vector> |
krb | 7f6421b | 2016-11-18 17:46:21 | [diff] [blame] | 10 | |
rouslan | 908248c | 2017-02-27 21:30:24 | [diff] [blame] | 11 | #include "base/macros.h" |
Anthony Vallee-Dubois | dc1dbf1a | 2017-07-17 15:01:13 | [diff] [blame] | 12 | #include "base/memory/weak_ptr.h" |
Rouslan Solomakhin | 2706470 | 2018-12-14 21:15:33 | [diff] [blame] | 13 | #include "components/payments/content/developer_console_logger.h" |
Rouslan Solomakhin | 8e9f149b2 | 2019-05-10 17:43:02 | [diff] [blame] | 14 | #include "components/payments/content/payment_handler_host.h" |
Anthony Vallee-Dubois | c7ae733 | 2017-12-19 20:44:07 | [diff] [blame] | 15 | #include "components/payments/content/payment_request_display_manager.h" |
mathp | f1a7a375 | 2017-03-15 11:23:37 | [diff] [blame] | 16 | #include "components/payments/content/payment_request_spec.h" |
| 17 | #include "components/payments/content/payment_request_state.h" |
Rouslan Solomakhin | 5d15cb1f | 2019-11-11 18:11:39 | [diff] [blame] | 18 | #include "components/payments/content/service_worker_payment_app.h" |
sebsg | 20b49d7b | 2017-05-04 20:23:17 | [diff] [blame] | 19 | #include "components/payments/core/journey_logger.h" |
Danyao Wang | 1584079 | 2020-05-07 23:52:17 | [diff] [blame] | 20 | #include "content/public/browser/global_routing_id.h" |
Gyuyoung Kim | 9cfbda3 | 2019-08-27 02:15:18 | [diff] [blame] | 21 | #include "mojo/public/cpp/bindings/receiver.h" |
| 22 | #include "mojo/public/cpp/bindings/remote.h" |
Han Leon | abbe7c90 | 2018-08-30 02:08:10 | [diff] [blame] | 23 | #include "third_party/blink/public/mojom/payments/payment_request.mojom.h" |
Rouslan Solomakhin | 6e979ab | 2017-08-30 17:30:39 | [diff] [blame] | 24 | #include "url/gurl.h" |
Rouslan Solomakhin | c71cca62 | 2020-01-31 22:15:35 | [diff] [blame] | 25 | #include "url/origin.h" |
krb | 7f6421b | 2016-11-18 17:46:21 | [diff] [blame] | 26 | |
| 27 | namespace content { |
rouslan | 69099768 | 2017-05-09 18:07:39 | [diff] [blame] | 28 | class RenderFrameHost; |
krb | 7f6421b | 2016-11-18 17:46:21 | [diff] [blame] | 29 | class WebContents; |
Rouslan Solomakhin | 115f723 | 2017-08-01 15:24:38 | [diff] [blame] | 30 | } // namespace content |
krb | 7f6421b | 2016-11-18 17:46:21 | [diff] [blame] | 31 | |
| 32 | namespace payments { |
| 33 | |
Rouslan Solomakhin | 4eea9bc2 | 2017-10-10 15:18:51 | [diff] [blame] | 34 | class ContentPaymentRequestDelegate; |
mathp | f709499d | 2017-01-09 20:48:36 | [diff] [blame] | 35 | class PaymentRequestWebContentsManager; |
| 36 | |
mathp | f1a7a375 | 2017-03-15 11:23:37 | [diff] [blame] | 37 | // This class manages the interaction between the renderer (through the |
Liquan (Max) Gu | b7fdf17e | 2020-06-19 21:38:22 | [diff] [blame] | 38 | // PaymentRequestClient and Mojo stub implementation) and the desktop Payment UI |
| 39 | // (through the PaymentRequestDelegate). The API user (merchant) specification |
| 40 | // (supported payment methods, required information, order details) is stored in |
mathp | f1a7a375 | 2017-03-15 11:23:37 | [diff] [blame] | 41 | // PaymentRequestSpec, and the current user selection state (and related data) |
Liquan (Max) Gu | b7fdf17e | 2020-06-19 21:38:22 | [diff] [blame] | 42 | // is stored in PaymentRequestState. |
mathp | 4b85b58 | 2017-03-08 21:07:16 | [diff] [blame] | 43 | class PaymentRequest : public mojom::PaymentRequest, |
Rouslan Solomakhin | 8e9f149b2 | 2019-05-10 17:43:02 | [diff] [blame] | 44 | public PaymentHandlerHost::Delegate, |
mathp | f1a7a375 | 2017-03-15 11:23:37 | [diff] [blame] | 45 | public PaymentRequestSpec::Observer, |
Rouslan Solomakhin | 6d4c1c27 | 2019-11-22 17:09:27 | [diff] [blame] | 46 | public PaymentRequestState::Delegate { |
krb | 7f6421b | 2016-11-18 17:46:21 | [diff] [blame] | 47 | public: |
mathp | 300fa54 | 2017-03-27 19:29:37 | [diff] [blame] | 48 | class ObserverForTest { |
| 49 | public: |
| 50 | virtual void OnCanMakePaymentCalled() = 0; |
gogerald | 8189d52 | 2017-09-15 17:52:18 | [diff] [blame] | 51 | virtual void OnCanMakePaymentReturned() = 0; |
Danyao Wang | ce175bf | 2018-12-21 22:35:58 | [diff] [blame] | 52 | virtual void OnHasEnrolledInstrumentCalled() = 0; |
| 53 | virtual void OnHasEnrolledInstrumentReturned() = 0; |
Sahel Sharify | fd677ff | 2020-07-08 19:01:52 | [diff] [blame] | 54 | virtual void OnAppListReady(base::WeakPtr<PaymentRequest> payment_request) { |
| 55 | } |
rouslan | 6e3cf7c6 | 2017-04-17 21:23:28 | [diff] [blame] | 56 | virtual void OnNotSupportedError() = 0; |
rouslan | b28f453 | 2017-05-08 15:41:47 | [diff] [blame] | 57 | virtual void OnConnectionTerminated() = 0; |
Anthony Vallee-Dubois | 6813c144 | 2017-05-17 19:32:56 | [diff] [blame] | 58 | virtual void OnAbortCalled() = 0; |
Sahel Sharify | 2a56b5f | 2019-11-28 19:27:19 | [diff] [blame] | 59 | virtual void OnCompleteCalled() {} |
mathp | 300fa54 | 2017-03-27 19:29:37 | [diff] [blame] | 60 | |
| 61 | protected: |
| 62 | virtual ~ObserverForTest() {} |
| 63 | }; |
| 64 | |
rouslan | 69099768 | 2017-05-09 18:07:39 | [diff] [blame] | 65 | PaymentRequest(content::RenderFrameHost* render_frame_host, |
| 66 | content::WebContents* web_contents, |
Rouslan Solomakhin | 4eea9bc2 | 2017-10-10 15:18:51 | [diff] [blame] | 67 | std::unique_ptr<ContentPaymentRequestDelegate> delegate, |
rouslan | 8fdbfb24 | 2017-03-15 01:12:49 | [diff] [blame] | 68 | PaymentRequestWebContentsManager* manager, |
Anthony Vallee-Dubois | c7ae733 | 2017-12-19 20:44:07 | [diff] [blame] | 69 | PaymentRequestDisplayManager* display_manager, |
Gyuyoung Kim | 9cfbda3 | 2019-08-27 02:15:18 | [diff] [blame] | 70 | mojo::PendingReceiver<mojom::PaymentRequest> receiver, |
mathp | 300fa54 | 2017-03-27 19:29:37 | [diff] [blame] | 71 | ObserverForTest* observer_for_testing); |
mathp | f709499d | 2017-01-09 20:48:36 | [diff] [blame] | 72 | ~PaymentRequest() override; |
krb | 7f6421b | 2016-11-18 17:46:21 | [diff] [blame] | 73 | |
rouslan | 8fdbfb24 | 2017-03-15 01:12:49 | [diff] [blame] | 74 | // mojom::PaymentRequest |
Gyuyoung Kim | 9cfbda3 | 2019-08-27 02:15:18 | [diff] [blame] | 75 | void Init(mojo::PendingRemote<mojom::PaymentRequestClient> client, |
rouslan | 8fdbfb24 | 2017-03-15 01:12:49 | [diff] [blame] | 76 | std::vector<mojom::PaymentMethodDataPtr> method_data, |
| 77 | mojom::PaymentDetailsPtr details, |
| 78 | mojom::PaymentOptionsPtr options) override; |
Rouslan Solomakhin | 9788d4b | 2019-04-09 13:10:23 | [diff] [blame] | 79 | void Show(bool is_user_gesture, bool wait_for_updated_details) override; |
Jinho Bang | be463a2 | 2018-08-02 10:26:50 | [diff] [blame] | 80 | void Retry(mojom::PaymentValidationErrorsPtr errors) override; |
mathp | 151bd31 | 2017-04-03 21:07:24 | [diff] [blame] | 81 | void UpdateWith(mojom::PaymentDetailsPtr details) override; |
Sahel Sharify | e2f88954 | 2019-12-02 22:17:48 | [diff] [blame] | 82 | void OnPaymentDetailsNotUpdated() override; |
mathp | f4bc50e | 2017-01-24 05:17:50 | [diff] [blame] | 83 | void Abort() override; |
rouslan | 8fdbfb24 | 2017-03-15 01:12:49 | [diff] [blame] | 84 | void Complete(mojom::PaymentComplete result) override; |
Danyao Wang | 03a4cbd | 2019-08-15 23:47:11 | [diff] [blame] | 85 | void CanMakePayment() override; |
Dongjun Kim | 0a7565b | 2020-08-18 09:39:46 | [diff] [blame] | 86 | void HasEnrolledInstrument() override; |
mathp | 4b85b58 | 2017-03-08 21:07:16 | [diff] [blame] | 87 | |
Rouslan Solomakhin | 8e9f149b2 | 2019-05-10 17:43:02 | [diff] [blame] | 88 | // PaymentHandlerHost::Delegate |
| 89 | bool ChangePaymentMethod(const std::string& method_name, |
| 90 | const std::string& stringified_data) override; |
Sahel Sharify | 9d98a50 | 2019-09-30 19:58:39 | [diff] [blame] | 91 | bool ChangeShippingOption(const std::string& shipping_option_id) override; |
| 92 | bool ChangeShippingAddress( |
| 93 | mojom::PaymentAddressPtr shipping_address) override; |
Rouslan Solomakhin | a480efa | 2019-05-06 15:37:22 | [diff] [blame] | 94 | |
mathp | f1a7a375 | 2017-03-15 11:23:37 | [diff] [blame] | 95 | // PaymentRequestSpec::Observer: |
mathp | 151bd31 | 2017-04-03 21:07:24 | [diff] [blame] | 96 | void OnSpecUpdated() override {} |
mathp | f1a7a375 | 2017-03-15 11:23:37 | [diff] [blame] | 97 | |
| 98 | // PaymentRequestState::Delegate: |
mathp | f1a7a375 | 2017-03-15 11:23:37 | [diff] [blame] | 99 | void OnPaymentResponseAvailable(mojom::PaymentResponsePtr response) override; |
Rouslan Solomakhin | 68429b7 | 2019-06-27 15:12:39 | [diff] [blame] | 100 | void OnPaymentResponseError(const std::string& error_message) override; |
mathp | 151bd31 | 2017-04-03 21:07:24 | [diff] [blame] | 101 | void OnShippingOptionIdSelected(std::string shipping_option_id) override; |
| 102 | void OnShippingAddressSelected(mojom::PaymentAddressPtr address) override; |
Jinho Bang | bb17815 | 2018-09-13 09:44:43 | [diff] [blame] | 103 | void OnPayerInfoSelected(mojom::PayerDetailPtr payer_info) override; |
krb | 7f6421b | 2016-11-18 17:46:21 | [diff] [blame] | 104 | |
Rouslan Solomakhin | 16ee5520 | 2017-10-03 19:04:42 | [diff] [blame] | 105 | // Called when the user explicitly cancelled the flow. Will send a message |
mathp | f4bc50e | 2017-01-24 05:17:50 | [diff] [blame] | 106 | // to the renderer which will indirectly destroy this object (through |
| 107 | // OnConnectionTerminated). |
| 108 | void UserCancelled(); |
| 109 | |
sebsg | d56b3e42 | 2017-10-20 18:08:08 | [diff] [blame] | 110 | // Called when the main frame attached to this PaymentRequest is navigating to |
| 111 | // another document, but before the PaymentRequest is destroyed. |
| 112 | void DidStartMainFrameNavigationToDifferentDocument(bool is_user_initiated); |
sebsg | 2c8558a | 2017-05-17 18:54:10 | [diff] [blame] | 113 | |
Danyao Wang | 5c38b30 | 2020-08-26 12:08:01 | [diff] [blame] | 114 | // Called when the frame attached to this PaymentRequest is about to be |
| 115 | // destroyed. This is used to clean up before the RenderFrameHost is actually |
| 116 | // destroyed because some objects held by the PaymentRequest (e.g. |
| 117 | // InternalAuthenticator) must be out-lived by the RenderFrameHost. |
| 118 | void RenderFrameDeleted(content::RenderFrameHost* render_frame_host); |
| 119 | |
mathp | f4bc50e | 2017-01-24 05:17:50 | [diff] [blame] | 120 | // As a result of a browser-side error or renderer-initiated mojo channel |
| 121 | // closure (e.g. there was an error on the renderer side, or payment was |
| 122 | // successful), this method is called. It is responsible for cleaning up, |
| 123 | // such as possibly closing the dialog. |
| 124 | void OnConnectionTerminated(); |
mathp | 6758be03 | 2017-01-13 04:49:50 | [diff] [blame] | 125 | |
mathp | d4be8de8 | 2017-03-01 00:51:48 | [diff] [blame] | 126 | // Called when the user clicks on the "Pay" button. |
| 127 | void Pay(); |
| 128 | |
Anthony Vallee-Dubois | c7ae733 | 2017-12-19 20:44:07 | [diff] [blame] | 129 | // Hide this Payment Request if it's already showing. |
| 130 | void HideIfNecessary(); |
| 131 | |
Ramin Halavati | fbfcef67 | 2020-05-21 16:33:34 | [diff] [blame] | 132 | bool IsOffTheRecord() const; |
Anthony Vallee-Dubois | 10d131a | 2018-02-22 15:41:04 | [diff] [blame] | 133 | |
Sahel Sharify | 54f5e86 | 2020-03-26 20:02:41 | [diff] [blame] | 134 | // Called when the payment handler requests to open a payment handler window. |
| 135 | void OnPaymentHandlerOpenWindowCalled(); |
| 136 | |
anthonyvd | 3d7f972 | 2016-12-07 18:43:54 | [diff] [blame] | 137 | content::WebContents* web_contents() { return web_contents_; } |
| 138 | |
Danyao Wang | 5c38b30 | 2020-08-26 12:08:01 | [diff] [blame] | 139 | const content::GlobalFrameRoutingId& initiator_frame_routing_id() { |
| 140 | return initiator_frame_routing_id_; |
| 141 | } |
| 142 | |
gogerald | 2ddfc64c | 2018-08-23 16:20:21 | [diff] [blame] | 143 | bool skipped_payment_request_ui() { return skipped_payment_request_ui_; } |
Rouslan Solomakhin | 1dca2a92 | 2019-09-06 22:25:07 | [diff] [blame] | 144 | bool is_show_user_gesture() const { return is_show_user_gesture_; } |
gogerald | 2ddfc64c | 2018-08-23 16:20:21 | [diff] [blame] | 145 | |
DongJun Kim | 54690d5 | 2020-09-26 12:07:54 | [diff] [blame^] | 146 | base::WeakPtr<PaymentRequestSpec> spec() { return spec_->AsWeakPtr(); } |
| 147 | base::WeakPtr<PaymentRequestState> state() { return state_->AsWeakPtr(); } |
mathp | d4be8de8 | 2017-03-01 00:51:48 | [diff] [blame] | 148 | |
DongJun Kim | 54690d5 | 2020-09-26 12:07:54 | [diff] [blame^] | 149 | base::WeakPtr<PaymentRequestSpec> spec() const { return spec_->AsWeakPtr(); } |
| 150 | base::WeakPtr<PaymentRequestState> state() const { |
| 151 | return state_->AsWeakPtr(); |
| 152 | } |
Anthony Vallee-Dubois | 968ae4d | 2018-03-15 16:56:36 | [diff] [blame] | 153 | |
Rouslan Solomakhin | e37ecbd0 | 2020-07-29 20:35:42 | [diff] [blame] | 154 | base::WeakPtr<PaymentRequest> GetWeakPtr(); |
| 155 | |
krb | 7f6421b | 2016-11-18 17:46:21 | [diff] [blame] | 156 | private: |
Rouslan Solomakhin | 2706470 | 2018-12-14 21:15:33 | [diff] [blame] | 157 | // Returns true after init() has been called and the mojo connection has been |
| 158 | // established. If the mojo connection gets later disconnected, this will |
| 159 | // returns false. |
| 160 | bool IsInitialized() const; |
| 161 | |
| 162 | // Returns true after show() has been called and the payment sheet is showing. |
| 163 | // If the payment sheet is later hidden, this will return false. |
| 164 | bool IsThisPaymentRequestShowing() const; |
| 165 | |
Sahel Sharify | 9120fd3 | 2019-12-05 17:16:11 | [diff] [blame] | 166 | // Returns true when there is exactly one available payment app which can |
| 167 | // provide all requested information including shipping address and payer's |
| 168 | // contact information whenever needed. |
| 169 | bool OnlySingleAppCanProvideAllRequiredInformation() const; |
| 170 | |
gogerald | 2ddfc64c | 2018-08-23 16:20:21 | [diff] [blame] | 171 | // Returns true if this payment request supports skipping the Payment Sheet. |
Sahel Sharify | 9120fd3 | 2019-12-05 17:16:11 | [diff] [blame] | 172 | // Typically, this means that exactly one payment app can provide requested |
| 173 | // information. |
Sahel Sharify | d3f1bc8 | 2019-05-21 18:48:46 | [diff] [blame] | 174 | bool SatisfiesSkipUIConstraints(); |
gogerald | 2ddfc64c | 2018-08-23 16:20:21 | [diff] [blame] | 175 | |
sebsg | fcdd13c | 2017-06-08 15:49:33 | [diff] [blame] | 176 | // Only records the abort reason if it's the first completion for this Payment |
| 177 | // Request. This is necessary since the aborts cascade into one another with |
| 178 | // the first one being the most precise. |
| 179 | void RecordFirstAbortReason(JourneyLogger::AbortReason completion_status); |
sebsg | 2c8558a | 2017-05-17 18:54:10 | [diff] [blame] | 180 | |
Danyao Wang | 03a4cbd | 2019-08-15 23:47:11 | [diff] [blame] | 181 | // The callback for PaymentRequestState::CanMakePayment. |
| 182 | void CanMakePaymentCallback(bool can_make_payment); |
gogerald | 8189d52 | 2017-09-15 17:52:18 | [diff] [blame] | 183 | |
Danyao Wang | ce175bf | 2018-12-21 22:35:58 | [diff] [blame] | 184 | // The callback for PaymentRequestState::HasEnrolledInstrument. Checks for |
| 185 | // query quota and may send QUERY_QUOTA_EXCEEDED. |
Dongjun Kim | 0a7565b | 2020-08-18 09:39:46 | [diff] [blame] | 186 | void HasEnrolledInstrumentCallback(bool has_enrolled_instrument); |
Danyao Wang | ce175bf | 2018-12-21 22:35:58 | [diff] [blame] | 187 | |
gogerald | 0a7ee6c | 2017-11-13 18:23:19 | [diff] [blame] | 188 | // The callback for PaymentRequestState::AreRequestedMethodsSupported. |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 189 | void AreRequestedMethodsSupportedCallback(bool methods_supported, |
| 190 | const std::string& error_message); |
gogerald | 0a7ee6c | 2017-11-13 18:23:19 | [diff] [blame] | 191 | |
Danyao Wang | ce175bf | 2018-12-21 22:35:58 | [diff] [blame] | 192 | // Sends either HAS_ENROLLED_INSTRUMENT or HAS_NO_ENROLLED_INSTRUMENT to the |
Danyao Wang | 4bc0606a | 2018-12-27 16:54:53 | [diff] [blame] | 193 | // renderer, depending on |has_enrolled_instrument| value. Does not check |
| 194 | // query quota so never sends QUERY_QUOTA_EXCEEDED. If |
| 195 | // |warn_localhost_or_file| is true, then sends |
Danyao Wang | ce175bf | 2018-12-21 22:35:58 | [diff] [blame] | 196 | // WARNING_HAS_ENROLLED_INSTRUMENT or WARNING_HAS_NO_ENROLLED_INSTRUMENT |
| 197 | // version of the values instead. |
| 198 | void RespondToHasEnrolledInstrumentQuery(bool has_enrolled_instrument, |
| 199 | bool warn_localhost_or_file); |
| 200 | |
Rouslan Solomakhin | 13947ae3 | 2020-05-22 15:34:29 | [diff] [blame] | 201 | void OnAbortResult(bool aborted); |
| 202 | |
krb | 7f6421b | 2016-11-18 17:46:21 | [diff] [blame] | 203 | content::WebContents* web_contents_; |
Danyao Wang | 1584079 | 2020-05-07 23:52:17 | [diff] [blame] | 204 | const content::GlobalFrameRoutingId initiator_frame_routing_id_; |
Rouslan Solomakhin | 2706470 | 2018-12-14 21:15:33 | [diff] [blame] | 205 | DeveloperConsoleLogger log_; |
Rouslan Solomakhin | 4eea9bc2 | 2017-10-10 15:18:51 | [diff] [blame] | 206 | std::unique_ptr<ContentPaymentRequestDelegate> delegate_; |
mathp | f709499d | 2017-01-09 20:48:36 | [diff] [blame] | 207 | // |manager_| owns this PaymentRequest. |
| 208 | PaymentRequestWebContentsManager* manager_; |
Anthony Vallee-Dubois | c7ae733 | 2017-12-19 20:44:07 | [diff] [blame] | 209 | PaymentRequestDisplayManager* display_manager_; |
| 210 | std::unique_ptr<PaymentRequestDisplayManager::DisplayHandle> display_handle_; |
Gyuyoung Kim | 9cfbda3 | 2019-08-27 02:15:18 | [diff] [blame] | 211 | mojo::Receiver<mojom::PaymentRequest> receiver_{this}; |
| 212 | mojo::Remote<mojom::PaymentRequestClient> client_; |
mathp | d4be8de8 | 2017-03-01 00:51:48 | [diff] [blame] | 213 | |
mathp | f1a7a375 | 2017-03-15 11:23:37 | [diff] [blame] | 214 | std::unique_ptr<PaymentRequestSpec> spec_; |
| 215 | std::unique_ptr<PaymentRequestState> state_; |
anthonyvd | 3d7f972 | 2016-12-07 18:43:54 | [diff] [blame] | 216 | |
Rouslan Solomakhin | a480efa | 2019-05-06 15:37:22 | [diff] [blame] | 217 | // The end-point for the payment handler renderer process to call into the |
| 218 | // browser process. |
DongJun Kim | 54690d5 | 2020-09-26 12:07:54 | [diff] [blame^] | 219 | std::unique_ptr<PaymentHandlerHost> payment_handler_host_; |
Rouslan Solomakhin | a480efa | 2019-05-06 15:37:22 | [diff] [blame] | 220 | |
Rouslan Solomakhin | c71cca62 | 2020-01-31 22:15:35 | [diff] [blame] | 221 | // The scheme, host, and port of the top level frame that has invoked |
| 222 | // PaymentRequest API as formatted by |
| 223 | // url_formatter::FormatUrlForSecurityDisplay(). This is what the user sees in |
| 224 | // the address bar. |
Rouslan Solomakhin | 6e979ab | 2017-08-30 17:30:39 | [diff] [blame] | 225 | const GURL top_level_origin_; |
Rouslan Solomakhin | 115f723 | 2017-08-01 15:24:38 | [diff] [blame] | 226 | |
Rouslan Solomakhin | c71cca62 | 2020-01-31 22:15:35 | [diff] [blame] | 227 | // The scheme, host, and port of the frame that has invoked PaymentRequest API |
| 228 | // as formatted by url_formatter::FormatUrlForSecurityDisplay(). This can be |
| 229 | // either the main frame or an iframe. |
Rouslan Solomakhin | 6e979ab | 2017-08-30 17:30:39 | [diff] [blame] | 230 | const GURL frame_origin_; |
rouslan | 69099768 | 2017-05-09 18:07:39 | [diff] [blame] | 231 | |
Rouslan Solomakhin | c71cca62 | 2020-01-31 22:15:35 | [diff] [blame] | 232 | // The security origin of the frame that has invoked PaymentRequest API. This |
| 233 | // can be opaque. Used by security features like 'Sec-Fetch-Site' and |
| 234 | // 'Cross-Origin-Resource-Policy'. |
| 235 | const url::Origin frame_security_origin_; |
| 236 | |
mathp | 300fa54 | 2017-03-27 19:29:37 | [diff] [blame] | 237 | // May be null, must outlive this object. |
| 238 | ObserverForTest* observer_for_testing_; |
| 239 | |
sebsg | 20b49d7b | 2017-05-04 20:23:17 | [diff] [blame] | 240 | JourneyLogger journey_logger_; |
| 241 | |
sebsg | fcdd13c | 2017-06-08 15:49:33 | [diff] [blame] | 242 | // Whether a completion was already recorded for this Payment Request. |
| 243 | bool has_recorded_completion_ = false; |
sebsg | 2c8558a | 2017-05-17 18:54:10 | [diff] [blame] | 244 | |
Rouslan Solomakhin | 833f851 | 2018-04-03 23:19:25 | [diff] [blame] | 245 | // Whether PaymentRequest.show() was invoked with a user gesture. |
| 246 | bool is_show_user_gesture_ = false; |
| 247 | |
gogerald | 2ddfc64c | 2018-08-23 16:20:21 | [diff] [blame] | 248 | // Whether PaymentRequest.show() was invoked by skipping payment request UI. |
| 249 | bool skipped_payment_request_ui_ = false; |
| 250 | |
Rouslan Solomakhin | 2706470 | 2018-12-14 21:15:33 | [diff] [blame] | 251 | // Whether PaymentRequest mojo connection has been initialized from the |
| 252 | // renderer. |
| 253 | bool is_initialized_ = false; |
| 254 | |
| 255 | // Whether PaymentRequest.show() has been called. |
| 256 | bool is_show_called_ = false; |
| 257 | |
Rouslan Solomakhin | 55db827 | 2019-06-25 18:16:28 | [diff] [blame] | 258 | // If not empty, use this error message for rejecting PaymentRequest.show(). |
Rouslan Solomakhin | 68429b7 | 2019-06-27 15:12:39 | [diff] [blame] | 259 | std::string reject_show_error_message_; |
Rouslan Solomakhin | 55db827 | 2019-06-25 18:16:28 | [diff] [blame] | 260 | |
Jeremy Roman | 5c341f6d | 2019-07-15 15:56:10 | [diff] [blame] | 261 | base::WeakPtrFactory<PaymentRequest> weak_ptr_factory_{this}; |
Anthony Vallee-Dubois | dc1dbf1a | 2017-07-17 15:01:13 | [diff] [blame] | 262 | |
mathp | f709499d | 2017-01-09 20:48:36 | [diff] [blame] | 263 | DISALLOW_COPY_AND_ASSIGN(PaymentRequest); |
krb | 7f6421b | 2016-11-18 17:46:21 | [diff] [blame] | 264 | }; |
| 265 | |
| 266 | } // namespace payments |
| 267 | |
rouslan | 908248c | 2017-02-27 21:30:24 | [diff] [blame] | 268 | #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ |