Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 #ifndef CHROME_BROWSER_PAYMENTS_ANDROID_PAYMENT_MANIFEST_WEB_DATA_SERVICE_ANDROI D_H_ | |
| 6 #define CHROME_BROWSER_PAYMENTS_ANDROID_PAYMENT_MANIFEST_WEB_DATA_SERVICE_ANDROI D_H_ | |
| 7 | |
| 8 #include <jni.h> | |
| 9 #include <map> | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "base/android/jni_weak_ref.h" | |
| 13 #include "base/android/scoped_java_ref.h" | |
| 14 #include "components/payments/android/payment_manifest_web_data_service.h" | |
| 15 #include "components/webdata/common/web_data_results.h" | |
| 16 #include "components/webdata/common/web_data_service_base.h" | |
| 17 #include "components/webdata/common/web_data_service_consumer.h" | |
| 18 | |
| 19 // Android wrapper of the PaymentManifestWebDataService which provides access | |
| 20 // from the Java layer. Note that on Android, there's only a single profile, and | |
| 21 // therefore a single instance of this wrapper. | |
|
please use gerrit instead
2017/04/24 18:22:32
This comment should be on the class, not on the na
gogerald1
2017/04/26 13:46:32
Done.
| |
| 22 namespace payments { | |
| 23 | |
| 24 class PaymentManifestWebDataServiceAndroid : public WebDataServiceConsumer { | |
| 25 public: | |
| 26 // Registers the JNI bindings for this class. | |
| 27 static bool Register(JNIEnv* env); | |
| 28 | |
| 29 PaymentManifestWebDataServiceAndroid(JNIEnv* env, jobject obj); | |
|
please use gerrit instead
2017/04/24 18:22:32
Need to override the parent destructor.
gogerald1
2017/04/26 13:46:33
Done.
| |
| 30 | |
| 31 // Override WebDataServiceConsumer interface. | |
| 32 void OnWebDataServiceRequestDone( | |
| 33 WebDataServiceBase::Handle h, | |
| 34 std::unique_ptr<WDTypedResult> result) override; | |
| 35 | |
| 36 // Gets the payment |jmethod_name|'s manifest asynchronously from the web data | |
| 37 // service. Return true if the result will be returned through |jcallback|. | |
| 38 bool GetPaymentMethodManifest( | |
| 39 JNIEnv* env, | |
| 40 const base::android::JavaParamRef<jobject>& unused_obj, | |
| 41 const base::android::JavaParamRef<jstring>& jmethod_name, | |
| 42 const base::android::JavaParamRef<jobject>& jcallback); | |
| 43 | |
| 44 // Adds the supported |jweb_apps_ids| of the |jmethod_name| to the cache. | |
| 45 void AddPaymentMethodManifest( | |
| 46 JNIEnv* env, | |
| 47 const base::android::JavaParamRef<jobject>& unused_obj, | |
| 48 const base::android::JavaParamRef<jstring>& jmethod_name, | |
| 49 const base::android::JavaParamRef<jobjectArray>& jweb_apps_ids); | |
| 50 | |
| 51 // Gets the payment |jweb_app_id|'s manifest asynchronously from the web data | |
| 52 // service. Return true if the result will be returned through |jcallback|. | |
| 53 bool GetPaymentWebAppManifest( | |
|
please use gerrit instead
2017/04/24 18:22:32
Please group the Get and Add methods together.
gogerald1
2017/04/26 13:46:32
Done.
| |
| 54 JNIEnv* env, | |
| 55 const base::android::JavaParamRef<jobject>& unused_obj, | |
| 56 const base::android::JavaParamRef<jstring>& jweb_app_id, | |
| 57 const base::android::JavaParamRef<jobject>& jcallback); | |
| 58 | |
| 59 // Adds the web app |manifest|. This function is called on C++ side. Put it | |
| 60 // here for completeness and readability. | |
| 61 static void AddPaymentWebAppManifest( | |
| 62 const std::vector<mojom::WebAppManifestSectionPtr>& manifest); | |
|
please use gerrit instead
2017/04/24 18:22:32
#include <vector>
#include "components/payments/mo
gogerald1
2017/04/26 13:46:32
Done.
| |
| 63 | |
| 64 private: | |
| 65 void OnWebAppManifestRequestDone(JNIEnv* env, | |
| 66 WebDataServiceBase::Handle h, | |
| 67 WDTypedResult* result); | |
| 68 void OnPaymentMethodManifestRequestDone(JNIEnv* env, | |
| 69 WebDataServiceBase::Handle h, | |
| 70 WDTypedResult* result); | |
| 71 | |
| 72 // Pointer to the java counterpart. | |
| 73 JavaObjectWeakGlobalRef weak_java_obj_; | |
| 74 | |
| 75 // Map of request handle and its correspond callback. | |
| 76 std::map<WebDataServiceBase::Handle, | |
| 77 std::unique_ptr<base::android::ScopedJavaGlobalRef<jobject>>> | |
| 78 web_data_service_requests_; | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(PaymentManifestWebDataServiceAndroid); | |
| 81 }; | |
| 82 | |
| 83 } // namespace payments | |
| 84 | |
| 85 #endif // CHROME_BROWSER_PAYMENTS_ANDROID_PAYMENT_MANIFEST_WEB_DATA_SERVICE_AND ROID_H_ | |
| OLD | NEW |