| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/ui/views/payments/test_chrome_payment_request_delegate.
h" | 5 #include "chrome/browser/ui/views/payments/test_chrome_payment_request_delegate.
h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "ui/views/widget/widget.h" | |
| 11 #include "ui/views/widget/widget_observer.h" | |
| 12 | 10 |
| 13 namespace payments { | 11 namespace payments { |
| 14 | 12 |
| 15 TestChromePaymentRequestDelegate::TestChromePaymentRequestDelegate( | 13 TestChromePaymentRequestDelegate::TestChromePaymentRequestDelegate( |
| 16 content::WebContents* web_contents, | 14 content::WebContents* web_contents, |
| 17 PaymentRequestDialogView::ObserverForTest* observer, | 15 PaymentRequestDialogView::ObserverForTest* observer, |
| 18 views::WidgetObserver* widget_observer, | |
| 19 bool is_incognito, | 16 bool is_incognito, |
| 20 bool is_valid_ssl) | 17 bool is_valid_ssl) |
| 21 : ChromePaymentRequestDelegate(web_contents), | 18 : ChromePaymentRequestDelegate(web_contents), |
| 22 region_data_loader_(nullptr), | 19 region_data_loader_(nullptr), |
| 23 observer_(observer), | 20 observer_(observer), |
| 24 widget_observer_(widget_observer), | |
| 25 is_incognito_(is_incognito), | 21 is_incognito_(is_incognito), |
| 26 is_valid_ssl_(is_valid_ssl) {} | 22 is_valid_ssl_(is_valid_ssl) {} |
| 27 | 23 |
| 28 void TestChromePaymentRequestDelegate::ShowDialog(PaymentRequest* request) { | 24 void TestChromePaymentRequestDelegate::ShowDialog(PaymentRequest* request) { |
| 29 PaymentRequestDialogView* dialog_view = | 25 PaymentRequestDialogView* dialog_view = |
| 30 new PaymentRequestDialogView(request, observer_); | 26 new PaymentRequestDialogView(request, observer_); |
| 31 dialog_view->ShowDialog(); | 27 dialog_view->ShowDialog(); |
| 32 | |
| 33 // The widget is now valid, so register its observer. | |
| 34 views::Widget* widget = dialog_view->GetWidget(); | |
| 35 widget->AddObserver(widget_observer_); | |
| 36 | |
| 37 dialog_ = std::move(dialog_view); | 28 dialog_ = std::move(dialog_view); |
| 38 } | 29 } |
| 39 | 30 |
| 40 bool TestChromePaymentRequestDelegate::IsIncognito() const { | 31 bool TestChromePaymentRequestDelegate::IsIncognito() const { |
| 41 return is_incognito_; | 32 return is_incognito_; |
| 42 } | 33 } |
| 43 | 34 |
| 44 bool TestChromePaymentRequestDelegate::IsSslCertificateValid() { | 35 bool TestChromePaymentRequestDelegate::IsSslCertificateValid() { |
| 45 return is_valid_ssl_; | 36 return is_valid_ssl_; |
| 46 } | 37 } |
| 47 | 38 |
| 48 autofill::RegionDataLoader* | 39 autofill::RegionDataLoader* |
| 49 TestChromePaymentRequestDelegate::GetRegionDataLoader() { | 40 TestChromePaymentRequestDelegate::GetRegionDataLoader() { |
| 50 if (region_data_loader_) | 41 if (region_data_loader_) |
| 51 return region_data_loader_; | 42 return region_data_loader_; |
| 52 return ChromePaymentRequestDelegate::GetRegionDataLoader(); | 43 return ChromePaymentRequestDelegate::GetRegionDataLoader(); |
| 53 } | 44 } |
| 54 } // namespace payments | 45 } // namespace payments |
| OLD | NEW |