js_reply_proxy.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (c) 2019 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. #ifndef ANDROID_WEBVIEW_BROWSER_JS_JAVA_INTERACTION_JS_REPLY_PROXY_H_
  5. #define ANDROID_WEBVIEW_BROWSER_JS_JAVA_INTERACTION_JS_REPLY_PROXY_H_
  6. #include "base/android/jni_weak_ref.h"
  7. #include "base/android/scoped_java_ref.h"
  8. #include "base/memory/raw_ptr.h"
  9. namespace js_injection {
  10. class WebMessageReplyProxy;
  11. }
  12. namespace android_webview {
  13. class JsReplyProxy {
  14. public:
  15. explicit JsReplyProxy(js_injection::WebMessageReplyProxy* reply_proxy);
  16. JsReplyProxy(const JsReplyProxy&) = delete;
  17. JsReplyProxy& operator=(const JsReplyProxy&) = delete;
  18. ~JsReplyProxy();
  19. base::android::ScopedJavaLocalRef<jobject> GetJavaPeer();
  20. void PostMessage(JNIEnv* env,
  21. const base::android::JavaParamRef<jstring>& message);
  22. private:
  23. raw_ptr<js_injection::WebMessageReplyProxy> reply_proxy_;
  24. base::android::ScopedJavaGlobalRef<jobject> java_ref_;
  25. };
  26. } // namespace android_webview
  27. #endif // ANDROID_WEBVIEW_BROWSER_JS_JAVA_INTERACTION_JS_REPLY_PROXY_H_