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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 10 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
11 #include "chrome/browser/autofill/validation_rules_storage_factory.h" | 11 #include "chrome/browser/autofill/validation_rules_storage_factory.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/payments/ssl_validity_checker.h" | 13 #include "chrome/browser/payments/ssl_validity_checker.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/signin/signin_manager_factory.h" |
15 #include "chrome/browser/ui/browser_dialogs.h" | 16 #include "chrome/browser/ui/browser_dialogs.h" |
16 #include "components/autofill/core/browser/personal_data_manager.h" | 17 #include "components/autofill/core/browser/personal_data_manager.h" |
17 #include "components/autofill/core/browser/region_combobox_model.h" | 18 #include "components/autofill/core/browser/region_combobox_model.h" |
| 19 #include "components/payments/content/payment_prefs.h" |
18 #include "components/payments/content/payment_request_dialog.h" | 20 #include "components/payments/content/payment_request_dialog.h" |
| 21 #include "components/prefs/pref_service.h" |
| 22 #include "components/signin/core/browser/signin_manager.h" |
19 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
20 #include "third_party/libaddressinput/chromium/chrome_metadata_source.h" | 24 #include "third_party/libaddressinput/chromium/chrome_metadata_source.h" |
21 #include "third_party/libaddressinput/chromium/chrome_storage_impl.h" | 25 #include "third_party/libaddressinput/chromium/chrome_storage_impl.h" |
22 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/preload_su
pplier.h" | 26 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/preload_su
pplier.h" |
23 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/region_dat
a.h" | 27 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/region_dat
a.h" |
24 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/region_dat
a_builder.h" | 28 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/region_dat
a_builder.h" |
25 | 29 |
26 namespace payments { | 30 namespace payments { |
27 | 31 |
28 namespace { | 32 namespace { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 185 } |
182 | 186 |
183 AddressNormalizer* ChromePaymentRequestDelegate::GetAddressNormalizer() { | 187 AddressNormalizer* ChromePaymentRequestDelegate::GetAddressNormalizer() { |
184 return &address_normalizer_; | 188 return &address_normalizer_; |
185 } | 189 } |
186 | 190 |
187 ukm::UkmService* ChromePaymentRequestDelegate::GetUkmService() { | 191 ukm::UkmService* ChromePaymentRequestDelegate::GetUkmService() { |
188 return g_browser_process->ukm_service(); | 192 return g_browser_process->ukm_service(); |
189 } | 193 } |
190 | 194 |
| 195 std::string ChromePaymentRequestDelegate::GetAuthenticatedEmail() const { |
| 196 // Check if the profile is authenticated. Guest profiles or incognito |
| 197 // windows may not have a sign in manager, and are considered not |
| 198 // authenticated. |
| 199 Profile* profile = |
| 200 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
| 201 SigninManagerBase* signin_manager = |
| 202 SigninManagerFactory::GetForProfile(profile); |
| 203 if (signin_manager && signin_manager->IsAuthenticated()) |
| 204 return signin_manager->GetAuthenticatedAccountInfo().email; |
| 205 |
| 206 return std::string(); |
| 207 } |
| 208 |
| 209 void ChromePaymentRequestDelegate::MarkFirstTransactionAsCompleted() { |
| 210 Profile::FromBrowserContext(web_contents_->GetBrowserContext()) |
| 211 ->GetPrefs() |
| 212 ->SetBoolean(kPaymentsFirstTransactionCompleted, true); |
| 213 } |
| 214 |
191 } // namespace payments | 215 } // namespace payments |
OLD | NEW |