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/payments/chrome_payment_request_delegate.h" | 5 #include "chrome/browser/payments/chrome_payment_request_delegate.h" |
6 | 6 |
7 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 7 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
8 #include "chrome/browser/autofill/validation_rules_storage_factory.h" | 8 #include "chrome/browser/autofill/validation_rules_storage_factory.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/payments/ssl_validity_checker.h" | 10 #include "chrome/browser/payments/ssl_validity_checker.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser_dialogs.h" | 12 #include "chrome/browser/ui/browser_dialogs.h" |
13 #include "components/autofill/core/browser/personal_data_manager.h" | 13 #include "components/autofill/core/browser/personal_data_manager.h" |
14 #include "components/payments/content/payment_request_dialog.h" | 14 #include "components/payments/content/payment_request_dialog.h" |
15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
16 #include "third_party/libaddressinput/chromium/chrome_metadata_source.h" | 16 #include "third_party/libaddressinput/chromium/chrome_metadata_source.h" |
17 #include "third_party/libaddressinput/chromium/chrome_storage_impl.h" | 17 #include "third_party/libaddressinput/chromium/chrome_storage_impl.h" |
18 | 18 |
19 namespace payments { | 19 namespace payments { |
20 | 20 |
21 ChromePaymentRequestDelegate::ChromePaymentRequestDelegate( | 21 ChromePaymentRequestDelegate::ChromePaymentRequestDelegate( |
22 content::WebContents* web_contents) | 22 content::WebContents* web_contents) |
23 : dialog_(nullptr), | 23 : dialog_(nullptr), web_contents_(web_contents) {} |
24 web_contents_(web_contents), | |
25 address_normalizer_(GetAddressInputSource(), GetAddressInputStorage()) {} | |
26 | |
27 ChromePaymentRequestDelegate::~ChromePaymentRequestDelegate() {} | |
28 | 24 |
29 void ChromePaymentRequestDelegate::ShowDialog(PaymentRequest* request) { | 25 void ChromePaymentRequestDelegate::ShowDialog(PaymentRequest* request) { |
30 DCHECK_EQ(nullptr, dialog_); | 26 DCHECK_EQ(nullptr, dialog_); |
31 dialog_ = chrome::CreatePaymentRequestDialog(request); | 27 dialog_ = chrome::CreatePaymentRequestDialog(request); |
32 dialog_->ShowDialog(); | 28 dialog_->ShowDialog(); |
33 } | 29 } |
34 | 30 |
35 void ChromePaymentRequestDelegate::CloseDialog() { | 31 void ChromePaymentRequestDelegate::CloseDialog() { |
36 if (dialog_) { | 32 if (dialog_) { |
37 dialog_->CloseDialog(); | 33 dialog_->CloseDialog(); |
(...skipping 30 matching lines...) Expand all Loading... |
68 return web_contents_->GetLastCommittedURL(); | 64 return web_contents_->GetLastCommittedURL(); |
69 } | 65 } |
70 | 66 |
71 void ChromePaymentRequestDelegate::DoFullCardRequest( | 67 void ChromePaymentRequestDelegate::DoFullCardRequest( |
72 const autofill::CreditCard& credit_card, | 68 const autofill::CreditCard& credit_card, |
73 base::WeakPtr<autofill::payments::FullCardRequest::ResultDelegate> | 69 base::WeakPtr<autofill::payments::FullCardRequest::ResultDelegate> |
74 result_delegate) { | 70 result_delegate) { |
75 dialog_->ShowCvcUnmaskPrompt(credit_card, result_delegate, web_contents_); | 71 dialog_->ShowCvcUnmaskPrompt(credit_card, result_delegate, web_contents_); |
76 } | 72 } |
77 | 73 |
78 std::unique_ptr<::i18n::addressinput::Source> | 74 std::unique_ptr<const ::i18n::addressinput::Source> |
79 ChromePaymentRequestDelegate::GetAddressInputSource() { | 75 ChromePaymentRequestDelegate::GetAddressInputSource() { |
80 return base::WrapUnique(new autofill::ChromeMetadataSource( | 76 return base::WrapUnique(new autofill::ChromeMetadataSource( |
81 I18N_ADDRESS_VALIDATION_DATA_URL, | 77 I18N_ADDRESS_VALIDATION_DATA_URL, |
82 GetPersonalDataManager()->GetURLRequestContextGetter())); | 78 GetPersonalDataManager()->GetURLRequestContextGetter())); |
83 } | 79 } |
84 std::unique_ptr<::i18n::addressinput::Storage> | 80 std::unique_ptr<::i18n::addressinput::Storage> |
85 ChromePaymentRequestDelegate::GetAddressInputStorage() { | 81 ChromePaymentRequestDelegate::GetAddressInputStorage() { |
86 return autofill::ValidationRulesStorageFactory::CreateStorage(); | 82 return autofill::ValidationRulesStorageFactory::CreateStorage(); |
87 } | 83 } |
88 | 84 |
89 AddressNormalizer* ChromePaymentRequestDelegate::GetAddressNormalizer() { | |
90 return &address_normalizer_; | |
91 } | |
92 | |
93 } // namespace payments | 85 } // namespace payments |
OLD | NEW |