| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 Java_ContentViewCore_onNativeContentViewCoreDestroyed( | 260 Java_ContentViewCore_onNativeContentViewCoreDestroyed( |
| 261 env, j_obj, reinterpret_cast<intptr_t>(this)); | 261 env, j_obj, reinterpret_cast<intptr_t>(this)); |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 | 264 |
| 265 void ContentViewCoreImpl::UpdateWindowAndroid( | 265 void ContentViewCoreImpl::UpdateWindowAndroid( |
| 266 JNIEnv* env, | 266 JNIEnv* env, |
| 267 const base::android::JavaParamRef<jobject>& obj, | 267 const base::android::JavaParamRef<jobject>& obj, |
| 268 jlong window_android) { | 268 jlong window_android) { |
| 269 ui::ViewAndroid* view = GetViewAndroid(); | 269 ui::ViewAndroid* view = GetViewAndroid(); |
| 270 if (window_android) { | 270 ui::WindowAndroid* window = |
| 271 DCHECK(!GetWindowAndroid()); | 271 reinterpret_cast<ui::WindowAndroid*>(window_android); |
| 272 ui::WindowAndroid* window = | 272 if (window == GetWindowAndroid()) |
| 273 reinterpret_cast<ui::WindowAndroid*>(window_android); | 273 return; |
| 274 window->AddChild(view); | 274 if (GetWindowAndroid()) { |
| 275 for (auto& observer : observer_list_) | |
| 276 observer.OnAttachedToWindow(); | |
| 277 } else { | |
| 278 for (auto& observer : observer_list_) | 275 for (auto& observer : observer_list_) |
| 279 observer.OnDetachedFromWindow(); | 276 observer.OnDetachedFromWindow(); |
| 280 view->RemoveFromParent(); | 277 view->RemoveFromParent(); |
| 281 } | 278 } |
| 279 if (window) { |
| 280 window->AddChild(view); |
| 281 for (auto& observer : observer_list_) |
| 282 observer.OnAttachedToWindow(); |
| 283 } |
| 282 } | 284 } |
| 283 | 285 |
| 284 base::android::ScopedJavaLocalRef<jobject> | 286 base::android::ScopedJavaLocalRef<jobject> |
| 285 ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env, | 287 ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env, |
| 286 const JavaParamRef<jobject>& obj) { | 288 const JavaParamRef<jobject>& obj) { |
| 287 return web_contents_->GetJavaWebContents(); | 289 return web_contents_->GetJavaWebContents(); |
| 288 } | 290 } |
| 289 | 291 |
| 290 base::android::ScopedJavaLocalRef<jobject> | 292 base::android::ScopedJavaLocalRef<jobject> |
| 291 ContentViewCoreImpl::GetJavaWindowAndroid(JNIEnv* env, | 293 ContentViewCoreImpl::GetJavaWindowAndroid(JNIEnv* env, |
| (...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 return ScopedJavaLocalRef<jobject>(); | 1571 return ScopedJavaLocalRef<jobject>(); |
| 1570 | 1572 |
| 1571 return view->GetJavaObject(); | 1573 return view->GetJavaObject(); |
| 1572 } | 1574 } |
| 1573 | 1575 |
| 1574 bool RegisterContentViewCore(JNIEnv* env) { | 1576 bool RegisterContentViewCore(JNIEnv* env) { |
| 1575 return RegisterNativesImpl(env); | 1577 return RegisterNativesImpl(env); |
| 1576 } | 1578 } |
| 1577 | 1579 |
| 1578 } // namespace content | 1580 } // namespace content |
| OLD | NEW |