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

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 comment by mathp@ 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 .release(), 148 .release(),
146 GetAddressInputStorage().release(), 149 GetAddressInputStorage().release(),
147 GetApplicationContext()->GetApplicationLocale()); 150 GetApplicationContext()->GetApplicationLocale());
148 } 151 }
149 152
150 ukm::UkmRecorder* PaymentRequest::GetUkmRecorder() { 153 ukm::UkmRecorder* PaymentRequest::GetUkmRecorder() {
151 return GetApplicationContext()->GetUkmRecorder(); 154 return GetApplicationContext()->GetUkmRecorder();
152 } 155 }
153 156
154 std::string PaymentRequest::GetAuthenticatedEmail() const { 157 std::string PaymentRequest::GetAuthenticatedEmail() const {
155 NOTREACHED() << "Implementation is never used"; 158 const SigninManager* signinManager =
Eugene But (OOO till 7-30) 2017/07/05 14:47:31 s/signinManager/signin_manager
Moe 2017/07/05 16:01:46 Done.
156 return std::string(); 159 ios::SigninManagerFactory::GetForBrowserStateIfExists(browser_state_);
160 if (signinManager && signinManager->IsAuthenticated())
161 return signinManager->GetAuthenticatedAccountInfo().email;
162 else
163 return std::string();
157 } 164 }
158 165
159 PrefService* PaymentRequest::GetPrefService() { 166 PrefService* PaymentRequest::GetPrefService() {
160 NOTREACHED() << "Implementation is never used"; 167 return browser_state_->GetPrefs();
161 return nullptr;
162 } 168 }
163 169
164 void PaymentRequest::UpdatePaymentDetails(const web::PaymentDetails& details) { 170 void PaymentRequest::UpdatePaymentDetails(const web::PaymentDetails& details) {
165 web_payment_request_.details = details; 171 web_payment_request_.details = details;
166 PopulateAvailableShippingOptions(); 172 PopulateAvailableShippingOptions();
167 SetSelectedShippingOption(); 173 SetSelectedShippingOption();
168 } 174 }
169 175
170 bool PaymentRequest::request_shipping() const { 176 bool PaymentRequest::request_shipping() const {
171 return web_payment_request_.options.request_shipping; 177 return web_payment_request_.options.request_shipping;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 void PaymentRequest::SetSelectedShippingOption() { 344 void PaymentRequest::SetSelectedShippingOption() {
339 // If more than one option has |selected| set, the last one in the sequence 345 // If more than one option has |selected| set, the last one in the sequence
340 // should be treated as the selected item. 346 // should be treated as the selected item.
341 for (auto* shipping_option : base::Reversed(shipping_options_)) { 347 for (auto* shipping_option : base::Reversed(shipping_options_)) {
342 if (shipping_option->selected) { 348 if (shipping_option->selected) {
343 selected_shipping_option_ = shipping_option; 349 selected_shipping_option_ = shipping_option;
344 break; 350 break;
345 } 351 }
346 } 352 }
347 } 353 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698