Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: ios/chrome/browser/payments/payment_request.mm

Issue 2970013003: [Payment Request] Displays appropriate footer if first transaction completed (Closed)
Patch Set: Addressed comments + rebase Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ios/chrome/browser/payments/payment_request.h" 5 #include "ios/chrome/browser/payments/payment_request.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/containers/adapters.h" 9 #include "base/containers/adapters.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "components/autofill/core/browser/autofill_data_util.h" 13 #include "components/autofill/core/browser/autofill_data_util.h"
14 #include "components/autofill/core/browser/autofill_profile.h" 14 #include "components/autofill/core/browser/autofill_profile.h"
15 #include "components/autofill/core/browser/personal_data_manager.h" 15 #include "components/autofill/core/browser/personal_data_manager.h"
16 #include "components/autofill/core/browser/region_data_loader_impl.h" 16 #include "components/autofill/core/browser/region_data_loader_impl.h"
17 #include "components/autofill/core/browser/validation.h" 17 #include "components/autofill/core/browser/validation.h"
18 #include "components/payments/core/address_normalizer_impl.h" 18 #include "components/payments/core/address_normalizer_impl.h"
19 #include "components/payments/core/currency_formatter.h" 19 #include "components/payments/core/currency_formatter.h"
20 #include "components/payments/core/payment_request_data_util.h" 20 #include "components/payments/core/payment_request_data_util.h"
21 #include "components/prefs/pref_service.h"
22 #include "components/signin/core/browser/signin_manager.h"
21 #include "ios/chrome/browser/application_context.h" 23 #include "ios/chrome/browser/application_context.h"
22 #include "ios/chrome/browser/autofill/validation_rules_storage_factory.h" 24 #include "ios/chrome/browser/autofill/validation_rules_storage_factory.h"
23 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 25 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
24 #import "ios/chrome/browser/payments/payment_request_util.h" 26 #import "ios/chrome/browser/payments/payment_request_util.h"
27 #include "ios/chrome/browser/signin/signin_manager_factory.h"
25 #include "ios/web/public/payments/payment_request.h" 28 #include "ios/web/public/payments/payment_request.h"
26 #include "third_party/libaddressinput/chromium/chrome_metadata_source.h" 29 #include "third_party/libaddressinput/chromium/chrome_metadata_source.h"
27 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h" 30 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h"
28 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h" 31 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h"
29 32
30 #if !defined(__has_feature) || !__has_feature(objc_arc) 33 #if !defined(__has_feature) || !__has_feature(objc_arc)
31 #error "This file requires ARC support." 34 #error "This file requires ARC support."
32 #endif 35 #endif
33 36
34 namespace { 37 namespace {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 .release(), 152 .release(),
150 GetAddressInputStorage().release(), 153 GetAddressInputStorage().release(),
151 GetApplicationContext()->GetApplicationLocale()); 154 GetApplicationContext()->GetApplicationLocale());
152 } 155 }
153 156
154 ukm::UkmRecorder* PaymentRequest::GetUkmRecorder() { 157 ukm::UkmRecorder* PaymentRequest::GetUkmRecorder() {
155 return GetApplicationContext()->GetUkmRecorder(); 158 return GetApplicationContext()->GetUkmRecorder();
156 } 159 }
157 160
158 std::string PaymentRequest::GetAuthenticatedEmail() const { 161 std::string PaymentRequest::GetAuthenticatedEmail() const {
159 NOTREACHED() << "Implementation is never used"; 162 const SigninManager* signin_manager =
160 return std::string(); 163 ios::SigninManagerFactory::GetForBrowserStateIfExists(browser_state_);
164 if (signin_manager && signin_manager->IsAuthenticated())
165 return signin_manager->GetAuthenticatedAccountInfo().email;
166 else
167 return std::string();
161 } 168 }
162 169
163 PrefService* PaymentRequest::GetPrefService() { 170 PrefService* PaymentRequest::GetPrefService() {
164 NOTREACHED() << "Implementation is never used"; 171 return browser_state_->GetPrefs();
165 return nullptr;
166 } 172 }
167 173
168 void PaymentRequest::UpdatePaymentDetails(const web::PaymentDetails& details) { 174 void PaymentRequest::UpdatePaymentDetails(const web::PaymentDetails& details) {
169 web_payment_request_.details = details; 175 web_payment_request_.details = details;
170 PopulateAvailableShippingOptions(); 176 PopulateAvailableShippingOptions();
171 SetSelectedShippingOption(); 177 SetSelectedShippingOption();
172 } 178 }
173 179
174 bool PaymentRequest::request_shipping() const { 180 bool PaymentRequest::request_shipping() const {
175 return web_payment_request_.options.request_shipping; 181 return web_payment_request_.options.request_shipping;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 void PaymentRequest::SetSelectedShippingOption() { 368 void PaymentRequest::SetSelectedShippingOption() {
363 // If more than one option has |selected| set, the last one in the sequence 369 // If more than one option has |selected| set, the last one in the sequence
364 // should be treated as the selected item. 370 // should be treated as the selected item.
365 for (auto* shipping_option : base::Reversed(shipping_options_)) { 371 for (auto* shipping_option : base::Reversed(shipping_options_)) {
366 if (shipping_option->selected) { 372 if (shipping_option->selected) {
367 selected_shipping_option_ = shipping_option; 373 selected_shipping_option_ = shipping_option;
368 break; 374 break;
369 } 375 }
370 } 376 }
371 } 377 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/payments/BUILD.gn ('k') | ios/chrome/browser/payments/test_payment_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698