| 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 "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 8 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser_dialogs.h" | 11 #include "chrome/browser/ui/browser_dialogs.h" |
| 12 #include "components/autofill/content/browser/content_autofill_driver.h" |
| 13 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
| 12 #include "components/payments/content/payment_request_dialog.h" | 14 #include "components/payments/content/payment_request_dialog.h" |
| 13 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 14 | 16 |
| 15 namespace payments { | 17 namespace payments { |
| 16 | 18 |
| 17 ChromePaymentRequestDelegate::ChromePaymentRequestDelegate( | 19 ChromePaymentRequestDelegate::ChromePaymentRequestDelegate( |
| 18 content::WebContents* web_contents) | 20 content::WebContents* web_contents) |
| 19 : dialog_(nullptr), web_contents_(web_contents) {} | 21 : dialog_(nullptr), web_contents_(web_contents) {} |
| 20 | 22 |
| 21 void ChromePaymentRequestDelegate::ShowDialog(PaymentRequest* request) { | 23 void ChromePaymentRequestDelegate::ShowDialog(PaymentRequest* request) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 40 const std::string& ChromePaymentRequestDelegate::GetApplicationLocale() const { | 42 const std::string& ChromePaymentRequestDelegate::GetApplicationLocale() const { |
| 41 return g_browser_process->GetApplicationLocale(); | 43 return g_browser_process->GetApplicationLocale(); |
| 42 } | 44 } |
| 43 | 45 |
| 44 bool ChromePaymentRequestDelegate::IsIncognito() const { | 46 bool ChromePaymentRequestDelegate::IsIncognito() const { |
| 45 Profile* profile = | 47 Profile* profile = |
| 46 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 48 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
| 47 return profile && profile->GetProfileType() == Profile::INCOGNITO_PROFILE; | 49 return profile && profile->GetProfileType() == Profile::INCOGNITO_PROFILE; |
| 48 } | 50 } |
| 49 | 51 |
| 52 void ChromePaymentRequestDelegate::DoFullCardRequest( |
| 53 const autofill::CreditCard& credit_card, |
| 54 base::WeakPtr<autofill::payments::FullCardRequest::ResultDelegate> |
| 55 result_delegate) { |
| 56 autofill::ContentAutofillDriverFactory* factory = |
| 57 autofill::ContentAutofillDriverFactory::FromWebContents(web_contents_); |
| 58 autofill::ContentAutofillDriver* driver = |
| 59 factory->DriverForFrame(web_contents_->GetMainFrame()); |
| 60 autofill::payments::FullCardRequest* request = |
| 61 driver->autofill_manager()->GetOrCreateFullCardRequest(); |
| 62 |
| 63 request->GetFullCard( |
| 64 credit_card, autofill::AutofillClient::UNMASK_FOR_PAYMENT_REQUEST, |
| 65 result_delegate, dialog_->GetFullCardRequestUIDelegate()); |
| 66 } |
| 67 |
| 50 } // namespace payments | 68 } // namespace payments |
| OLD | NEW |