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

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

Issue 2970233002: [Payment Request] Adds a JourneyLogger instance to the PaymentRequest (Closed)
Patch Set: Initial 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 #ifndef IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_ 5 #ifndef IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_
6 #define IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_ 6 #define IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "components/autofill/core/browser/credit_card.h" 16 #include "components/autofill/core/browser/credit_card.h"
17 #include "components/payments/core/journey_logger.h"
17 #include "components/payments/core/payment_options_provider.h" 18 #include "components/payments/core/payment_options_provider.h"
18 #include "components/payments/core/payment_request_base_delegate.h" 19 #include "components/payments/core/payment_request_base_delegate.h"
19 #include "components/payments/core/payments_profile_comparator.h" 20 #include "components/payments/core/payments_profile_comparator.h"
20 #include "ios/web/public/payments/payment_request.h" 21 #include "ios/web/public/payments/payment_request.h"
21 22
22 namespace autofill { 23 namespace autofill {
23 class AutofillProfile; 24 class AutofillProfile;
24 class PersonalDataManager; 25 class PersonalDataManager;
25 class RegionDataLoader; 26 class RegionDataLoader;
26 } // namespace autofill 27 } // namespace autofill
27 28
28 namespace payments { 29 namespace payments {
29 class AddressNormalizer; 30 class AddressNormalizer;
30 class AddressNormalizerImpl; 31 class AddressNormalizerImpl;
31 class CurrencyFormatter; 32 class CurrencyFormatter;
32 class PaymentInstrument; 33 class PaymentInstrument;
33 class AutofillPaymentInstrument; 34 class AutofillPaymentInstrument;
34 } // namespace payments 35 } // namespace payments
35 36
36 namespace ios { 37 namespace ios {
37 class ChromeBrowserState; 38 class ChromeBrowserState;
38 } // namepsace ios 39 } // namepsace ios
39 40
41 namespace web {
42 class WebState;
43 } // namespace web
44
40 // A protocol implementd by any UI classes that the PaymentRequest object 45 // A protocol implementd by any UI classes that the PaymentRequest object
41 // needs to communicate with in order to perform certain actions such as 46 // needs to communicate with in order to perform certain actions such as
42 // initiating UI to request full card details for payment. 47 // initiating UI to request full card details for payment.
43 @protocol PaymentRequestUIDelegate<NSObject> 48 @protocol PaymentRequestUIDelegate<NSObject>
44 49
45 - (void) 50 - (void)
46 requestFullCreditCard:(const autofill::CreditCard&)creditCard 51 requestFullCreditCard:(const autofill::CreditCard&)creditCard
47 resultDelegate: 52 resultDelegate:
48 (base::WeakPtr<autofill::payments::FullCardRequest::ResultDelegate>) 53 (base::WeakPtr<autofill::payments::FullCardRequest::ResultDelegate>)
49 resultDelegate; 54 resultDelegate;
50 55
51 @end 56 @end
52 57
53 namespace payments { 58 namespace payments {
54 59
55 // Has a copy of web::PaymentRequest as provided by the page invoking the 60 // Has a copy of web::PaymentRequest as provided by the page invoking the
56 // PaymentRequest API. Also caches credit cards and addresses provided by the 61 // PaymentRequest API. Also caches credit cards and addresses provided by the
57 // |personal_data_manager| and manages shared resources and user selections for 62 // |personal_data_manager| and manages shared resources and user selections for
58 // the current PaymentRequest flow. It must be initialized with a non-null 63 // the current PaymentRequest flow. It must be initialized with a non-null
59 // instance of |personal_data_manager| that outlives this class. 64 // instance of |personal_data_manager| that outlives this class.
60 class PaymentRequest : public PaymentOptionsProvider, 65 class PaymentRequest : public PaymentOptionsProvider,
61 public PaymentRequestBaseDelegate { 66 public PaymentRequestBaseDelegate {
62 public: 67 public:
63 // |personal_data_manager| should not be null and should outlive this object. 68 // |personal_data_manager| should not be null and should outlive this object.
64 PaymentRequest(const web::PaymentRequest& web_payment_request, 69 PaymentRequest(const web::PaymentRequest& web_payment_request,
65 ios::ChromeBrowserState* browser_state_, 70 ios::ChromeBrowserState* browser_state_,
please use gerrit instead 2017/07/06 14:52:24 Remove the trailing _ from |browser_state_| on thi
Moe 2017/07/07 02:24:53 Done.
71 web::WebState* web_state,
66 autofill::PersonalDataManager* personal_data_manager, 72 autofill::PersonalDataManager* personal_data_manager,
67 id<PaymentRequestUIDelegate> payment_request_ui_delegate); 73 id<PaymentRequestUIDelegate> payment_request_ui_delegate);
68 ~PaymentRequest() override; 74 ~PaymentRequest() override;
69 75
70 // PaymentRequestBaseDelegate: 76 // PaymentRequestBaseDelegate:
71 autofill::PersonalDataManager* GetPersonalDataManager() override; 77 autofill::PersonalDataManager* GetPersonalDataManager() override;
72 const std::string& GetApplicationLocale() const override; 78 const std::string& GetApplicationLocale() const override;
73 bool IsIncognito() const override; 79 bool IsIncognito() const override;
74 bool IsSslCertificateValid() override; 80 bool IsSslCertificateValid() override;
75 const GURL& GetLastCommittedURL() const override; 81 const GURL& GetLastCommittedURL() const override;
(...skipping 10 matching lines...) Expand all
86 // Returns the web::PaymentRequest that was used to build this PaymentRequest. 92 // Returns the web::PaymentRequest that was used to build this PaymentRequest.
87 const web::PaymentRequest& web_payment_request() const { 93 const web::PaymentRequest& web_payment_request() const {
88 return web_payment_request_; 94 return web_payment_request_;
89 } 95 }
90 96
91 // Returns the payment details from |web_payment_request_|. 97 // Returns the payment details from |web_payment_request_|.
92 const web::PaymentDetails& payment_details() const { 98 const web::PaymentDetails& payment_details() const {
93 return web_payment_request_.details; 99 return web_payment_request_.details;
94 } 100 }
95 101
102 // Returns the JourneyLogger for this instance.
103 const JourneyLogger& journey_logger() const { return journey_logger_; }
104
96 // Updates the payment details of the |web_payment_request_|. It also updates 105 // Updates the payment details of the |web_payment_request_|. It also updates
97 // the cached references to the shipping options in |web_payment_request_| as 106 // the cached references to the shipping options in |web_payment_request_| as
98 // well as the reference to the selected shipping option. 107 // well as the reference to the selected shipping option.
99 void UpdatePaymentDetails(const web::PaymentDetails& details); 108 void UpdatePaymentDetails(const web::PaymentDetails& details);
100 109
101 // PaymentOptionsProvider: 110 // PaymentOptionsProvider:
102 bool request_shipping() const override; 111 bool request_shipping() const override;
103 bool request_payer_name() const override; 112 bool request_payer_name() const override;
104 bool request_payer_phone() const override; 113 bool request_payer_phone() const override;
105 bool request_payer_email() const override; 114 bool request_payer_email() const override;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 void SetSelectedShippingOption(); 246 void SetSelectedShippingOption();
238 247
239 // The web::PaymentRequest object as provided by the page invoking the Payment 248 // The web::PaymentRequest object as provided by the page invoking the Payment
240 // Request API, owned by this object. 249 // Request API, owned by this object.
241 web::PaymentRequest web_payment_request_; 250 web::PaymentRequest web_payment_request_;
242 251
243 // Never null and outlives this object. 252 // Never null and outlives this object.
244 ios::ChromeBrowserState* browser_state_; 253 ios::ChromeBrowserState* browser_state_;
245 254
246 // Never null and outlives this object. 255 // Never null and outlives this object.
256 web::WebState* web_state_;
257
258 // Never null and outlives this object.
247 autofill::PersonalDataManager* personal_data_manager_; 259 autofill::PersonalDataManager* personal_data_manager_;
248 260
249 // The PaymentRequestUIDelegate as provided by the UI object that originally 261 // The PaymentRequestUIDelegate as provided by the UI object that originally
250 // created this PaymentRequest object. 262 // created this PaymentRequest object.
251 __weak id<PaymentRequestUIDelegate> payment_request_ui_delegate_; 263 __weak id<PaymentRequestUIDelegate> payment_request_ui_delegate_;
252 264
253 // The address normalizer to use for the duration of the Payment Request. 265 // The address normalizer to use for the duration of the Payment Request.
254 AddressNormalizerImpl* address_normalizer_; 266 AddressNormalizerImpl* address_normalizer_;
255 267
256 // The currency formatter instance for this PaymentRequest flow. 268 // The currency formatter instance for this PaymentRequest flow.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 304
293 // The set of supported card types (e.g., credit, debit, prepaid). 305 // The set of supported card types (e.g., credit, debit, prepaid).
294 std::set<autofill::CreditCard::CardType> supported_card_types_set_; 306 std::set<autofill::CreditCard::CardType> supported_card_types_set_;
295 307
296 // A vector of pointers to the shipping options in |web_payment_request_|. 308 // A vector of pointers to the shipping options in |web_payment_request_|.
297 std::vector<web::PaymentShippingOption*> shipping_options_; 309 std::vector<web::PaymentShippingOption*> shipping_options_;
298 web::PaymentShippingOption* selected_shipping_option_; 310 web::PaymentShippingOption* selected_shipping_option_;
299 311
300 PaymentsProfileComparator profile_comparator_; 312 PaymentsProfileComparator profile_comparator_;
301 313
314 // Keeps track of different stats during the lifetime of this object.
315 JourneyLogger journey_logger_;
316
302 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); 317 DISALLOW_COPY_AND_ASSIGN(PaymentRequest);
303 }; 318 };
304 319
305 } // namespace payments 320 } // namespace payments
306 321
307 #endif // IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_ 322 #endif // IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698