Chromium Code Reviews| 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" |
|
please use gerrit instead
2017/03/30 13:14:09
Already included in the header, so not needed in h
anthonyvd
2017/03/30 15:43:40
Done.
| |
| 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 23 matching lines...) Expand all Loading... | |
| 45 const std::string& ChromePaymentRequestDelegate::GetApplicationLocale() const { | 47 const std::string& ChromePaymentRequestDelegate::GetApplicationLocale() const { |
| 46 return g_browser_process->GetApplicationLocale(); | 48 return g_browser_process->GetApplicationLocale(); |
| 47 } | 49 } |
| 48 | 50 |
| 49 bool ChromePaymentRequestDelegate::IsIncognito() const { | 51 bool ChromePaymentRequestDelegate::IsIncognito() const { |
| 50 Profile* profile = | 52 Profile* profile = |
| 51 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 53 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
| 52 return profile && profile->GetProfileType() == Profile::INCOGNITO_PROFILE; | 54 return profile && profile->GetProfileType() == Profile::INCOGNITO_PROFILE; |
| 53 } | 55 } |
| 54 | 56 |
| 57 void ChromePaymentRequestDelegate::DoFullCardRequest( | |
| 58 const autofill::CreditCard& credit_card, | |
| 59 base::WeakPtr<autofill::payments::FullCardRequest::ResultDelegate> | |
| 60 result_delegate) { | |
| 61 autofill::ContentAutofillDriverFactory* factory = | |
|
Mathieu
2017/03/30 14:37:32
I don't like this dependence on the AutofillManage
| |
| 62 autofill::ContentAutofillDriverFactory::FromWebContents(web_contents_); | |
| 63 autofill::ContentAutofillDriver* driver = | |
| 64 factory->DriverForFrame(web_contents_->GetMainFrame()); | |
| 65 autofill::payments::FullCardRequest* request = | |
| 66 driver->autofill_manager()->GetOrCreateFullCardRequest(); | |
| 67 | |
| 68 request->GetFullCard( | |
| 69 credit_card, autofill::AutofillClient::UNMASK_FOR_PAYMENT_REQUEST, | |
| 70 result_delegate, dialog_->GetFullCardRequestUIDelegate()); | |
| 71 } | |
| 72 | |
| 55 } // namespace payments | 73 } // namespace payments |
| OLD | NEW |