Commit eb06b271 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Web Payment] Generate fewer Java strings.

Before this patch, 41 error strings were auto-generated for Java, but
only 14 of them were used on Android.

This patch separates the strings that are used only from native C++ code
into their own native_error_strings.h/cc files, which are not
auto-generated into ErrorStrings.java.

After this patch, only the 14 error strings referenced from Java are
generated into ErrorStrings.java.

Bug: 977145
Change-Id: Id3652179c124ba1742b52aa2beaaca3d499d5d90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692113Reviewed-by: default avatarSahel Sharify <sahel@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676032}
parent 36959297
......@@ -8,7 +8,7 @@
#include "base/logging.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "components/payments/core/error_strings.h"
#include "components/payments/core/native_error_strings.h"
#include "components/payments/core/url_util.h"
#include "components/security_state/core/security_state.h"
#include "url/gurl.h"
......
......@@ -16,7 +16,7 @@
#include "chrome/browser/ui/views/payments/payment_request_views_util.h"
#include "chrome/grit/generated_resources.h"
#include "components/payments/content/icon/icon_size.h"
#include "components/payments/core/error_strings.h"
#include "components/payments/core/native_error_strings.h"
#include "components/payments/core/url_util.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
......
......@@ -6,6 +6,7 @@
#include "base/strings/string_piece.h"
#include "components/payments/core/error_strings.h"
#include "components/payments/core/native_error_strings.h"
namespace payments {
......
......@@ -8,6 +8,7 @@
#include "base/callback.h"
#include "components/payments/core/error_strings.h"
#include "components/payments/core/native_error_strings.h"
#include "content/public/browser/browser_thread.h"
namespace payments {
......
......@@ -21,6 +21,7 @@
#include "components/payments/core/can_make_payment_query.h"
#include "components/payments/core/error_strings.h"
#include "components/payments/core/features.h"
#include "components/payments/core/native_error_strings.h"
#include "components/payments/core/payment_details.h"
#include "components/payments/core/payment_details_validation.h"
#include "components/payments/core/payment_instrument.h"
......
......@@ -98,6 +98,8 @@ jumbo_static_library("error_strings") {
sources = [
"error_strings.cc",
"error_strings.h",
"native_error_strings.cc",
"native_error_strings.h",
]
}
......
......@@ -12,43 +12,16 @@ namespace errors {
const char kAnotherUiShowing[] = "Another PaymentRequest UI is already showing in a different tab or window.";
const char kAttemptedInitializationTwice[] = "Attempted initialization twice.";
const char kCannotAbortWithoutInit[] = "Attempted abort without initialization.";
const char kCannotAbortWithoutShow[] = "Attempted abort without show.";
const char kCannotCallCanMakePaymentWithoutInit[] = "Attempted canMakePayment without initialization.";
const char kCannotCallHasEnrolledInstrumentWithoutInit[] = "Attempted hasEnrolledInstrument without initialization.";
const char kCannotCompleteWithoutInit[] = "Attempted complete without initialization.";
const char kCannotCompleteWithoutShow[] = "Attempted complete without show.";
const char kCannotRetryWithoutInit[] = "Attempted retry without initialization.";
const char kCannotRetryWithoutShow[] = "Attempted retry without show.";
const char kCannotShowInBackgroundTab[] = "Cannot show PaymentRequest UI in a background tab.";
const char kCannotShowTwice[] = "Attempted show twice.";
const char kCannotShowWithoutInit[] = "Attempted show without initialization.";
const char kCannotUpdateWithoutInit[] = "Attempted updateWith without initialization.";
const char kCannotUpdateWithoutShow[] = "Attempted updateWith without show.";
const char kDetailedInvalidSslCertificateMessageFormat[] = "SSL certificate is not valid. Security level: $.";
const char kGenericPaymentMethodNotSupportedMessage[] = "Payment method not supported.";
const char kInvalidSslCertificate[] = "SSL certificate is not valid.";
const char kInvalidState[] = "Invalid state.";
const char kMethodDataRequired[] = "Method data required.";
const char kMethodNameRequired[] = "Method name required.";
const char kMissingDetailsFromPaymentApp[] = "Payment app returned invalid response. Missing field \"details\".";
const char kMissingMethodNameFromPaymentApp[] = "Payment app returned invalid response. Missing field \"methodName\".";
const char kMultiplePaymentMethodsNotSupportedFormat[] = "The payment methods $ are not supported.";
const char kNoResponseToPaymentEvent[] = "Payment handler did not respond to \"paymentrequest\" event.";
const char kNotInASecureOrigin[] = "Not in a secure origin.";
const char kNotInitialized[] = "Not initialized.";
const char kNotShown[] = "Not shown.";
const char kPaymentDetailsNotObject[] = "Payment app returned invalid response. \"details\" field is not a dictionary.";
const char kPaymentDetailsStringifyError[] = "Payment app returned invalid response. Unable to JSON-serialize \"details\".";
const char kPaymentEventBrowserError[] = "Browser encountered an error when firing the \"paymentrequest\" event in the payment handler.";
const char kPaymentEventInternalError[] = "Payment handler encountered an internal error when handling the \"paymentrequest\" event.";
const char kPaymentEventRejected[] = "Payment handler rejected the promise passed into PaymentRequestEvent.respondWith(). This is how payment handlers close their own window programmatically.";
const char kPaymentEventServiceWorkerError[] = "Payment handler failed to provide a response because either the \"paymentrequest\" event took too long or the service worker stopped for some reason or was killed before the request finished.";
const char kPaymentEventTimeout[] = "The \"paymentrequest\" event timed out after 5 minutes.";
const char kPaymentHandlerInsecureNavigation[] = "The payment handler navigated to a page with insecure context, invalid certificate state, or malicious content.";
const char kProhibitedOrigin[] = "Only localhost, file://, and cryptographic scheme origins allowed.";
const char kProhibitedOriginOrInvalidSslExplanation[] = "No UI will be shown. CanMakePayment and hasEnrolledInstrument will always return false. Show will be rejected with NotSupportedError.";
const char kSinglePaymentMethodNotSupportedFormat[] = "The payment method $ is not supported.";
const char kTotalRequired[] = "Total required.";
const char kUserCancelled[] = "User closed the Payment Request UI.";
......
......@@ -8,6 +8,9 @@
namespace payments {
namespace errors {
// These strings are referenced from both C++ and Java (through the
// auto-generated file ErrorStrings.java).
// Please keep the list alphabetized.
// Only a single PaymentRequest UI can be displayed at a time.
......@@ -16,32 +19,6 @@ extern const char kAnotherUiShowing[];
// Mojo call PaymentRequest::Init() must precede PaymentRequest::Show().
extern const char kAttemptedInitializationTwice[];
// Mojo call PaymentRequest::Init() must precede PaymentRequest::Abort().
extern const char kCannotAbortWithoutInit[];
// Mojo call PaymentRequest::Show() must precede PaymentRequest::Abort().
extern const char kCannotAbortWithoutShow[];
// Mojo call PaymentRequest::Init() must precede
// PaymentRequest::CanMakePayment().
extern const char kCannotCallCanMakePaymentWithoutInit[];
// Mojo call PaymentRequest::Init() must precede
// PaymentRequest::HasEnrolledInstrument().
extern const char kCannotCallHasEnrolledInstrumentWithoutInit[];
// Mojo call PaymentRequest::Init() must precede PaymentRequest::Complete().
extern const char kCannotCompleteWithoutInit[];
// Mojo call PaymentRequest::Show() must precede PaymentRequest::Complete().
extern const char kCannotCompleteWithoutShow[];
// Mojo call PaymentRequest::Init() must precede PaymentRequest::Retry().
extern const char kCannotRetryWithoutInit[];
// Mojo call PaymentRequest::Show() must precede PaymentRequest::Retry().
extern const char kCannotRetryWithoutShow[];
// Payment Request UI must be shown in the foreground tab, as a result of user
// interaction.
extern const char kCannotShowInBackgroundTab[];
......@@ -58,82 +35,15 @@ extern const char kCannotUpdateWithoutInit[];
// Mojo call PaymentRequest::Show() must precede PaymentRequest::UpdateWith().
extern const char kCannotUpdateWithoutShow[];
// The format for a detailed message about invalid SSL certificate. This format
// should be used with base::ReplaceChars() function, where "$" is the character
// to replace.
extern const char kDetailedInvalidSslCertificateMessageFormat[];
// A message about unsupported payment method.
extern const char kGenericPaymentMethodNotSupportedMessage[];
// Chrome refuses to provide any payment information to a website with an
// invalid SSL certificate.
extern const char kInvalidSslCertificate[];
// Used when an invalid state is encountered generically.
extern const char kInvalidState[];
// Used when the {"supportedMethods": "", data: {}} is required, but not
// provided.
extern const char kMethodDataRequired[];
// Used when non-empty "supportedMethods": "" is required, but not provided.
extern const char kMethodNameRequired[];
// The payment handler responded with an empty "details" field.
extern const char kMissingDetailsFromPaymentApp[];
// The payment handler responded with an empty "methodName" field.
extern const char kMissingMethodNameFromPaymentApp[];
// The format for the message about multiple payment methods that are not
// supported. This format should be used with base::ReplaceChars() function,
// where "$" is the character to replace.
extern const char kMultiplePaymentMethodsNotSupportedFormat[];
// Payment handler did not respond to the "paymentrequest" event.
extern const char kNoResponseToPaymentEvent[];
// The PaymentRequest API is available only on secure origins.
extern const char kNotInASecureOrigin[];
// Used when PaymentRequest::Init() has not been called, but should have been.
extern const char kNotInitialized[];
// Used when PaymentRequest::Show() has not been called, but should have been.
extern const char kNotShown[];
// Payment handler passed a non-object field "details" in response to the
// "paymentrequest" event.
extern const char kPaymentDetailsNotObject[];
// Payment handler passed a non-stringifiable field "details" in response to the
// "paymentrequest" event.
extern const char kPaymentDetailsStringifyError[];
// Used when the browser failed to fire the "paymentrequest" event without any
// actionable corrective action from the web developer.
extern const char kPaymentEventBrowserError[];
// Service worker timed out or stopped for some reason or was killed before the
// payment handler could respond to the "paymentrequest" event.
extern const char kPaymentEventServiceWorkerError[];
// Service worker timed out while responding to "paymentrequest" event.
extern const char kPaymentEventTimeout[];
// Payment handler navigated to a page with insecure context, invalid SSL, or
// malicious content.
extern const char kPaymentHandlerInsecureNavigation[];
// Payment handler encountered an internal error when handling the
// "paymentrequest" event.
extern const char kPaymentEventInternalError[];
// Payment handler rejected the promise passed into
// PaymentRequestEvent.respondWith() method.
extern const char kPaymentEventRejected[];
// Chrome provides payment information only to a whitelist of origin types.
extern const char kProhibitedOrigin[];
......@@ -141,11 +51,6 @@ extern const char kProhibitedOrigin[];
// or kInvalidSslCertificate error.
extern const char kProhibitedOriginOrInvalidSslExplanation[];
// The format for the message about a single payment method that is not
// supported. This format should be used with base::ReplaceChars() function,
// where "$" is the character to replace.
extern const char kSinglePaymentMethodNotSupportedFormat[];
// Used when "total": {"label": "Total", "amount": {"currency": "USD", "value":
// "0.01"}} is required, bot not provided.
extern const char kTotalRequired[];
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/payments/core/native_error_strings.h"
namespace payments {
namespace errors {
const char kCannotAbortWithoutInit[] =
"Attempted abort without initialization.";
const char kCannotAbortWithoutShow[] = "Attempted abort without show.";
const char kCannotCallCanMakePaymentWithoutInit[] =
"Attempted canMakePayment without initialization.";
const char kCannotCallHasEnrolledInstrumentWithoutInit[] =
"Attempted hasEnrolledInstrument without initialization.";
const char kCannotCompleteWithoutInit[] =
"Attempted complete without initialization.";
const char kCannotCompleteWithoutShow[] = "Attempted complete without show.";
const char kCannotRetryWithoutInit[] =
"Attempted retry without initialization.";
const char kCannotRetryWithoutShow[] = "Attempted retry without show.";
const char kDetailedInvalidSslCertificateMessageFormat[] =
"SSL certificate is not valid. Security level: $.";
const char kInvalidSslCertificate[] = "SSL certificate is not valid.";
const char kMethodDataRequired[] = "Method data required.";
const char kMethodNameRequired[] = "Method name required.";
const char kMissingDetailsFromPaymentApp[] =
"Payment app returned invalid response. Missing field \"details\".";
const char kMissingMethodNameFromPaymentApp[] =
"Payment app returned invalid response. Missing field \"methodName\".";
const char kMultiplePaymentMethodsNotSupportedFormat[] =
"The payment methods $ are not supported.";
const char kNoResponseToPaymentEvent[] =
"Payment handler did not respond to \"paymentrequest\" event.";
const char kNotInitialized[] = "Not initialized.";
const char kNotShown[] = "Not shown.";
const char kPaymentDetailsNotObject[] =
"Payment app returned invalid response. \"details\" field is not a "
"dictionary.";
const char kPaymentDetailsStringifyError[] =
"Payment app returned invalid response. Unable to JSON-serialize "
"\"details\".";
const char kPaymentEventBrowserError[] =
"Browser encountered an error when firing the \"paymentrequest\" event in "
"the payment handler.";
const char kPaymentEventInternalError[] =
"Payment handler encountered an internal error when handling the "
"\"paymentrequest\" event.";
const char kPaymentEventRejected[] =
"Payment handler rejected the promise passed into "
"PaymentRequestEvent.respondWith(). This is how payment handlers close "
"their own window programmatically.";
const char kPaymentEventServiceWorkerError[] =
"Payment handler failed to provide a response because either the "
"\"paymentrequest\" event took too long or the service worker stopped for "
"some reason or was killed before the request finished.";
const char kPaymentEventTimeout[] =
"The \"paymentrequest\" event timed out after 5 minutes.";
const char kPaymentHandlerInsecureNavigation[] =
"The payment handler navigated to a page with insecure context, invalid "
"certificate state, or malicious content.";
const char kSinglePaymentMethodNotSupportedFormat[] =
"The payment method $ is not supported.";
} // namespace errors
} // namespace payments
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PAYMENTS_CORE_NATIVE_ERROR_STRINGS_H_
#define COMPONENTS_PAYMENTS_CORE_NATIVE_ERROR_STRINGS_H_
namespace payments {
namespace errors {
// These strings are referenced only from C++.
// Mojo call PaymentRequest::Init() must precede PaymentRequest::Abort().
extern const char kCannotAbortWithoutInit[];
// Mojo call PaymentRequest::Show() must precede PaymentRequest::Abort().
extern const char kCannotAbortWithoutShow[];
// Mojo call PaymentRequest::Init() must precede
// PaymentRequest::CanMakePayment().
extern const char kCannotCallCanMakePaymentWithoutInit[];
// Mojo call PaymentRequest::Init() must precede
// PaymentRequest::HasEnrolledInstrument().
extern const char kCannotCallHasEnrolledInstrumentWithoutInit[];
// Mojo call PaymentRequest::Init() must precede PaymentRequest::Complete().
extern const char kCannotCompleteWithoutInit[];
// Mojo call PaymentRequest::Show() must precede PaymentRequest::Complete().
extern const char kCannotCompleteWithoutShow[];
// Mojo call PaymentRequest::Init() must precede PaymentRequest::Retry().
extern const char kCannotRetryWithoutInit[];
// Mojo call PaymentRequest::Show() must precede PaymentRequest::Retry().
extern const char kCannotRetryWithoutShow[];
// Mojo call PaymentRequest::Show() must precede PaymentRequest::UpdateWith().
extern const char kCannotUpdateWithoutShow[];
// The format for a detailed message about invalid SSL certificate. This format
// should be used with base::ReplaceChars() function, where "$" is the character
// to replace.
extern const char kDetailedInvalidSslCertificateMessageFormat[];
// Chrome refuses to provide any payment information to a website with an
// invalid SSL certificate.
extern const char kInvalidSslCertificate[];
// Used when the {"supportedMethods": "", data: {}} is required, but not
// provided.
extern const char kMethodDataRequired[];
// Used when non-empty "supportedMethods": "" is required, but not provided.
extern const char kMethodNameRequired[];
// The payment handler responded with an empty "details" field.
extern const char kMissingDetailsFromPaymentApp[];
// The payment handler responded with an empty "methodName" field.
extern const char kMissingMethodNameFromPaymentApp[];
// The format for the message about multiple payment methods that are not
// supported. This format should be used with base::ReplaceChars() function,
// where "$" is the character to replace.
extern const char kMultiplePaymentMethodsNotSupportedFormat[];
// Payment handler did not respond to the "paymentrequest" event.
extern const char kNoResponseToPaymentEvent[];
// Used when PaymentRequest::Init() has not been called, but should have been.
extern const char kNotInitialized[];
// Used when PaymentRequest::Show() has not been called, but should have been.
extern const char kNotShown[];
// Payment handler passed a non-object field "details" in response to the
// "paymentrequest" event.
extern const char kPaymentDetailsNotObject[];
// Payment handler passed a non-stringifiable field "details" in response to the
// "paymentrequest" event.
extern const char kPaymentDetailsStringifyError[];
// Used when the browser failed to fire the "paymentrequest" event without any
// actionable corrective action from the web developer.
extern const char kPaymentEventBrowserError[];
// Service worker timed out or stopped for some reason or was killed before the
// payment handler could respond to the "paymentrequest" event.
extern const char kPaymentEventServiceWorkerError[];
// Service worker timed out while responding to "paymentrequest" event.
extern const char kPaymentEventTimeout[];
// Payment handler navigated to a page with insecure context, invalid SSL, or
// malicious content.
extern const char kPaymentHandlerInsecureNavigation[];
// Payment handler encountered an internal error when handling the
// "paymentrequest" event.
extern const char kPaymentEventInternalError[];
// Payment handler rejected the promise passed into
// PaymentRequestEvent.respondWith() method.
extern const char kPaymentEventRejected[];
// The format for the message about a single payment method that is not
// supported. This format should be used with base::ReplaceChars() function,
// where "$" is the character to replace.
extern const char kSinglePaymentMethodNotSupportedFormat[];
} // namespace errors
} // namespace payments
#endif // COMPONENTS_PAYMENTS_CORE_NATIVE_ERROR_STRINGS_H_
......@@ -13,7 +13,7 @@
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "components/payments/core/error_strings.h"
#include "components/payments/core/native_error_strings.h"
#include "components/payments/core/payment_details.h"
#include "components/payments/core/payment_instrument.h"
#import "ios/chrome/browser/payments/payment_request_constants.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment