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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/payments/payment_request.h
diff --git a/components/payments/payment_request.h b/components/payments/payment_request.h
index 6c55cca9ae4910cb4377dfa08fdf5251239c8fc6..bd9eba71038e86fca0e5add39f5b30cea7c0a7f9 100644
--- a/components/payments/payment_request.h
+++ b/components/payments/payment_request.h
@@ -59,12 +59,19 @@ class PaymentRequest : payments::mojom::PaymentRequest {
const base::Optional<std::string> currency_system,
const std::string& locale_name);
- // Returns the Autofill Profile, representing the shipping address and contact
- // information, currently selected for this PaymentRequest flow. If
- // unpopulated, populates with and returns the 0th profile on record for this
- // user, if it exists; or nullptr otherwise. Profile is owned by the request
- // object, not the caller.
- autofill::AutofillProfile* GetCurrentlySelectedProfile();
+ // Returns the Autofill Profiles for this user. On the first invocation,
+ // profiles are fetched from the PersonalDataManager; on subsequent
+ // invocations, a cached version is returned. The profiles returned are
+ // copies owned by the request object.
+ 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.
+
+ // Gets/sets the Autofill Profile representing the shipping address or contact
+ // information currently selected for this PaymentRequest flow. Getters return
+ // nullptr if no profile has been selected or otherwise populated.
+ autofill::AutofillProfile* GetSelectedShippingProfile();
+ void SetShippingProfile(autofill::AutofillProfile* profile);
+ autofill::AutofillProfile* GetSelectedContactProfile();
+ void SetContactProfile(autofill::AutofillProfile* profile);
// Returns the currently selected credit card for this PaymentRequest flow.
// It's not guaranteed to be complete. Returns nullptr if there is no selected
@@ -75,6 +82,9 @@ class PaymentRequest : payments::mojom::PaymentRequest {
content::WebContents* web_contents() { return web_contents_; }
private:
+ // Sets the default values for the selected Shipping and Contact profiles.
+ void SetDefaultProfileSelections();
+
content::WebContents* web_contents_;
std::unique_ptr<PaymentRequestDelegate> delegate_;
// |manager_| owns this PaymentRequest.
@@ -83,7 +93,13 @@ class PaymentRequest : payments::mojom::PaymentRequest {
payments::mojom::PaymentRequestClientPtr client_;
payments::mojom::PaymentDetailsPtr details_;
std::unique_ptr<CurrencyFormatter> currency_formatter_;
- std::unique_ptr<autofill::AutofillProfile> profile_;
+
+ // Profiles may change due to (e.g.) sync events, so profiles are cached after
+ // loading and owned here. They are populated once only, and ordered by
+ // frecency.
+ std::vector<std::unique_ptr<autofill::AutofillProfile>> profile_cache_;
+ autofill::AutofillProfile* selected_shipping_profile_;
+ autofill::AutofillProfile* selected_contact_profile_;
DISALLOW_COPY_AND_ASSIGN(PaymentRequest);
};

Powered by Google App Engine
This is Rietveld 408576698