Commit 91dc1b58 authored by Jinho Bang's avatar Jinho Bang Committed by Commit Bot

PaymentHandler: Replace 'enabledMethods' array with 'method' string

The related spec change:
  https://github.com/w3c/payment-handler/pull/276

Payment Handler feature is behind a flag:
  chrome://flags/#service-worker-payment-apps

FYI, the original field type was `repeated string`, and the changed
field type is `optional string`. So, if `enabledMethods` data is
stored in a previous version, when reading the `method` field in a new
version, the protobuf will read the first element of `enabledMethods`.
Therefore, DB migration is not required.

Bug: 828894
Change-Id: Ic5775768eaff9584517956f2984473e8b6a0a411
Reviewed-on: https://chromium-review.googlesource.com/986121Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Jinho Bang <jinho.bang@samsung.com>
Cr-Commit-Position: refs/heads/master@{#548750}
parent f1ba9bd1
......@@ -328,7 +328,7 @@ public class ServiceWorkerPaymentApp extends PaymentInstrument implements Paymen
iframeOrigin, id, new HashSet<>(methodData.values()), total,
new HashSet<>(modifiers.values()), callback, mAppName,
icon == null ? null : icon.getBitmap(), mSwUri, mScope, mUseCache,
mMethodNames);
mMethodNames.toArray(new String[0])[0]);
} else {
ServiceWorkerPaymentAppBridge.invokePaymentApp(mWebContents, mRegistrationId, origin,
iframeOrigin, id, new HashSet<>(methodData.values()), total,
......
......@@ -207,20 +207,19 @@ public class ServiceWorkerPaymentAppBridge implements PaymentAppFactory.PaymentA
* @param swUri The URI to get the app's service worker js script.
* @param scope The scope of the service worker that should be registered.
* @param useCache Whether to use cache when registering the service worker.
* @param methodNames Supported method names of the app.
* @param method Supported method name of the app.
*/
public static void installAndInvokePaymentApp(WebContents webContents, String origin,
String iframeOrigin, String paymentRequestId, Set<PaymentMethodData> methodData,
PaymentItem total, Set<PaymentDetailsModifier> modifiers,
PaymentInstrument.InstrumentDetailsCallback callback, String appName,
@Nullable Bitmap icon, URI swUri, URI scope, boolean useCache,
Set<String> methodNames) {
@Nullable Bitmap icon, URI swUri, URI scope, boolean useCache, String method) {
ThreadUtils.assertOnUiThread();
nativeInstallAndInvokePaymentApp(webContents, origin, iframeOrigin, paymentRequestId,
methodData.toArray(new PaymentMethodData[0]), total,
modifiers.toArray(new PaymentDetailsModifier[0]), callback, appName, icon,
swUri.toString(), scope.toString(), useCache, methodNames.toArray(new String[0]));
swUri.toString(), scope.toString(), useCache, method);
}
/**
......@@ -427,8 +426,7 @@ public class ServiceWorkerPaymentAppBridge implements PaymentAppFactory.PaymentA
String topLevelOrigin, String paymentRequestOrigin, String paymentRequestId,
PaymentMethodData[] methodData, PaymentItem total, PaymentDetailsModifier[] modifiers,
PaymentInstrument.InstrumentDetailsCallback callback, String appName,
@Nullable Bitmap icon, String swUrl, String scope, boolean useCache,
String[] methodNames);
@Nullable Bitmap icon, String swUrl, String scope, boolean useCache, String method);
private static native void nativeAbortPaymentApp(
WebContents webContents, long registrationId, PaymentInstrument.AbortCallback callback);
......
......@@ -467,7 +467,7 @@ static void JNI_ServiceWorkerPaymentAppBridge_InstallAndInvokePaymentApp(
const JavaParamRef<jstring>& jsw_js_url,
const JavaParamRef<jstring>& jsw_scope,
jboolean juse_cache,
const JavaParamRef<jobjectArray>& jmethod_names) {
const JavaParamRef<jstring>& jmethod) {
content::WebContents* web_contents =
content::WebContents::FromJavaWebContents(jweb_contents);
......@@ -476,9 +476,6 @@ static void JNI_ServiceWorkerPaymentAppBridge_InstallAndInvokePaymentApp(
icon_bitmap = gfx::CreateSkBitmapFromJavaBitmap(gfx::JavaBitmap(jicon));
}
std::vector<std::string> enabled_methods;
base::android::AppendJavaStringArrayToStringVector(env, jmethod_names,
&enabled_methods);
content::PaymentAppProvider::GetInstance()->InstallAndInvokePaymentApp(
web_contents,
ConvertPaymentRequestEventDataFromJavaToNative(
......@@ -486,7 +483,8 @@ static void JNI_ServiceWorkerPaymentAppBridge_InstallAndInvokePaymentApp(
jmethod_data, jtotal, jmodifiers),
ConvertJavaStringToUTF8(env, japp_name), icon_bitmap,
ConvertJavaStringToUTF8(env, jsw_js_url),
ConvertJavaStringToUTF8(env, jsw_scope), juse_cache, enabled_methods,
ConvertJavaStringToUTF8(env, jsw_scope), juse_cache,
ConvertJavaStringToUTF8(env, jmethod),
base::BindOnce(&OnPaymentAppInvoked,
ScopedJavaGlobalRef<jobject>(env, jweb_contents),
ScopedJavaGlobalRef<jobject>(env, jcallback)));
......
......@@ -202,8 +202,7 @@ void ServiceWorkerPaymentInstrument::InvokePaymentApp(Delegate* delegate) {
: *(installable_web_app_info_->icon),
installable_web_app_info_->sw_js_url,
installable_web_app_info_->sw_scope,
installable_web_app_info_->sw_use_cache,
std::vector<std::string>(1, installable_enabled_method_),
installable_web_app_info_->sw_use_cache, installable_enabled_method_,
base::BindOnce(&ServiceWorkerPaymentInstrument::OnPaymentAppInvoked,
weak_ptr_factory_.GetWeakPtr()));
} else {
......
......@@ -54,7 +54,7 @@ function install(method) { // eslint-disable-line no-unused-vars
}
registration.paymentManager.instruments
.set('123456', {name: 'Alice Pay', enabledMethods: [method]})
.set('123456', {name: 'Alice Pay', method: method})
.then(() => {
output(
'instruments.set()',
......
......@@ -54,7 +54,7 @@ function install(method) { // eslint-disable-line no-unused-vars
}
registration.paymentManager.instruments
.set('123456', {name: 'Alice Pay', enabledMethods: [method]})
.set('123456', {name: 'Alice Pay', method: method})
.then(() => {
output(
'instruments.set()',
......
......@@ -54,7 +54,7 @@ function install(method) { // eslint-disable-line no-unused-vars
}
registration.paymentManager.instruments
.set('123456', {name: 'Bob Pay', enabledMethods: [method]})
.set('123456', {name: 'Bob Pay', method: method})
.then(() => {
output(
'instruments.set()',
......
......@@ -28,7 +28,7 @@ message StoredPaymentInstrumentProto {
optional int64 registration_id = 1;
optional string instrument_key = 2;
optional string name = 3;
repeated string enabled_methods = 4;
optional string method = 4;
optional string stringified_capabilities = 5;
repeated StoredPaymentInstrumentImageObject icons = 6;
optional string decoded_instrument_icon = 7;
......
......@@ -80,8 +80,7 @@ PaymentInstrumentPtr ToPaymentInstrumentForMojo(const std::string& input) {
}
instrument->icons.emplace_back(icon);
}
for (const auto& method : instrument_proto.enabled_methods())
instrument->enabled_methods.push_back(method);
instrument->method = instrument_proto.method();
instrument->stringified_capabilities =
instrument_proto.stringified_capabilities();
......@@ -431,7 +430,7 @@ void PaymentAppDatabase::SetPaymentAppInfoForRegisteredServiceWorker(
const std::string& instrument_key,
const std::string& name,
const std::string& icon,
const std::vector<std::string>& enabled_methods,
const std::string& method,
SetPaymentAppInfoCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
......@@ -439,14 +438,14 @@ void PaymentAppDatabase::SetPaymentAppInfoForRegisteredServiceWorker(
registration_id,
base::BindOnce(&PaymentAppDatabase::DidFindRegistrationToSetPaymentApp,
weak_ptr_factory_.GetWeakPtr(), instrument_key, name, icon,
enabled_methods, std::move(callback)));
method, std::move(callback)));
}
void PaymentAppDatabase::DidFindRegistrationToSetPaymentApp(
const std::string& instrument_key,
const std::string& name,
const std::string& icon,
const std::vector<std::string>& enabled_methods,
const std::string& method,
SetPaymentAppInfoCallback callback,
ServiceWorkerStatusCode status,
scoped_refptr<ServiceWorkerRegistration> registration) {
......@@ -472,16 +471,15 @@ void PaymentAppDatabase::DidFindRegistrationToSetPaymentApp(
{{CreatePaymentAppKey(registration->pattern().spec()),
serialized_payment_app}},
base::Bind(&PaymentAppDatabase::DidWritePaymentAppForSetPaymentApp,
weak_ptr_factory_.GetWeakPtr(), instrument_key,
enabled_methods, base::Passed(std::move(callback)),
std::move(registration)));
weak_ptr_factory_.GetWeakPtr(), instrument_key, method,
base::Passed(std::move(callback)), std::move(registration)));
return;
}
void PaymentAppDatabase::DidWritePaymentAppForSetPaymentApp(
const std::string& instrument_key,
const std::vector<std::string>& enabled_methods,
const std::string& method,
SetPaymentAppInfoCallback callback,
scoped_refptr<ServiceWorkerRegistration> registration,
ServiceWorkerStatusCode status) {
......@@ -495,9 +493,7 @@ void PaymentAppDatabase::DidWritePaymentAppForSetPaymentApp(
StoredPaymentInstrumentProto instrument_proto;
instrument_proto.set_registration_id(registration->id());
instrument_proto.set_instrument_key(instrument_key);
for (const auto& method : enabled_methods) {
instrument_proto.add_enabled_methods(method);
}
instrument_proto.set_method(method);
std::string serialized_instrument;
bool success = instrument_proto.SerializeToString(&serialized_instrument);
......@@ -582,10 +578,7 @@ void PaymentAppDatabase::DidReadAllPaymentInstruments(
if (!base::ContainsKey(apps, id))
continue;
for (const auto& method : instrument_proto.enabled_methods()) {
apps[id]->enabled_methods.push_back(method);
}
apps[id]->enabled_methods.emplace_back(instrument_proto.method());
apps[id]->capabilities.emplace_back(StoredCapabilities());
for (const auto& network : instrument_proto.supported_card_networks()) {
apps[id]->capabilities.back().supported_card_networks.emplace_back(
......@@ -773,9 +766,7 @@ void PaymentAppDatabase::DidFindRegistrationToWritePaymentInstrument(
instrument_proto.set_decoded_instrument_icon(decoded_instrument_icon);
instrument_proto.set_instrument_key(instrument_key);
instrument_proto.set_name(instrument->name);
for (const auto& method : instrument->enabled_methods) {
instrument_proto.add_enabled_methods(method);
}
instrument_proto.set_method(instrument->method);
for (const auto& icon : instrument->icons) {
StoredPaymentInstrumentImageObject* image_object_proto =
instrument_proto.add_icons();
......
......@@ -82,7 +82,7 @@ class CONTENT_EXPORT PaymentAppDatabase {
const std::string& instrument_key,
const std::string& name,
const std::string& icon,
const std::vector<std::string>& enabled_methods,
const std::string& method,
SetPaymentAppInfoCallback callback);
private:
......@@ -210,13 +210,13 @@ class CONTENT_EXPORT PaymentAppDatabase {
const std::string& instrument_key,
const std::string& name,
const std::string& icon,
const std::vector<std::string>& enabled_methods,
const std::string& method,
SetPaymentAppInfoCallback callback,
ServiceWorkerStatusCode status,
scoped_refptr<ServiceWorkerRegistration> registration);
void DidWritePaymentAppForSetPaymentApp(
const std::string& instrument_key,
const std::vector<std::string>& enabled_methods,
const std::string& method,
SetPaymentAppInfoCallback callback,
scoped_refptr<ServiceWorkerRegistration> registration,
ServiceWorkerStatusCode status);
......
......@@ -32,12 +32,13 @@ class SelfDeleteInstaller
const GURL& sw_url,
const GURL& scope,
bool use_cache,
const std::vector<std::string>& enabled_methods,
const std::string& method,
PaymentAppInstaller::InstallPaymentAppCallback callback)
: app_name_(app_name),
app_icon_(app_icon),
sw_url_(sw_url),
scope_(scope),
method_(method),
callback_(std::move(callback)) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
......@@ -45,9 +46,6 @@ class SelfDeleteInstaller
// installation early.
Observe(web_contents);
std::copy(enabled_methods.begin(), enabled_methods.end(),
std::back_inserter(enabled_methods_));
content::BrowserContext* browser_context =
web_contents->GetBrowserContext();
ServiceWorkerContextWrapper* service_worker_context =
......@@ -137,7 +135,7 @@ class SelfDeleteInstaller
BrowserThread::IO, FROM_HERE,
base::BindOnce(&SelfDeleteInstaller::SetPaymentAppInfoOnIO, this,
payment_app_context, registration_id_, scope_.spec(),
app_name_, app_icon_, enabled_methods_));
app_name_, app_icon_, method_));
}
void SetPaymentAppInfoOnIO(
......@@ -146,12 +144,12 @@ class SelfDeleteInstaller
const std::string& instrument_key,
const std::string& name,
const std::string& app_icon,
const std::vector<std::string>& enabled_methods) {
const std::string& method) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
payment_app_context->payment_app_database()
->SetPaymentAppInfoForRegisteredServiceWorker(
registration_id, instrument_key, name, app_icon, enabled_methods,
registration_id, instrument_key, name, app_icon, method,
base::BindOnce(&SelfDeleteInstaller::OnSetPaymentAppInfo, this));
}
......@@ -192,7 +190,7 @@ class SelfDeleteInstaller
std::string app_icon_;
GURL sw_url_;
GURL scope_;
std::vector<std::string> enabled_methods_;
std::string method_;
PaymentAppInstaller::InstallPaymentAppCallback callback_;
int64_t registration_id_ = -1; // Take -1 as an invalid registration Id.
......@@ -204,19 +202,18 @@ class SelfDeleteInstaller
} // namespace.
// Static
void PaymentAppInstaller::Install(
WebContents* web_contents,
const std::string& app_name,
const std::string& app_icon,
const GURL& sw_url,
const GURL& scope,
bool use_cache,
const std::vector<std::string>& enabled_methods,
InstallPaymentAppCallback callback) {
void PaymentAppInstaller::Install(WebContents* web_contents,
const std::string& app_name,
const std::string& app_icon,
const GURL& sw_url,
const GURL& scope,
bool use_cache,
const std::string& method,
InstallPaymentAppCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
new SelfDeleteInstaller(web_contents, app_name, app_icon, sw_url, scope,
use_cache, enabled_methods, std::move(callback));
use_cache, method, std::move(callback));
}
} // namespace content
\ No newline at end of file
} // namespace content
......@@ -39,7 +39,7 @@ class PaymentAppInstaller {
const GURL& sw_url,
const GURL& scope,
bool use_cache,
const std::vector<std::string>& enabled_methods,
const std::string& method,
InstallPaymentAppCallback callback);
private:
......@@ -48,4 +48,4 @@ class PaymentAppInstaller {
} // namespace content.
#endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_INSTALLER_H_
\ No newline at end of file
#endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_INSTALLER_H_
......@@ -410,7 +410,7 @@ void PaymentAppProviderImpl::InstallAndInvokePaymentApp(
const std::string& sw_js_url,
const std::string& sw_scope,
bool sw_use_cache,
const std::vector<std::string>& enabled_methods,
const std::string& method,
InvokePaymentAppCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
......@@ -418,7 +418,7 @@ void PaymentAppProviderImpl::InstallAndInvokePaymentApp(
GURL url = GURL(sw_js_url);
DCHECK(base::IsStringUTF8(sw_scope));
GURL scope = GURL(sw_scope);
if (!url.is_valid() || !scope.is_valid() || enabled_methods.size() == 0) {
if (!url.is_valid() || !scope.is_valid() || method.empty()) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(callback),
......@@ -438,7 +438,7 @@ void PaymentAppProviderImpl::InstallAndInvokePaymentApp(
PaymentAppInstaller::Install(
web_contents, app_name, string_encoded_icon, url, scope, sw_use_cache,
enabled_methods,
method,
base::BindOnce(&OnInstallPaymentApp, std::move(event_data),
std::move(callback)));
}
......
......@@ -33,7 +33,7 @@ class CONTENT_EXPORT PaymentAppProviderImpl : public PaymentAppProvider {
const std::string& sw_js_url,
const std::string& sw_scope,
bool sw_use_cache,
const std::vector<std::string>& enabled_methods,
const std::string& method,
InvokePaymentAppCallback callback) override;
void CanMakePayment(BrowserContext* browser_context,
int64_t registration_id,
......
......@@ -211,17 +211,17 @@ TEST_F(PaymentAppProviderTest, GetAllPaymentAppsTest) {
PaymentHandlerStatus status;
PaymentInstrumentPtr instrument_1 = PaymentInstrument::New();
instrument_1->enabled_methods.push_back("hellopay");
instrument_1->method = "hellopay";
SetPaymentInstrument(manager1, "test_key1", std::move(instrument_1),
base::BindOnce(&SetPaymentInstrumentCallback, &status));
PaymentInstrumentPtr instrument_2 = PaymentInstrument::New();
instrument_2->enabled_methods.push_back("hellopay");
instrument_2->method = "hellopay";
SetPaymentInstrument(manager2, "test_key2", std::move(instrument_2),
base::BindOnce(&SetPaymentInstrumentCallback, &status));
PaymentInstrumentPtr instrument_3 = PaymentInstrument::New();
instrument_3->enabled_methods.push_back("bobpay");
instrument_3->method = "bobpay";
SetPaymentInstrument(manager2, "test_key3", std::move(instrument_3),
base::BindOnce(&SetPaymentInstrumentCallback, &status));
......@@ -244,17 +244,17 @@ TEST_F(PaymentAppProviderTest, GetAllPaymentAppsFromTheSameOriginTest) {
PaymentHandlerStatus status;
PaymentInstrumentPtr instrument_1 = PaymentInstrument::New();
instrument_1->enabled_methods.push_back("hellopay");
instrument_1->method = "hellopay";
SetPaymentInstrument(manager1, "test_key1", std::move(instrument_1),
base::BindOnce(&SetPaymentInstrumentCallback, &status));
PaymentInstrumentPtr instrument_2 = PaymentInstrument::New();
instrument_2->enabled_methods.push_back("hellopay");
instrument_2->method = "hellopay";
SetPaymentInstrument(manager2, "test_key2", std::move(instrument_2),
base::BindOnce(&SetPaymentInstrumentCallback, &status));
PaymentInstrumentPtr instrument_3 = PaymentInstrument::New();
instrument_3->enabled_methods.push_back("bobpay");
instrument_3->method = "bobpay";
SetPaymentInstrument(manager2, "test_key3", std::move(instrument_3),
base::BindOnce(&SetPaymentInstrumentCallback, &status));
......
......@@ -126,8 +126,8 @@ class PaymentManagerTest : public PaymentAppContentUnitTestBase {
TEST_F(PaymentManagerTest, SetAndGetPaymentInstrument) {
PaymentHandlerStatus write_status = PaymentHandlerStatus::NOT_FOUND;
PaymentInstrumentPtr write_details = PaymentInstrument::New();
write_details->name = "Visa ending ****4756",
write_details->enabled_methods.push_back("visa");
write_details->name = "Visa ending ****4756";
write_details->method = "visa";
write_details->stringified_capabilities = "{}";
SetPaymentInstrument("test_key", std::move(write_details), &write_status);
// Write the first instrument of a web payment app will return
......@@ -141,8 +141,7 @@ TEST_F(PaymentManagerTest, SetAndGetPaymentInstrument) {
GetPaymentInstrument("test_key", &read_details, &read_status);
ASSERT_EQ(PaymentHandlerStatus::SUCCESS, read_status);
EXPECT_EQ("Visa ending ****4756", read_details->name);
ASSERT_EQ(1U, read_details->enabled_methods.size());
EXPECT_EQ("visa", read_details->enabled_methods[0]);
EXPECT_EQ("visa", read_details->method);
EXPECT_EQ("{}", read_details->stringified_capabilities);
}
......@@ -156,8 +155,8 @@ TEST_F(PaymentManagerTest, GetUnstoredPaymentInstrument) {
TEST_F(PaymentManagerTest, DeletePaymentInstrument) {
PaymentHandlerStatus write_status = PaymentHandlerStatus::NOT_FOUND;
PaymentInstrumentPtr write_details = PaymentInstrument::New();
write_details->name = "Visa ending ****4756",
write_details->enabled_methods.push_back("visa");
write_details->name = "Visa ending ****4756";
write_details->method = "visa";
write_details->stringified_capabilities = "{}";
SetPaymentInstrument("test_key", std::move(write_details), &write_status);
// Write the first instrument of a web payment app will return
......@@ -183,8 +182,8 @@ TEST_F(PaymentManagerTest, DeletePaymentInstrument) {
TEST_F(PaymentManagerTest, HasPaymentInstrument) {
PaymentHandlerStatus write_status = PaymentHandlerStatus::NOT_FOUND;
PaymentInstrumentPtr write_details = PaymentInstrument::New();
write_details->name = "Visa ending ****4756",
write_details->enabled_methods.push_back("visa");
write_details->name = "Visa ending ****4756";
write_details->method = "visa";
write_details->stringified_capabilities = "{}";
SetPaymentInstrument("test_key", std::move(write_details), &write_status);
// Write the first instrument of a web payment app will return
......
......@@ -57,7 +57,7 @@ class CONTENT_EXPORT PaymentAppProvider {
const std::string& sw_js_url,
const std::string& sw_scope,
bool sw_use_cache,
const std::vector<std::string>& enabled_methods,
const std::string& method,
InvokePaymentAppCallback callback) = 0;
virtual void CanMakePayment(
BrowserContext* browser_context,
......
......@@ -17,7 +17,7 @@ function registerPaymentApp() {
'basic-card-payment-app-id',
{
name: 'Visa ****',
enabledMethods: ['basic-card'],
method: 'basic-card',
icons: [
{
'src': 'icon-1x.png',
......@@ -42,7 +42,7 @@ function registerPaymentApp() {
'bobpay-payment-app-id',
{
name: 'Bob Pay',
enabledMethods: ['https://bobpay.com'],
method: 'https://bobpay.com',
icons: [
{
'src': 'icon-1x.png',
......
......@@ -40,7 +40,7 @@ promise_test(test => {
'purpose': 'any badge'
}
],
enabledMethods: ['basic-card'],
method: 'basic-card',
capabilities: {
supportedNetworks: ['visa'],
supportedTypes: ['credit']
......@@ -53,7 +53,7 @@ promise_test(test => {
})
.then(stored_instrument => {
assert_equals(stored_instrument.name, 'Visa ending ****4756');
assert_array_equals(stored_instrument.enabledMethods, ['basic-card']);
assert_equals(stored_instrument.method, 'basic-card');
assert_equals(stored_instrument.icons.length, 2);
assert_object_equals(stored_instrument.icons[0], {
src: location.origin + '/payments/resources/icon-1x.png',
......@@ -112,7 +112,7 @@ promise_test(test => {
'test_key',
{
name: 'Visa ending ****4756',
enabledMethods: ['basic-card'],
method: 'basic-card',
capabilities: {
supportedNetworks: ['visa'],
supportedTypes: ['credit']
......@@ -152,7 +152,7 @@ promise_test(test => {
'test_key',
{
name: 'Visa ending ****4756',
enabledMethods: ['basic-card'],
method: 'basic-card',
capabilities: {
supportedNetworks: ['visa'],
supportedTypes: ['credit']
......@@ -193,7 +193,7 @@ promise_test(test => {
'test_key1',
{
name: 'Visa ending ****4756',
enabledMethods: ['basic-card'],
method: 'basic-card',
capabilities: {
supportedNetworks: ['visa'],
supportedTypes: ['credit']
......@@ -203,7 +203,7 @@ promise_test(test => {
'test_key2',
{
name: "My Bob Pay Account: john@example.com",
enabledMethods: ["https://bobpay.com/"]
method: "https://bobpay.com/"
})
];
return Promise.all(instruments);
......@@ -238,7 +238,7 @@ promise_test(test => {
'test_key1',
{
name: 'Visa ending ****4756',
enabledMethods: ['basic-card'],
method: 'basic-card',
capabilities: {
supportedNetworks: ['visa'],
supportedTypes: ['credit']
......@@ -248,7 +248,7 @@ promise_test(test => {
'test_key2',
{
name: "My Bob Pay Account: john@example.com",
enabledMethods: ["https://bobpay.com/"]
method: "https://bobpay.com/"
})
];
return Promise.all(instruments);
......@@ -303,7 +303,7 @@ promise_test(test => {
'purpose': 'any badge'
}
],
enabledMethods: ['basic-card'],
method: 'basic-card',
capabilities: {
supportedNetworks: ['visa'],
supportedTypes: ['credit']
......
......@@ -7,6 +7,6 @@
dictionary PaymentInstrument {
required DOMString name;
sequence<ImageObject> icons;
sequence<DOMString> enabledMethods;
DOMString method;
object capabilities;
};
......@@ -249,9 +249,8 @@ void PaymentInstruments::OnRequestPermission(
}
}
if (details.hasEnabledMethods()) {
instrument->enabled_methods = details.enabledMethods();
}
instrument->method =
details.hasMethod() ? details.method() : WTF::g_empty_string;
if (details.hasCapabilities()) {
v8::Local<v8::String> value;
......@@ -264,7 +263,7 @@ void PaymentInstruments::OnRequestPermission(
return;
}
instrument->stringified_capabilities = ToCoreString(value);
if (instrument->enabled_methods.Contains("basic-card")) {
if (instrument->method == "basic-card") {
ExceptionState exception_state(resolver->GetScriptState()->GetIsolate(),
ExceptionState::kSetterContext,
"PaymentInstruments", "set");
......@@ -326,13 +325,7 @@ void PaymentInstruments::onGetPaymentInstrument(
icons.emplace_back(image_object);
}
instrument.setIcons(icons);
Vector<String> enabled_methods;
for (const auto& method : stored_instrument->enabled_methods) {
enabled_methods.push_back(method);
}
instrument.setEnabledMethods(enabled_methods);
instrument.setMethod(stored_instrument->method);
if (!stored_instrument->stringified_capabilities.IsEmpty()) {
ExceptionState exception_state(resolver->GetScriptState()->GetIsolate(),
ExceptionState::kGetterContext,
......
......@@ -25,7 +25,7 @@ enum PaymentHandlerStatus {
struct PaymentInstrument {
string name;
array<blink.mojom.ManifestIcon> icons;
array<string> enabled_methods;
string method;
string stringified_capabilities;
// Parsed basic-card specific capabilities.
......
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