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 CONTENT_BROWSER_ANDROID_DIALOG_OVERLAY_IMPL_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_DIALOG_OVERLAY_IMPL_H_ |
| 7 |
| 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_weak_ref.h" |
| 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/unguessable_token.h" |
| 12 #include "content/browser/android/content_view_core_impl.h" |
| 13 #include "content/browser/android/content_view_core_impl_observer.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 // Native counterpart to DialogOverlayImpl java class. This is created by the |
| 18 // java side. When the ContentViewCore for the provided token is attached or |
| 19 // detached from a WindowAndroid, we get the Android window token and notify the |
| 20 // java side. |
| 21 class DialogOverlayImpl : public ContentViewCoreImplObserver { |
| 22 public: |
| 23 // Registers the JNI methods for DialogOverlayImpl. |
| 24 static bool RegisterDialogOverlayImpl(JNIEnv* env); |
| 25 |
| 26 DialogOverlayImpl(const base::android::JavaParamRef<jobject>& obj, |
| 27 const base::UnguessableToken& token); |
| 28 ~DialogOverlayImpl() override; |
| 29 |
| 30 // Clean up and post to delete |this| later. |
| 31 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| 32 |
| 33 // ContentViewCoreImplObserver |
| 34 void OnContentViewCoreDestroyed() override; |
| 35 void OnAttachedToWindow() override; |
| 36 void OnDetachedFromWindow() override; |
| 37 |
| 38 // Unregister for tokens if we're registered, and clear |cvc_|. |
| 39 void UnregisterForTokensIfNeeded(); |
| 40 |
| 41 private: |
| 42 // Look up the ContentViewCore for |renderer_pid_| and |render_frame_id_|. |
| 43 ContentViewCoreImpl* GetContentViewCore(); |
| 44 |
| 45 // Java object that owns us. |
| 46 JavaObjectWeakGlobalRef obj_; |
| 47 |
| 48 base::UnguessableToken token_; |
| 49 |
| 50 // ContentViewCoreImpl instance that we're registered with as an observer. |
| 51 ContentViewCoreImpl* cvc_; |
| 52 }; |
| 53 |
| 54 } // namespace content |
| 55 |
| 56 #endif // CONTENT_BROWSER_ANDROID_DIALOG_OVERLAY_IMPL_H_ |
OLD | NEW |