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

Unified Diff: components/payments/content/payment_request_spec.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/payments/content/payment_request.cc ('k') | components/payments/content/payment_request_spec.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/payments/content/payment_request_spec.h
diff --git a/components/payments/content/payment_request_spec.h b/components/payments/content/payment_request_spec.h
index dbefd2b61e67376a8065156aa53d7acaf1f728cd..d205a1bb4abaa69943b93f04c2b67a8eb0f9a344 100644
--- a/components/payments/content/payment_request_spec.h
+++ b/components/payments/content/payment_request_spec.h
@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/observer_list.h"
#include "components/payments/content/payment_request.mojom.h"
+#include "components/payments/core/currency_formatter.h"
namespace payments {
@@ -33,7 +34,8 @@ class PaymentRequestSpec {
PaymentRequestSpec(mojom::PaymentOptionsPtr options,
mojom::PaymentDetailsPtr details,
std::vector<mojom::PaymentMethodDataPtr> method_data,
- PaymentRequestSpec::Observer* observer);
+ PaymentRequestSpec::Observer* observer,
+ const std::string& app_locale);
~PaymentRequestSpec();
void AddObserver(Observer* observer);
@@ -48,6 +50,16 @@ class PaymentRequestSpec {
return supported_card_networks_;
}
+ // Uses CurrencyFormatter to format |amount| with the currency symbol for this
+ // request's currency. Will use currency of the "total" display item, because
+ // all items are supposed to have the same currency in a given request.
+ base::string16 GetFormattedCurrencyAmount(const std::string& amount);
+
+ // Uses CurrencyFormatter to get the formatted currency code for this
+ // request's currency. Will use currency of the "total" display item, because
+ // all items are supposed to have the same currency in a given request.
+ std::string GetFormattedCurrencyCode();
+
const mojom::PaymentDetails& details() const { return *details_.get(); }
const mojom::PaymentOptions& options() const { return *options_.get(); }
@@ -59,8 +71,19 @@ class PaymentRequestSpec {
// Will notify all observers that the spec is invalid.
void NotifyOnInvalidSpecProvided();
+ // Returns the CurrencyFormatter instance for this PaymentRequest.
+ // |locale_name| should be the result of the browser's GetApplicationLocale().
+ // Note: Having multiple currencies per PaymentRequest is not supported; hence
+ // the CurrencyFormatter is cached here.
+ CurrencyFormatter* GetOrCreateCurrencyFormatter(
+ const std::string& currency_code,
+ const std::string& currency_system,
+ const std::string& locale_name);
+
mojom::PaymentOptionsPtr options_;
mojom::PaymentDetailsPtr details_;
+ const std::string app_locale_;
+ std::unique_ptr<CurrencyFormatter> currency_formatter_;
// A list of supported basic card networks, in order that they were specified
// by the merchant.
« no previous file with comments | « components/payments/content/payment_request.cc ('k') | components/payments/content/payment_request_spec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698