Chromium Code Reviews| 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 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ |
| 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ | 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "components/payments/content/payment_request_spec.h" | 12 #include "components/payments/content/payment_request_spec.h" |
| 13 #include "components/payments/content/payment_request_state.h" | 13 #include "components/payments/content/payment_request_state.h" |
| 14 #include "components/payments/core/journey_logger.h" | 14 #include "components/payments/core/journey_logger.h" |
| 15 #include "components/payments/core/payment_request_delegate.h" | 15 #include "components/payments/core/payment_request_delegate.h" |
| 16 #include "components/payments/mojom/payment_request.mojom.h" | 16 #include "components/payments/mojom/payment_request.mojom.h" |
| 17 #include "mojo/public/cpp/bindings/binding.h" | 17 #include "mojo/public/cpp/bindings/binding.h" |
| 18 #include "mojo/public/cpp/bindings/interface_request.h" | 18 #include "mojo/public/cpp/bindings/interface_request.h" |
| 19 #include "url/gurl.h" | |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 22 class RenderFrameHost; | |
| 21 class WebContents; | 23 class WebContents; |
| 22 } | 24 } |
| 23 | 25 |
| 24 namespace payments { | 26 namespace payments { |
| 25 | 27 |
| 26 class PaymentRequestWebContentsManager; | 28 class PaymentRequestWebContentsManager; |
| 27 | 29 |
| 28 // This class manages the interaction between the renderer (through the | 30 // This class manages the interaction between the renderer (through the |
| 29 // PaymentRequestClient and Mojo stub implementation) and the UI (through the | 31 // PaymentRequestClient and Mojo stub implementation) and the UI (through the |
| 30 // PaymentRequestDelegate). The API user (merchant) specification (supported | 32 // PaymentRequestDelegate). The API user (merchant) specification (supported |
| 31 // payment methods, required information, order details) is stored in | 33 // payment methods, required information, order details) is stored in |
| 32 // PaymentRequestSpec, and the current user selection state (and related data) | 34 // PaymentRequestSpec, and the current user selection state (and related data) |
| 33 // is stored in PaymentRequestSpec. | 35 // is stored in PaymentRequestSpec. |
| 34 class PaymentRequest : public mojom::PaymentRequest, | 36 class PaymentRequest : public mojom::PaymentRequest, |
| 35 public PaymentRequestSpec::Observer, | 37 public PaymentRequestSpec::Observer, |
| 36 public PaymentRequestState::Delegate { | 38 public PaymentRequestState::Delegate { |
| 37 public: | 39 public: |
| 38 class ObserverForTest { | 40 class ObserverForTest { |
| 39 public: | 41 public: |
| 40 virtual void OnCanMakePaymentCalled() = 0; | 42 virtual void OnCanMakePaymentCalled() = 0; |
| 41 virtual void OnNotSupportedError() = 0; | 43 virtual void OnNotSupportedError() = 0; |
| 42 | 44 |
| 43 protected: | 45 protected: |
| 44 virtual ~ObserverForTest() {} | 46 virtual ~ObserverForTest() {} |
| 45 }; | 47 }; |
| 46 | 48 |
| 47 PaymentRequest(content::WebContents* web_contents, | 49 PaymentRequest(content::RenderFrameHost* render_frame_host, |
| 50 content::WebContents* web_contents, | |
| 48 std::unique_ptr<PaymentRequestDelegate> delegate, | 51 std::unique_ptr<PaymentRequestDelegate> delegate, |
| 49 PaymentRequestWebContentsManager* manager, | 52 PaymentRequestWebContentsManager* manager, |
| 50 mojo::InterfaceRequest<mojom::PaymentRequest> request, | 53 mojo::InterfaceRequest<mojom::PaymentRequest> request, |
| 51 ObserverForTest* observer_for_testing); | 54 ObserverForTest* observer_for_testing); |
| 52 ~PaymentRequest() override; | 55 ~PaymentRequest() override; |
| 53 | 56 |
| 54 // mojom::PaymentRequest | 57 // mojom::PaymentRequest |
| 55 void Init(mojom::PaymentRequestClientPtr client, | 58 void Init(mojom::PaymentRequestClientPtr client, |
| 56 std::vector<mojom::PaymentMethodDataPtr> method_data, | 59 std::vector<mojom::PaymentMethodDataPtr> method_data, |
| 57 mojom::PaymentDetailsPtr details, | 60 mojom::PaymentDetailsPtr details, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 private: | 95 private: |
| 93 content::WebContents* web_contents_; | 96 content::WebContents* web_contents_; |
| 94 std::unique_ptr<PaymentRequestDelegate> delegate_; | 97 std::unique_ptr<PaymentRequestDelegate> delegate_; |
| 95 // |manager_| owns this PaymentRequest. | 98 // |manager_| owns this PaymentRequest. |
| 96 PaymentRequestWebContentsManager* manager_; | 99 PaymentRequestWebContentsManager* manager_; |
| 97 mojo::Binding<mojom::PaymentRequest> binding_; | 100 mojo::Binding<mojom::PaymentRequest> binding_; |
| 98 mojom::PaymentRequestClientPtr client_; | 101 mojom::PaymentRequestClientPtr client_; |
| 99 | 102 |
| 100 std::unique_ptr<PaymentRequestSpec> spec_; | 103 std::unique_ptr<PaymentRequestSpec> spec_; |
| 101 std::unique_ptr<PaymentRequestState> state_; | 104 std::unique_ptr<PaymentRequestState> state_; |
| 105 const GURL iframe_origin_; | |
|
Mathieu
2017/05/08 15:28:11
couldn't it be main frame too? Should we change th
please use gerrit instead
2017/05/08 17:28:47
Done.
| |
| 102 | 106 |
| 103 // May be null, must outlive this object. | 107 // May be null, must outlive this object. |
| 104 ObserverForTest* observer_for_testing_; | 108 ObserverForTest* observer_for_testing_; |
| 105 | 109 |
| 106 JourneyLogger journey_logger_; | 110 JourneyLogger journey_logger_; |
| 107 | 111 |
| 108 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); | 112 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); |
| 109 }; | 113 }; |
| 110 | 114 |
| 111 } // namespace payments | 115 } // namespace payments |
| 112 | 116 |
| 113 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ | 117 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ |
| OLD | NEW |