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

Unified Diff: components/payments/currency_formatter.cc

Issue 2649143003: PaymentRequest: The currencySystem should be non-nullable. (Closed)
Patch Set: PaymentRequest: The currencySystem should be non-nullable. 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
« no previous file with comments | « components/payments/currency_formatter.h ('k') | components/payments/currency_formatter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/payments/currency_formatter.cc
diff --git a/components/payments/currency_formatter.cc b/components/payments/currency_formatter.cc
index d6d4bc0476988e451e06c66c8b76adb59f593c34..1dc2c10dee379a98d66e154507bdb3e85b47c00a 100644
--- a/components/payments/currency_formatter.cc
+++ b/components/payments/currency_formatter.cc
@@ -36,9 +36,9 @@ const char kEllipsis[] = "\xE2\x80\xA6";
// Returns whether the |currency_code| is valid to be used in ICU.
bool ShouldUseCurrencyCode(const std::string& currency_code,
- const base::Optional<std::string> currency_system) {
- return currency_system.value_or(kIso4217CurrencySystem) ==
- kIso4217CurrencySystem &&
+ const std::string& currency_system) {
+ return (currency_system.empty() ||
+ currency_system == kIso4217CurrencySystem) &&
!currency_code.empty() &&
currency_code.size() <= kMaxCurrencyCodeLength;
}
@@ -52,10 +52,9 @@ std::string FormatCurrencyCode(const std::string& currency_code) {
} // namespace
-CurrencyFormatter::CurrencyFormatter(
- const std::string& currency_code,
- const base::Optional<std::string> currency_system,
- const std::string& locale_name)
+CurrencyFormatter::CurrencyFormatter(const std::string& currency_code,
+ const std::string& currency_system,
+ const std::string& locale_name)
: locale_(locale_name.c_str()),
formatted_currency_code_(FormatCurrencyCode(currency_code)) {
UErrorCode error_code = U_ZERO_ERROR;
« no previous file with comments | « components/payments/currency_formatter.h ('k') | components/payments/currency_formatter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698