| 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 CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 | 12 |
| 13 namespace views { | 13 namespace views { |
| 14 class View; | 14 class View; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace payments { | 17 namespace payments { |
| 18 | 18 |
| 19 class PaymentRequestDialog; | 19 class PaymentRequestDialog; |
| 20 class PaymentRequestImpl; | 20 class PaymentRequest; |
| 21 | 21 |
| 22 // The base class for objects responsible for the creation and event handling in | 22 // The base class for objects responsible for the creation and event handling in |
| 23 // views shown in the PaymentRequestDialog. | 23 // views shown in the PaymentRequestDialog. |
| 24 class PaymentRequestSheetController { | 24 class PaymentRequestSheetController { |
| 25 public: | 25 public: |
| 26 // Objects of this class are owned by |dialog|, so it's a non-owned pointer | 26 // Objects of this class are owned by |dialog|, so it's a non-owned pointer |
| 27 // that should be valid throughout this object's lifetime. | 27 // that should be valid throughout this object's lifetime. |
| 28 // |impl| is also not owned by this and is guaranteed to outlive dialog. | 28 // |request| is also not owned by this and is guaranteed to outlive dialog. |
| 29 // Neither |impl| or |dialog| should be null. | 29 // Neither |request| or |dialog| should be null. |
| 30 PaymentRequestSheetController(PaymentRequestImpl* impl, | 30 PaymentRequestSheetController(PaymentRequest* request, |
| 31 PaymentRequestDialog* dialog) | 31 PaymentRequestDialog* dialog) |
| 32 : impl_(impl), | 32 : request_(request), dialog_(dialog) { |
| 33 dialog_(dialog) { | 33 DCHECK(request_); |
| 34 DCHECK(impl_); | |
| 35 DCHECK(dialog_); | 34 DCHECK(dialog_); |
| 36 } | 35 } |
| 37 virtual ~PaymentRequestSheetController() {} | 36 virtual ~PaymentRequestSheetController() {} |
| 38 | 37 |
| 39 virtual std::unique_ptr<views::View> CreateView() = 0; | 38 virtual std::unique_ptr<views::View> CreateView() = 0; |
| 40 | 39 |
| 41 // The PaymentRequestImpl object associated with this instance of the dialog. | 40 // The PaymentRequest object associated with this instance of the dialog. |
| 42 // Caller should not take ownership of the result. | 41 // Caller should not take ownership of the result. |
| 43 PaymentRequestImpl* impl() { return impl_; } | 42 PaymentRequest* request() { return request_; } |
| 44 | 43 |
| 45 // The dialog that contains and owns this object. | 44 // The dialog that contains and owns this object. |
| 46 // Caller should not take ownership of the result. | 45 // Caller should not take ownership of the result. |
| 47 PaymentRequestDialog* dialog() { return dialog_; } | 46 PaymentRequestDialog* dialog() { return dialog_; } |
| 48 | 47 |
| 49 private: | 48 private: |
| 50 // Not owned. Will outlive this. | 49 // Not owned. Will outlive this. |
| 51 PaymentRequestImpl* impl_; | 50 PaymentRequest* request_; |
| 52 // Not owned. Will outlive this. | 51 // Not owned. Will outlive this. |
| 53 PaymentRequestDialog* dialog_; | 52 PaymentRequestDialog* dialog_; |
| 54 | 53 |
| 55 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); | 54 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 } // namespace payments | 57 } // namespace payments |
| 59 | 58 |
| 60 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ | 59 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ |
| OLD | NEW |