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

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

Issue 2970233002: [Payment Request] Adds a JourneyLogger instance to the PaymentRequest (Closed)
Patch Set: Addressed comments 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"
(...skipping 10 matching lines...) Expand all
21 #include "components/payments/core/payment_instrument.h" 21 #include "components/payments/core/payment_instrument.h"
22 #include "components/payments/core/payment_request_data_util.h" 22 #include "components/payments/core/payment_request_data_util.h"
23 #include "components/prefs/pref_service.h" 23 #include "components/prefs/pref_service.h"
24 #include "components/signin/core/browser/signin_manager.h" 24 #include "components/signin/core/browser/signin_manager.h"
25 #include "ios/chrome/browser/application_context.h" 25 #include "ios/chrome/browser/application_context.h"
26 #include "ios/chrome/browser/autofill/validation_rules_storage_factory.h" 26 #include "ios/chrome/browser/autofill/validation_rules_storage_factory.h"
27 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 27 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
28 #import "ios/chrome/browser/payments/payment_request_util.h" 28 #import "ios/chrome/browser/payments/payment_request_util.h"
29 #include "ios/chrome/browser/signin/signin_manager_factory.h" 29 #include "ios/chrome/browser/signin/signin_manager_factory.h"
30 #include "ios/web/public/payments/payment_request.h" 30 #include "ios/web/public/payments/payment_request.h"
31 #include "ios/web/public/web_state/web_state.h"
31 #include "third_party/libaddressinput/chromium/chrome_metadata_source.h" 32 #include "third_party/libaddressinput/chromium/chrome_metadata_source.h"
32 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h" 33 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h"
33 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h" 34 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h"
34 35
35 #if !defined(__has_feature) || !__has_feature(objc_arc) 36 #if !defined(__has_feature) || !__has_feature(objc_arc)
36 #error "This file requires ARC support." 37 #error "This file requires ARC support."
37 #endif 38 #endif
38 39
39 namespace { 40 namespace {
40 41
41 std::unique_ptr<::i18n::addressinput::Source> GetAddressInputSource( 42 std::unique_ptr<::i18n::addressinput::Source> GetAddressInputSource(
42 net::URLRequestContextGetter* url_context_getter) { 43 net::URLRequestContextGetter* url_context_getter) {
43 return std::unique_ptr<::i18n::addressinput::Source>( 44 return std::unique_ptr<::i18n::addressinput::Source>(
44 new autofill::ChromeMetadataSource(I18N_ADDRESS_VALIDATION_DATA_URL, 45 new autofill::ChromeMetadataSource(I18N_ADDRESS_VALIDATION_DATA_URL,
45 url_context_getter)); 46 url_context_getter));
46 } 47 }
47 48
48 std::unique_ptr<::i18n::addressinput::Storage> GetAddressInputStorage() { 49 std::unique_ptr<::i18n::addressinput::Storage> GetAddressInputStorage() {
49 return autofill::ValidationRulesStorageFactory::CreateStorage(); 50 return autofill::ValidationRulesStorageFactory::CreateStorage();
50 } 51 }
51 52
52 } // namespace 53 } // namespace
53 54
54 namespace payments { 55 namespace payments {
55 56
56 PaymentRequest::PaymentRequest( 57 PaymentRequest::PaymentRequest(
57 const web::PaymentRequest& web_payment_request, 58 const web::PaymentRequest& web_payment_request,
58 ios::ChromeBrowserState* browser_state, 59 ios::ChromeBrowserState* browser_state,
60 web::WebState* web_state,
59 autofill::PersonalDataManager* personal_data_manager, 61 autofill::PersonalDataManager* personal_data_manager,
60 id<PaymentRequestUIDelegate> payment_request_ui_delegate) 62 id<PaymentRequestUIDelegate> payment_request_ui_delegate)
61 : web_payment_request_(web_payment_request), 63 : web_payment_request_(web_payment_request),
62 browser_state_(browser_state), 64 browser_state_(browser_state),
65 web_state_(web_state),
63 personal_data_manager_(personal_data_manager), 66 personal_data_manager_(personal_data_manager),
64 payment_request_ui_delegate_(payment_request_ui_delegate), 67 payment_request_ui_delegate_(payment_request_ui_delegate),
65 address_normalizer_(new AddressNormalizerImpl( 68 address_normalizer_(new AddressNormalizerImpl(
66 GetAddressInputSource( 69 GetAddressInputSource(
67 personal_data_manager_->GetURLRequestContextGetter()), 70 personal_data_manager_->GetURLRequestContextGetter()),
68 GetAddressInputStorage())), 71 GetAddressInputStorage())),
69 selected_shipping_profile_(nullptr), 72 selected_shipping_profile_(nullptr),
70 selected_contact_profile_(nullptr), 73 selected_contact_profile_(nullptr),
71 selected_payment_method_(nullptr), 74 selected_payment_method_(nullptr),
72 selected_shipping_option_(nullptr), 75 selected_shipping_option_(nullptr),
73 profile_comparator_(GetApplicationContext()->GetApplicationLocale(), 76 profile_comparator_(GetApplicationContext()->GetApplicationLocale(),
74 *this) { 77 *this),
78 journey_logger_(IsIncognito(), GetLastCommittedURL(), GetUkmRecorder()) {
75 PopulateAvailableShippingOptions(); 79 PopulateAvailableShippingOptions();
76 PopulateProfileCache(); 80 PopulateProfileCache();
77 PopulateAvailableProfiles(); 81 PopulateAvailableProfiles();
78 PopulatePaymentMethodCache(); 82 PopulatePaymentMethodCache();
79 PopulateAvailablePaymentMethods(); 83 PopulateAvailablePaymentMethods();
80 84
81 SetSelectedShippingOption(); 85 SetSelectedShippingOption();
82 86
83 if (request_shipping()) { 87 if (request_shipping()) {
84 // If the merchant provided a default shipping option, and the 88 // If the merchant provided a default shipping option, and the
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 bool PaymentRequest::IsIncognito() const { 126 bool PaymentRequest::IsIncognito() const {
123 return browser_state_->IsOffTheRecord(); 127 return browser_state_->IsOffTheRecord();
124 } 128 }
125 129
126 bool PaymentRequest::IsSslCertificateValid() { 130 bool PaymentRequest::IsSslCertificateValid() {
127 NOTREACHED() << "Implementation is never used"; 131 NOTREACHED() << "Implementation is never used";
128 return false; 132 return false;
129 } 133 }
130 134
131 const GURL& PaymentRequest::GetLastCommittedURL() const { 135 const GURL& PaymentRequest::GetLastCommittedURL() const {
132 NOTREACHED() << "Implementation is never used"; 136 return web_state_->GetLastCommittedURL();
133 return GURL::EmptyGURL();
134 } 137 }
135 138
136 void PaymentRequest::DoFullCardRequest( 139 void PaymentRequest::DoFullCardRequest(
137 const autofill::CreditCard& credit_card, 140 const autofill::CreditCard& credit_card,
138 base::WeakPtr<autofill::payments::FullCardRequest::ResultDelegate> 141 base::WeakPtr<autofill::payments::FullCardRequest::ResultDelegate>
139 result_delegate) { 142 result_delegate) {
140 [payment_request_ui_delegate_ requestFullCreditCard:credit_card 143 [payment_request_ui_delegate_ requestFullCreditCard:credit_card
141 resultDelegate:result_delegate]; 144 resultDelegate:result_delegate];
142 } 145 }
143 146
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // should be treated as the selected item. 393 // should be treated as the selected item.
391 for (auto* shipping_option : base::Reversed(shipping_options_)) { 394 for (auto* shipping_option : base::Reversed(shipping_options_)) {
392 if (shipping_option->selected) { 395 if (shipping_option->selected) {
393 selected_shipping_option_ = shipping_option; 396 selected_shipping_option_ = shipping_option;
394 break; 397 break;
395 } 398 }
396 } 399 }
397 } 400 }
398 401
399 } // namespace payments 402 } // namespace payments
OLDNEW
« no previous file with comments | « ios/chrome/browser/payments/payment_request.h ('k') | ios/chrome/browser/payments/payment_request_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698