Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: chrome/browser/payments/android/payment_manifest_web_data_service_android.h

Issue 2838433002: [Payments] Cache payment manifests. (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include <vector>
12
13 #include "base/android/jni_weak_ref.h"
14 #include "base/android/scoped_java_ref.h"
15 #include "components/payments/android/payment_manifest_web_data_service.h"
16 #include "components/payments/mojom/payment_manifest_parser.mojom.h"
17 #include "components/webdata/common/web_data_results.h"
18 #include "components/webdata/common/web_data_service_base.h"
19 #include "components/webdata/common/web_data_service_consumer.h"
20
21 namespace payments {
22
23 // Android wrapper of the PaymentManifestWebDataService which provides access
24 // from the Java layer. Note that on Android, there's only a single profile, and
25 // therefore a single instance of this wrapper.
26 class PaymentManifestWebDataServiceAndroid : public WebDataServiceConsumer {
27 public:
28 // Registers the JNI bindings for this class.
29 static bool Register(JNIEnv* env);
30
31 PaymentManifestWebDataServiceAndroid(JNIEnv* env, jobject obj);
32 ~PaymentManifestWebDataServiceAndroid() override;
33
34 // Override WebDataServiceConsumer interface.
35 void OnWebDataServiceRequestDone(
36 WebDataServiceBase::Handle h,
37 std::unique_ptr<WDTypedResult> result) override;
38
39 // Destroys this object.
40 void Destroy(JNIEnv* env,
41 const base::android::JavaParamRef<jobject>& unused_obj);
42
43 // Adds the supported |japp_package_names| of the |jmethod_name| to the
44 // 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>& japp_package_names);
50
51 // Adds the web app |jmanifest_sections|.
52 void AddPaymentWebAppManifest(
53 JNIEnv* env,
54 const base::android::JavaParamRef<jobject>& unused_obj,
55 const base::android::JavaParamRef<jobjectArray>& jmanifest_sections);
56
57 // Gets the payment |jmethod_name|'s manifest asynchronously from the web data
58 // service. Return true if the result will be returned through |jcallback|.
59 bool GetPaymentMethodManifest(
60 JNIEnv* env,
61 const base::android::JavaParamRef<jobject>& unused_obj,
62 const base::android::JavaParamRef<jstring>& jmethod_name,
63 const base::android::JavaParamRef<jobject>& jcallback);
64
65 // Gets the payment |japp_package_name|'s manifest asynchronously from the web
66 // data service. Return true if the result will be returned through
67 // |jcallback|.
68 bool GetPaymentWebAppManifest(
69 JNIEnv* env,
70 const base::android::JavaParamRef<jobject>& unused_obj,
71 const base::android::JavaParamRef<jstring>& japp_package_name,
72 const base::android::JavaParamRef<jobject>& jcallback);
73
74 private:
75 void OnWebAppManifestRequestDone(JNIEnv* env,
76 WebDataServiceBase::Handle h,
77 WDTypedResult* result);
78 void OnPaymentMethodManifestRequestDone(JNIEnv* env,
79 WebDataServiceBase::Handle h,
80 WDTypedResult* result);
81
82 // Pointer to the java counterpart.
83 JavaObjectWeakGlobalRef weak_java_obj_;
84
85 // Map of request handle and its correspond callback.
86 std::map<WebDataServiceBase::Handle,
87 std::unique_ptr<base::android::ScopedJavaGlobalRef<jobject>>>
88 web_data_service_requests_;
89
90 DISALLOW_COPY_AND_ASSIGN(PaymentManifestWebDataServiceAndroid);
91 };
92
93 } // namespace payments
94
95 #endif // CHROME_BROWSER_PAYMENTS_ANDROID_PAYMENT_MANIFEST_WEB_DATA_SERVICE_AND ROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698