| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/android/payments/service_worker_payment_app_bridge.h" | 5 #include "chrome/browser/android/payments/service_worker_payment_app_bridge.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 using ::payments::mojom::PaymentDetailsModifierPtr; | 35 using ::payments::mojom::PaymentDetailsModifierPtr; |
| 36 using ::payments::mojom::PaymentItem; | 36 using ::payments::mojom::PaymentItem; |
| 37 using ::payments::mojom::PaymentMethodData; | 37 using ::payments::mojom::PaymentMethodData; |
| 38 using ::payments::mojom::PaymentMethodDataPtr; | 38 using ::payments::mojom::PaymentMethodDataPtr; |
| 39 | 39 |
| 40 void OnGotAllPaymentApps(const JavaRef<jobject>& jweb_contents, | 40 void OnGotAllPaymentApps(const JavaRef<jobject>& jweb_contents, |
| 41 const JavaRef<jobject>& jcallback, | 41 const JavaRef<jobject>& jcallback, |
| 42 content::PaymentAppProvider::PaymentApps apps) { | 42 content::PaymentAppProvider::PaymentApps apps) { |
| 43 JNIEnv* env = AttachCurrentThread(); | 43 JNIEnv* env = AttachCurrentThread(); |
| 44 | 44 |
| 45 // TODO(gogerald): Present payment app instead of instruments to user, |
| 46 // crbug.com/735063. |
| 45 for (const auto& app_info : apps) { | 47 for (const auto& app_info : apps) { |
| 46 ScopedJavaLocalRef<jobject> java_instruments = | 48 ScopedJavaLocalRef<jobject> java_instruments = |
| 47 Java_ServiceWorkerPaymentAppBridge_createInstrumentList(env); | 49 Java_ServiceWorkerPaymentAppBridge_createInstrumentList(env); |
| 48 for (const auto& instrument : app_info.second) { | 50 for (const auto& instrument : app_info.second->instruments) { |
| 49 Java_ServiceWorkerPaymentAppBridge_addInstrument( | 51 Java_ServiceWorkerPaymentAppBridge_addInstrument( |
| 50 env, java_instruments, jweb_contents, instrument->registration_id, | 52 env, java_instruments, jweb_contents, |
| 53 app_info.second->registration_id, |
| 51 ConvertUTF8ToJavaString(env, instrument->instrument_key), | 54 ConvertUTF8ToJavaString(env, instrument->instrument_key), |
| 52 ConvertUTF8ToJavaString(env, instrument->name), | 55 ConvertUTF8ToJavaString(env, instrument->name), |
| 53 ToJavaArrayOfStrings(env, instrument->enabled_methods), | 56 ToJavaArrayOfStrings(env, instrument->enabled_methods), |
| 54 instrument->icon == nullptr | 57 instrument->icon == nullptr |
| 55 ? nullptr | 58 ? nullptr |
| 56 : gfx::ConvertToJavaBitmap(instrument->icon.get())); | 59 : gfx::ConvertToJavaBitmap(instrument->icon.get())); |
| 57 } | 60 } |
| 58 Java_ServiceWorkerPaymentAppBridge_onPaymentAppCreated( | 61 Java_ServiceWorkerPaymentAppBridge_onPaymentAppCreated( |
| 59 env, java_instruments, jweb_contents, jcallback); | 62 env, java_instruments, jweb_contents, jcallback); |
| 60 } | 63 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 content::PaymentAppProvider::GetInstance()->InvokePaymentApp( | 188 content::PaymentAppProvider::GetInstance()->InvokePaymentApp( |
| 186 web_contents->GetBrowserContext(), registration_id, std::move(event_data), | 189 web_contents->GetBrowserContext(), registration_id, std::move(event_data), |
| 187 base::Bind(&OnPaymentAppInvoked, | 190 base::Bind(&OnPaymentAppInvoked, |
| 188 ScopedJavaGlobalRef<jobject>(env, jweb_contents), | 191 ScopedJavaGlobalRef<jobject>(env, jweb_contents), |
| 189 ScopedJavaGlobalRef<jobject>(env, jcallback))); | 192 ScopedJavaGlobalRef<jobject>(env, jcallback))); |
| 190 } | 193 } |
| 191 | 194 |
| 192 bool RegisterServiceWorkerPaymentAppBridge(JNIEnv* env) { | 195 bool RegisterServiceWorkerPaymentAppBridge(JNIEnv* env) { |
| 193 return RegisterNativesImpl(env); | 196 return RegisterNativesImpl(env); |
| 194 } | 197 } |
| OLD | NEW |