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

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp

Issue 2865023003: Warn web developers that card networks as method names are deprecated. (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
index 9759e63f2eccaaa13af83dcfd05b94e0cb542119..3425dc0b68113f90686c235aa9189f536ce25a63 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
@@ -128,6 +128,20 @@ struct TypeConverter<PaymentOptionsPtr, blink::PaymentOptions> {
namespace blink {
namespace {
+using ::payments::mojom::blink::BasicCardNetwork;
+
+const struct {
+ const BasicCardNetwork code;
+ const char* const name;
+} kBasicCardNetworks[] = {{BasicCardNetwork::AMEX, "amex"},
+ {BasicCardNetwork::DINERS, "diners"},
+ {BasicCardNetwork::DISCOVER, "discover"},
+ {BasicCardNetwork::JCB, "jcb"},
+ {BasicCardNetwork::MASTERCARD, "mastercard"},
+ {BasicCardNetwork::MIR, "mir"},
+ {BasicCardNetwork::UNIONPAY, "unionpay"},
+ {BasicCardNetwork::VISA, "visa"}};
+
// If the website does not call complete() 60 seconds after show() has been
// resolved, then behave as if the website called complete("fail").
static const int kCompleteTimeoutSeconds = 60;
@@ -349,20 +363,6 @@ void SetBasicCardMethodData(const ScriptValue& input,
return;
if (basic_card.hasSupportedNetworks()) {
- using ::payments::mojom::blink::BasicCardNetwork;
-
- const struct {
- const BasicCardNetwork code;
- const char* const name;
- } kBasicCardNetworks[] = {{BasicCardNetwork::AMEX, "amex"},
- {BasicCardNetwork::DINERS, "diners"},
- {BasicCardNetwork::DISCOVER, "discover"},
- {BasicCardNetwork::JCB, "jcb"},
- {BasicCardNetwork::MASTERCARD, "mastercard"},
- {BasicCardNetwork::MIR, "mir"},
- {BasicCardNetwork::UNIONPAY, "unionpay"},
- {BasicCardNetwork::VISA, "visa"}};
-
for (const String& network : basic_card.supportedNetworks()) {
for (size_t i = 0; i < arraysize(kBasicCardNetworks); ++i) {
if (network == kBasicCardNetworks[i].name) {
@@ -400,6 +400,22 @@ void SetBasicCardMethodData(const ScriptValue& input,
}
}
+void WarnDeprecatedBasicCard(const Vector<String>& supported_methods,
+ ExecutionContext& execution_context) {
+ for (const auto& method : supported_methods) {
+ for (size_t i = 0; i < arraysize(kBasicCardNetworks); ++i) {
+ if (method == kBasicCardNetworks[i].name) {
+ execution_context.AddConsoleMessage(ConsoleMessage::Create(
+ kJSMessageSource, kWarningMessageLevel,
Rick Byers 2017/05/16 13:48:58 Please use the "DeprecationMessageSource" - that'l
please use gerrit instead 2017/05/16 18:02:55 Done.
+ "The supported methods 'amex', 'diners', 'discover', 'jcb', "
+ "'mastercard', 'mir', 'unionpay', and 'visa' are deprecated. Use "
+ "'basic-card' instead."));
Rick Byers 2017/05/16 13:48:58 In general we prefer to give developers a concrete
please use gerrit instead 2017/05/16 18:02:55 Done.
+ return;
+ }
+ }
+ }
+}
+
void StringifyAndParseMethodSpecificData(
const Vector<String>& supported_methods,
const ScriptValue& input,
@@ -434,6 +450,7 @@ void StringifyAndParseMethodSpecificData(
if (exception_state.HadException())
exception_state.ClearException();
}
+ WarnDeprecatedBasicCard(supported_methods, execution_context);
}
void ValidateAndConvertPaymentDetailsModifiers(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698