Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/android/payments/service_worker_payment_app_bridge.h" | |
| 6 | |
| 7 #include "base/android/jni_string.h" | |
| 8 #include "base/android/scoped_java_ref.h" | |
| 9 #include "chrome/browser/profiles/profile_manager.h" | |
| 10 #include "components/payments/payment_app.mojom.h" | |
| 11 #include "content/public/browser/service_worker_context.h" | |
| 12 #include "content/public/browser/storage_partition.h" | |
| 13 #include "jni/ServiceWorkerPaymentAppBridge_jni.h" | |
| 14 | |
| 15 using base::android::ConvertUTF8ToJavaString; | |
| 16 using base::android::JavaParamRef; | |
| 17 using base::android::ScopedJavaLocalRef; | |
| 18 | |
| 19 static ScopedJavaLocalRef<jobject> GetAllAppManifests( | |
| 20 JNIEnv* env, | |
| 21 const JavaParamRef<jclass>& jcaller) { | |
| 22 NOTIMPLEMENTED(); | |
|
please use gerrit instead
2016/12/07 13:43:58
I would advise against using NOTIMPLEMENTED() in a
tommyt
2016/12/08 13:19:13
I've removed the NOTIMPLEMENTED()
| |
| 23 | |
| 24 // TODO(tommyt): crbug.com/669876. Initialise the following two variables. | |
| 25 // At the moment, they are empty, so this function will return an empty | |
| 26 // list of manifests. We need to hook this function up to the service worker | |
| 27 // payment apps. | |
| 28 std::string scope_url; | |
| 29 std::vector<payments::mojom::PaymentAppManifestPtr> manifests; | |
| 30 | |
| 31 ScopedJavaLocalRef<jobject> java_manifests = | |
| 32 Java_ServiceWorkerPaymentAppBridge_createManifestList(env); | |
| 33 for (const auto& manifest : manifests) { | |
| 34 ScopedJavaLocalRef<jobject> java_manifest = | |
| 35 Java_ServiceWorkerPaymentAppBridge_createAndAddManifest( | |
| 36 env, java_manifests, ConvertUTF8ToJavaString(env, scope_url), | |
| 37 ConvertUTF8ToJavaString(env, manifest->label), | |
| 38 ConvertUTF8ToJavaString( | |
| 39 env, manifest->icon ? *manifest->icon : nullptr)); | |
| 40 for (const auto& option : manifest->options) { | |
| 41 ScopedJavaLocalRef<jobject> java_option = | |
| 42 Java_ServiceWorkerPaymentAppBridge_createAndAddOption( | |
| 43 env, java_manifest, ConvertUTF8ToJavaString(env, option->id), | |
| 44 ConvertUTF8ToJavaString(env, option->label), | |
| 45 ConvertUTF8ToJavaString(env, | |
| 46 option->icon ? *option->icon : nullptr)); | |
| 47 for (const auto& enabled_method : option->enabled_methods) { | |
| 48 Java_ServiceWorkerPaymentAppBridge_addEnabledMethod( | |
| 49 env, java_option, ConvertUTF8ToJavaString(env, enabled_method)); | |
| 50 } | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 return java_manifests; | |
| 55 } | |
| 56 | |
| 57 static void InvokePaymentApp(JNIEnv* env, | |
| 58 const JavaParamRef<jclass>& jcaller, | |
| 59 const JavaParamRef<jstring>& scopeUrl, | |
| 60 const JavaParamRef<jstring>& optionId, | |
| 61 const JavaParamRef<jobject>& methodDataMap) { | |
| 62 NOTIMPLEMENTED(); | |
| 63 } | |
| 64 | |
| 65 // Register native methods | |
|
please use gerrit instead
2016/12/07 13:43:58
Static methods should have a comment like this to
tommyt
2016/12/08 13:19:13
I've removed the obvious comment, but this is not
please use gerrit instead
2016/12/08 13:47:01
You're right, my bad.
| |
| 66 bool RegisterServiceWorkerPaymentAppBridge(JNIEnv* env) { | |
| 67 return RegisterNativesImpl(env); | |
| 68 } | |
| OLD | NEW |