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

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

Issue 2741343011: [Payments] Move PersonalDataManager and locale to PaymentRequestState (Closed)
Patch Set: Initial Created 3 years, 9 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_CONTENT_PAYMENT_REQUEST_H_ 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_
6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string>
10 #include <vector> 9 #include <vector>
11 10
12 #include "base/macros.h" 11 #include "base/macros.h"
13 #include "components/payments/content/payment_request.mojom.h" 12 #include "components/payments/content/payment_request.mojom.h"
14 #include "components/payments/content/payment_request_delegate.h" 13 #include "components/payments/content/payment_request_delegate.h"
15 #include "components/payments/content/payment_request_spec.h" 14 #include "components/payments/content/payment_request_spec.h"
16 #include "components/payments/content/payment_request_state.h" 15 #include "components/payments/content/payment_request_state.h"
17 #include "mojo/public/cpp/bindings/binding.h" 16 #include "mojo/public/cpp/bindings/binding.h"
18 #include "mojo/public/cpp/bindings/interface_request.h" 17 #include "mojo/public/cpp/bindings/interface_request.h"
19 18
20 namespace autofill {
21 class PersonalDataManager;
22 }
23
24 namespace content { 19 namespace content {
25 class WebContents; 20 class WebContents;
26 } 21 }
27 22
28 namespace payments { 23 namespace payments {
29 24
30 class CurrencyFormatter;
31 class PaymentRequestWebContentsManager; 25 class PaymentRequestWebContentsManager;
32 26
33 // This class manages the interaction between the renderer (through the 27 // This class manages the interaction between the renderer (through the
34 // PaymentRequestClient and Mojo stub implementation) and the UI (through the 28 // PaymentRequestClient and Mojo stub implementation) and the UI (through the
35 // PaymentRequestDelegate). The API user (merchant) specification (supported 29 // PaymentRequestDelegate). The API user (merchant) specification (supported
36 // payment methods, required information, order details) is stored in 30 // payment methods, required information, order details) is stored in
37 // PaymentRequestSpec, and the current user selection state (and related data) 31 // PaymentRequestSpec, and the current user selection state (and related data)
38 // is stored in PaymentRequestSpec. 32 // is stored in PaymentRequestSpec.
39 class PaymentRequest : public mojom::PaymentRequest, 33 class PaymentRequest : public mojom::PaymentRequest,
40 public PaymentRequestSpec::Observer, 34 public PaymentRequestSpec::Observer,
(...skipping 13 matching lines...) Expand all
54 void Show() override; 48 void Show() override;
55 void UpdateWith(mojom::PaymentDetailsPtr details) override {} 49 void UpdateWith(mojom::PaymentDetailsPtr details) override {}
56 void Abort() override; 50 void Abort() override;
57 void Complete(mojom::PaymentComplete result) override; 51 void Complete(mojom::PaymentComplete result) override;
58 void CanMakePayment() override; 52 void CanMakePayment() override;
59 53
60 // PaymentRequestSpec::Observer: 54 // PaymentRequestSpec::Observer:
61 void OnInvalidSpecProvided() override; 55 void OnInvalidSpecProvided() override;
62 56
63 // PaymentRequestState::Delegate: 57 // PaymentRequestState::Delegate:
64 const std::string& GetApplicationLocale() override;
65 autofill::PersonalDataManager* GetPersonalDataManager() override;
66 void OnPaymentResponseAvailable(mojom::PaymentResponsePtr response) override; 58 void OnPaymentResponseAvailable(mojom::PaymentResponsePtr response) override;
67 59
68 // Called when the user explicitely cancelled the flow. Will send a message 60 // Called when the user explicitely cancelled the flow. Will send a message
69 // to the renderer which will indirectly destroy this object (through 61 // to the renderer which will indirectly destroy this object (through
70 // OnConnectionTerminated). 62 // OnConnectionTerminated).
71 void UserCancelled(); 63 void UserCancelled();
72 64
73 // As a result of a browser-side error or renderer-initiated mojo channel 65 // As a result of a browser-side error or renderer-initiated mojo channel
74 // closure (e.g. there was an error on the renderer side, or payment was 66 // closure (e.g. there was an error on the renderer side, or payment was
75 // successful), this method is called. It is responsible for cleaning up, 67 // successful), this method is called. It is responsible for cleaning up,
76 // such as possibly closing the dialog. 68 // such as possibly closing the dialog.
77 void OnConnectionTerminated(); 69 void OnConnectionTerminated();
78 70
79 // Called when the user clicks on the "Pay" button. 71 // Called when the user clicks on the "Pay" button.
80 void Pay(); 72 void Pay();
81 73
82 // Returns the CurrencyFormatter instance for this PaymentRequest.
83 // |locale_name| should be the result of the browser's GetApplicationLocale().
84 // Note: Having multiple currencies per PaymentRequest is not supported; hence
85 // the CurrencyFormatter is cached here.
86 CurrencyFormatter* GetOrCreateCurrencyFormatter(
87 const std::string& currency_code,
88 const std::string& currency_system,
89 const std::string& locale_name);
90
91 // Uses CurrencyFormatter to format |amount| with the currency symbol for this
92 // request's currency.
93 base::string16 GetFormattedCurrencyAmount(const std::string& amount);
94
95 // Uses CurrencyFormatter to get the formatted currency code for this
96 // request's currency.
97 std::string GetFormattedCurrencyCode();
98
99 content::WebContents* web_contents() { return web_contents_; } 74 content::WebContents* web_contents() { return web_contents_; }
100 75
101 PaymentRequestSpec* spec() { return spec_.get(); } 76 PaymentRequestSpec* spec() { return spec_.get(); }
102 PaymentRequestState* state() { return state_.get(); } 77 PaymentRequestState* state() { return state_.get(); }
103 78
104 private: 79 private:
105 content::WebContents* web_contents_; 80 content::WebContents* web_contents_;
106 std::unique_ptr<PaymentRequestDelegate> delegate_; 81 std::unique_ptr<PaymentRequestDelegate> delegate_;
107 // |manager_| owns this PaymentRequest. 82 // |manager_| owns this PaymentRequest.
108 PaymentRequestWebContentsManager* manager_; 83 PaymentRequestWebContentsManager* manager_;
109 mojo::Binding<mojom::PaymentRequest> binding_; 84 mojo::Binding<mojom::PaymentRequest> binding_;
110 mojom::PaymentRequestClientPtr client_; 85 mojom::PaymentRequestClientPtr client_;
111 std::unique_ptr<CurrencyFormatter> currency_formatter_;
112 86
113 std::unique_ptr<PaymentRequestSpec> spec_; 87 std::unique_ptr<PaymentRequestSpec> spec_;
114 std::unique_ptr<PaymentRequestState> state_; 88 std::unique_ptr<PaymentRequestState> state_;
115 89
116 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); 90 DISALLOW_COPY_AND_ASSIGN(PaymentRequest);
117 }; 91 };
118 92
119 } // namespace payments 93 } // namespace payments
120 94
121 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ 95 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/shipping_option_view_controller.cc ('k') | components/payments/content/payment_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698