Index: chrome/browser/payments/android/payment_manifest_web_data_service_android.h |
diff --git a/chrome/browser/payments/android/payment_manifest_web_data_service_android.h b/chrome/browser/payments/android/payment_manifest_web_data_service_android.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d63ea88185850334b85da385b6c060f49fd8e2af |
--- /dev/null |
+++ b/chrome/browser/payments/android/payment_manifest_web_data_service_android.h |
@@ -0,0 +1,85 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_PAYMENTS_ANDROID_PAYMENT_MANIFEST_WEB_DATA_SERVICE_ANDROID_H_ |
+#define CHROME_BROWSER_PAYMENTS_ANDROID_PAYMENT_MANIFEST_WEB_DATA_SERVICE_ANDROID_H_ |
+ |
+#include <jni.h> |
+#include <map> |
+#include <memory> |
+ |
+#include "base/android/jni_weak_ref.h" |
+#include "base/android/scoped_java_ref.h" |
+#include "components/payments/android/payment_manifest_web_data_service.h" |
+#include "components/webdata/common/web_data_results.h" |
+#include "components/webdata/common/web_data_service_base.h" |
+#include "components/webdata/common/web_data_service_consumer.h" |
+ |
+// Android wrapper of the PaymentManifestWebDataService which provides access |
+// from the Java layer. Note that on Android, there's only a single profile, and |
+// 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.
|
+namespace payments { |
+ |
+class PaymentManifestWebDataServiceAndroid : public WebDataServiceConsumer { |
+ public: |
+ // Registers the JNI bindings for this class. |
+ static bool Register(JNIEnv* env); |
+ |
+ 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.
|
+ |
+ // Override WebDataServiceConsumer interface. |
+ void OnWebDataServiceRequestDone( |
+ WebDataServiceBase::Handle h, |
+ std::unique_ptr<WDTypedResult> result) override; |
+ |
+ // Gets the payment |jmethod_name|'s manifest asynchronously from the web data |
+ // service. Return true if the result will be returned through |jcallback|. |
+ bool GetPaymentMethodManifest( |
+ JNIEnv* env, |
+ const base::android::JavaParamRef<jobject>& unused_obj, |
+ const base::android::JavaParamRef<jstring>& jmethod_name, |
+ const base::android::JavaParamRef<jobject>& jcallback); |
+ |
+ // Adds the supported |jweb_apps_ids| of the |jmethod_name| to the cache. |
+ void AddPaymentMethodManifest( |
+ JNIEnv* env, |
+ const base::android::JavaParamRef<jobject>& unused_obj, |
+ const base::android::JavaParamRef<jstring>& jmethod_name, |
+ const base::android::JavaParamRef<jobjectArray>& jweb_apps_ids); |
+ |
+ // Gets the payment |jweb_app_id|'s manifest asynchronously from the web data |
+ // service. Return true if the result will be returned through |jcallback|. |
+ 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.
|
+ JNIEnv* env, |
+ const base::android::JavaParamRef<jobject>& unused_obj, |
+ const base::android::JavaParamRef<jstring>& jweb_app_id, |
+ const base::android::JavaParamRef<jobject>& jcallback); |
+ |
+ // Adds the web app |manifest|. This function is called on C++ side. Put it |
+ // here for completeness and readability. |
+ static void AddPaymentWebAppManifest( |
+ 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.
|
+ |
+ private: |
+ void OnWebAppManifestRequestDone(JNIEnv* env, |
+ WebDataServiceBase::Handle h, |
+ WDTypedResult* result); |
+ void OnPaymentMethodManifestRequestDone(JNIEnv* env, |
+ WebDataServiceBase::Handle h, |
+ WDTypedResult* result); |
+ |
+ // Pointer to the java counterpart. |
+ JavaObjectWeakGlobalRef weak_java_obj_; |
+ |
+ // Map of request handle and its correspond callback. |
+ std::map<WebDataServiceBase::Handle, |
+ std::unique_ptr<base::android::ScopedJavaGlobalRef<jobject>>> |
+ web_data_service_requests_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PaymentManifestWebDataServiceAndroid); |
+}; |
+ |
+} // namespace payments |
+ |
+#endif // CHROME_BROWSER_PAYMENTS_ANDROID_PAYMENT_MANIFEST_WEB_DATA_SERVICE_ANDROID_H_ |