| 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" | 10 #include "ui/views/widget/widget.h" |
| 11 #include "ui/views/widget/widget_observer.h" | 11 #include "ui/views/widget/widget_observer.h" |
| 12 | 12 |
| 13 namespace payments { | 13 namespace payments { |
| 14 | 14 |
| 15 TestChromePaymentRequestDelegate::TestChromePaymentRequestDelegate( | 15 TestChromePaymentRequestDelegate::TestChromePaymentRequestDelegate( |
| 16 content::WebContents* web_contents, | 16 content::WebContents* web_contents, |
| 17 PaymentRequestDialogView::ObserverForTest* observer, | 17 PaymentRequestDialogView::ObserverForTest* observer, |
| 18 views::WidgetObserver* widget_observer, | 18 views::WidgetObserver* widget_observer, |
| 19 bool is_incognito) | 19 bool is_incognito, |
| 20 bool is_valid_ssl) |
| 20 : ChromePaymentRequestDelegate(web_contents), | 21 : ChromePaymentRequestDelegate(web_contents), |
| 21 address_input_provider_(nullptr), | 22 address_input_provider_(nullptr), |
| 22 observer_(observer), | 23 observer_(observer), |
| 23 widget_observer_(widget_observer), | 24 widget_observer_(widget_observer), |
| 24 is_incognito_for_testing_(is_incognito) {} | 25 is_incognito_(is_incognito), |
| 26 is_valid_ssl_(is_valid_ssl) {} |
| 25 | 27 |
| 26 void TestChromePaymentRequestDelegate::ShowDialog(PaymentRequest* request) { | 28 void TestChromePaymentRequestDelegate::ShowDialog(PaymentRequest* request) { |
| 27 PaymentRequestDialogView* dialog_view = | 29 PaymentRequestDialogView* dialog_view = |
| 28 new PaymentRequestDialogView(request, observer_); | 30 new PaymentRequestDialogView(request, observer_); |
| 29 dialog_view->ShowDialog(); | 31 dialog_view->ShowDialog(); |
| 30 | 32 |
| 31 // The widget is now valid, so register its observer. | 33 // The widget is now valid, so register its observer. |
| 32 views::Widget* widget = dialog_view->GetWidget(); | 34 views::Widget* widget = dialog_view->GetWidget(); |
| 33 widget->AddObserver(widget_observer_); | 35 widget->AddObserver(widget_observer_); |
| 34 | 36 |
| 35 dialog_ = std::move(dialog_view); | 37 dialog_ = std::move(dialog_view); |
| 36 } | 38 } |
| 37 | 39 |
| 38 bool TestChromePaymentRequestDelegate::IsIncognito() const { | 40 bool TestChromePaymentRequestDelegate::IsIncognito() const { |
| 39 return is_incognito_for_testing_; | 41 return is_incognito_; |
| 42 } |
| 43 |
| 44 bool TestChromePaymentRequestDelegate::IsSslCertificateValid() { |
| 45 return is_valid_ssl_; |
| 40 } | 46 } |
| 41 | 47 |
| 42 std::unique_ptr<const ::i18n::addressinput::Source> | 48 std::unique_ptr<const ::i18n::addressinput::Source> |
| 43 TestChromePaymentRequestDelegate::GetAddressInputSource() { | 49 TestChromePaymentRequestDelegate::GetAddressInputSource() { |
| 44 if (address_input_provider_) | 50 if (address_input_provider_) |
| 45 return address_input_provider_->GetAddressInputSource(); | 51 return address_input_provider_->GetAddressInputSource(); |
| 46 return ChromePaymentRequestDelegate::GetAddressInputSource(); | 52 return ChromePaymentRequestDelegate::GetAddressInputSource(); |
| 47 } | 53 } |
| 48 | 54 |
| 49 std::unique_ptr<::i18n::addressinput::Storage> | 55 std::unique_ptr<::i18n::addressinput::Storage> |
| 50 TestChromePaymentRequestDelegate::GetAddressInputStorage() { | 56 TestChromePaymentRequestDelegate::GetAddressInputStorage() { |
| 51 if (address_input_provider_) | 57 if (address_input_provider_) |
| 52 return address_input_provider_->GetAddressInputStorage(); | 58 return address_input_provider_->GetAddressInputStorage(); |
| 53 return ChromePaymentRequestDelegate::GetAddressInputStorage(); | 59 return ChromePaymentRequestDelegate::GetAddressInputStorage(); |
| 54 } | 60 } |
| 55 | 61 |
| 56 } // namespace payments | 62 } // namespace payments |
| OLD | NEW |