Rakina Zata Amni | 65a5dc4 | 2025-03-03 02:51:55 | [diff] [blame] | 1 | // Copyright 2025 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "content/browser/android/page_proxy.h" |
| 6 | |
| 7 | #include "base/android/jni_android.h" |
| 8 | #include "base/android/jni_string.h" |
| 9 | #include "base/android/scoped_java_ref.h" |
| 10 | #include "content/browser/renderer_host/page_impl.h" |
| 11 | #include "content/browser/renderer_host/render_frame_host_impl.h" |
| 12 | #include "content/public/browser/content_browser_client.h" |
| 13 | |
| 14 | // Must come after all headers that specialize FromJniType() / ToJniType(). |
| 15 | #include "content/public/android/content_jni_headers/Page_jni.h" |
| 16 | |
| 17 | using base::android::AttachCurrentThread; |
| 18 | using base::android::JavaParamRef; |
| 19 | |
| 20 | namespace content { |
| 21 | |
| 22 | PageProxy::PageProxy(PageImpl* cpp_page) { |
| 23 | JNIEnv* env = AttachCurrentThread(); |
| 24 | java_page_ = Java_Page_Constructor( |
| 25 | env, cpp_page->GetMainDocument().lifecycle_state() == |
| 26 | RenderFrameHostImpl::LifecycleStateImpl::kPrerendering); |
| 27 | } |
| 28 | |
| 29 | PageProxy::~PageProxy() = default; |
| 30 | |
| 31 | void PageProxy::WillDeletePage(bool is_prerendering) { |
| 32 | JNIEnv* env = AttachCurrentThread(); |
| 33 | Java_Page_willDeletePage(env, java_page_, is_prerendering); |
| 34 | } |
| 35 | |
| 36 | } // namespace content |