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

Side by Side Diff: components/payments/payment_request.h

Issue 2643643006: [WebPayments] Adding something resembling Shipping Address list (Closed)
Patch Set: Cleanup 2 Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ 5 #ifndef COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_
6 #define COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ 6 #define COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 // Returns the CurrencyFormatter instance for this PaymentRequest. 53 // Returns the CurrencyFormatter instance for this PaymentRequest.
54 // |locale_name| should be the result of the browser's GetApplicationLocale(). 54 // |locale_name| should be the result of the browser's GetApplicationLocale().
55 // Note: Having multiple currencies per PaymentRequest is not supported; hence 55 // Note: Having multiple currencies per PaymentRequest is not supported; hence
56 // the CurrencyFormatter is cached here. 56 // the CurrencyFormatter is cached here.
57 CurrencyFormatter* GetOrCreateCurrencyFormatter( 57 CurrencyFormatter* GetOrCreateCurrencyFormatter(
58 const std::string& currency_code, 58 const std::string& currency_code,
59 const base::Optional<std::string> currency_system, 59 const base::Optional<std::string> currency_system,
60 const std::string& locale_name); 60 const std::string& locale_name);
61 61
62 // Returns the Autofill Profile, representing the shipping address and contact 62 // Returns the Autofill Profiles for this user. On the first invocation,
63 // information, currently selected for this PaymentRequest flow. If 63 // profiles are fetched from the PersonalDataManager; on subsequent
64 // unpopulated, populates with and returns the 0th profile on record for this 64 // invocations, a cached version is returned. The profiles returned are
65 // user, if it exists; or nullptr otherwise. Profile is owned by the request 65 // copies owned by the request object.
66 // object, not the caller. 66 std::vector<autofill::AutofillProfile*> GetProfiles();
please use gerrit instead 2017/01/20 19:32:53 It would be preferable to return a const-ref of an
tmartino 2017/01/25 00:08:41 Done.
67 autofill::AutofillProfile* GetCurrentlySelectedProfile(); 67
68 // Gets/sets the Autofill Profile representing the shipping address or contact
69 // information currently selected for this PaymentRequest flow. Getters return
70 // nullptr if no profile has been selected or otherwise populated.
71 autofill::AutofillProfile* GetSelectedShippingProfile();
72 void SetShippingProfile(autofill::AutofillProfile* profile);
73 autofill::AutofillProfile* GetSelectedContactProfile();
74 void SetContactProfile(autofill::AutofillProfile* profile);
68 75
69 // Returns the currently selected credit card for this PaymentRequest flow. 76 // Returns the currently selected credit card for this PaymentRequest flow.
70 // It's not guaranteed to be complete. Returns nullptr if there is no selected 77 // It's not guaranteed to be complete. Returns nullptr if there is no selected
71 // card. 78 // card.
72 autofill::CreditCard* GetCurrentlySelectedCreditCard(); 79 autofill::CreditCard* GetCurrentlySelectedCreditCard();
73 80
74 payments::mojom::PaymentDetails* details() { return details_.get(); } 81 payments::mojom::PaymentDetails* details() { return details_.get(); }
75 content::WebContents* web_contents() { return web_contents_; } 82 content::WebContents* web_contents() { return web_contents_; }
76 83
77 private: 84 private:
85 // Sets the default values for the selected Shipping and Contact profiles.
86 void SetDefaultProfileSelections();
87
78 content::WebContents* web_contents_; 88 content::WebContents* web_contents_;
79 std::unique_ptr<PaymentRequestDelegate> delegate_; 89 std::unique_ptr<PaymentRequestDelegate> delegate_;
80 // |manager_| owns this PaymentRequest. 90 // |manager_| owns this PaymentRequest.
81 PaymentRequestWebContentsManager* manager_; 91 PaymentRequestWebContentsManager* manager_;
82 mojo::Binding<payments::mojom::PaymentRequest> binding_; 92 mojo::Binding<payments::mojom::PaymentRequest> binding_;
83 payments::mojom::PaymentRequestClientPtr client_; 93 payments::mojom::PaymentRequestClientPtr client_;
84 payments::mojom::PaymentDetailsPtr details_; 94 payments::mojom::PaymentDetailsPtr details_;
85 std::unique_ptr<CurrencyFormatter> currency_formatter_; 95 std::unique_ptr<CurrencyFormatter> currency_formatter_;
86 std::unique_ptr<autofill::AutofillProfile> profile_; 96
97 // Profiles may change due to (e.g.) sync events, so profiles are cached after
98 // loading and owned here. They are populated once only, and ordered by
99 // frecency.
100 std::vector<std::unique_ptr<autofill::AutofillProfile>> profile_cache_;
101 autofill::AutofillProfile* selected_shipping_profile_;
102 autofill::AutofillProfile* selected_contact_profile_;
87 103
88 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); 104 DISALLOW_COPY_AND_ASSIGN(PaymentRequest);
89 }; 105 };
90 106
91 } // namespace payments 107 } // namespace payments
92 108
93 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ 109 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698