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_UI_WEBUI_WEBAPK_INFO_CALLBACK_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_WEBAPK_INFO_CALLBACK_H_ |
| 7 |
| 8 #include "base/android/jni_weak_ref.h" |
| 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/callback.h" |
| 11 |
| 12 // A callback wrapper for fetching information regarding the WebAPKs installed |
| 13 // on the Android device. |
| 14 class WebApkInfoCallback { |
| 15 public: |
| 16 explicit WebApkInfoCallback( |
| 17 const base::RepeatingCallback<void(std::string, std::string, int, int)>& |
| 18 callback); |
| 19 ~WebApkInfoCallback(); |
| 20 |
| 21 // Destroys this object. |
| 22 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| 23 |
| 24 // Fetches a list of the WebAPKs installed in the device, including their |
| 25 // package name and version info. |
| 26 void MakeInfoRequest(JNIEnv* env); |
| 27 |
| 28 // Called by Java code with information about a WebAPK. It will be called |
| 29 // once for each one installed in the device. |
| 30 void OnWebApkFound(JNIEnv* env, |
| 31 const base::android::JavaParamRef<jobject>& obj, |
| 32 const base::android::JavaParamRef<jstring>& name, |
| 33 const base::android::JavaParamRef<jstring>& package_name, |
| 34 const jint j_shell_apk_version, |
| 35 const jint j_version_code) const; |
| 36 |
| 37 // JNI registration. |
| 38 static bool Register(JNIEnv* env); |
| 39 |
| 40 private: |
| 41 // The wrapped native filter. |
| 42 base::RepeatingCallback<void(std::string, std::string, int, int)> callback_; |
| 43 |
| 44 // The Java counterpart of this C++ object. |
| 45 base::android::ScopedJavaGlobalRef<jobject> j_webapk_info_callback_; |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(WebApkInfoCallback); |
| 48 }; |
| 49 |
| 50 #endif // CHROME_BROWSER_UI_WEBUI_WEBAPK_INFO_CALLBACK_H_ |
OLD | NEW |