| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 ContentViewCoreImpl::ContentViewCoreImpl( | 212 ContentViewCoreImpl::ContentViewCoreImpl( |
| 213 JNIEnv* env, | 213 JNIEnv* env, |
| 214 jobject obj, | 214 jobject obj, |
| 215 WebContents* web_contents, | 215 WebContents* web_contents, |
| 216 const base::android::JavaRef<jobject>& view_android_delegate, | 216 const base::android::JavaRef<jobject>& view_android_delegate, |
| 217 ui::WindowAndroid* window_android, | 217 ui::WindowAndroid* window_android, |
| 218 jobject java_bridge_retained_object_set) | 218 jobject java_bridge_retained_object_set) |
| 219 : WebContentsObserver(web_contents), | 219 : WebContentsObserver(web_contents), |
| 220 java_ref_(env, obj), | 220 java_ref_(env, obj), |
| 221 view_(view_android_delegate, window_android), | 221 view_(view_android_delegate), |
| 222 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 222 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 223 page_scale_(1), | 223 page_scale_(1), |
| 224 dpi_scale_(ui::GetScaleFactorForNativeView(&view_)), | 224 dpi_scale_(ui::GetScaleFactorForNativeView(&view_)), |
| 225 device_orientation_(0), | 225 device_orientation_(0), |
| 226 accessibility_enabled_(false) { | 226 accessibility_enabled_(false) { |
| 227 CHECK(web_contents) << | 227 CHECK(web_contents) << |
| 228 "A ContentViewCoreImpl should be created with a valid WebContents."; | 228 "A ContentViewCoreImpl should be created with a valid WebContents."; |
| 229 DCHECK(window_android); | 229 DCHECK(window_android); |
| 230 DCHECK(!view_android_delegate.is_null()); | 230 DCHECK(!view_android_delegate.is_null()); |
| 231 window_android->AddChild(&view_); |
| 231 view_.SetLayer(cc::SolidColorLayer::Create()); | 232 view_.SetLayer(cc::SolidColorLayer::Create()); |
| 232 view_.GetLayer()->SetBackgroundColor(GetBackgroundColor(env, obj)); | 233 view_.GetLayer()->SetBackgroundColor(GetBackgroundColor(env, obj)); |
| 233 gfx::Size physical_size( | 234 gfx::Size physical_size( |
| 234 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), | 235 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), |
| 235 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); | 236 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); |
| 236 view_.GetLayer()->SetBounds(physical_size); | 237 view_.GetLayer()->SetBounds(physical_size); |
| 237 view_.GetLayer()->SetIsDrawable(true); | 238 view_.GetLayer()->SetIsDrawable(true); |
| 238 | 239 |
| 239 // Currently, the only use case we have for overriding a user agent involves | 240 // Currently, the only use case we have for overriding a user agent involves |
| 240 // spoofing a desktop Linux user agent for "Request desktop site". | 241 // spoofing a desktop Linux user agent for "Request desktop site". |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 env, j_obj.obj(), reinterpret_cast<intptr_t>(this)); | 279 env, j_obj.obj(), reinterpret_cast<intptr_t>(this)); |
| 279 } | 280 } |
| 280 } | 281 } |
| 281 | 282 |
| 282 void ContentViewCoreImpl::UpdateWindowAndroid( | 283 void ContentViewCoreImpl::UpdateWindowAndroid( |
| 283 JNIEnv* env, | 284 JNIEnv* env, |
| 284 const base::android::JavaParamRef<jobject>& obj, | 285 const base::android::JavaParamRef<jobject>& obj, |
| 285 jlong window_android) { | 286 jlong window_android) { |
| 286 if (window_android) { | 287 if (window_android) { |
| 287 DCHECK(!view_.GetWindowAndroid()); | 288 DCHECK(!view_.GetWindowAndroid()); |
| 288 view_.SetWindowAndroid( | 289 ui::WindowAndroid* window = |
| 289 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 290 reinterpret_cast<ui::WindowAndroid*>(window_android); |
| 291 window->AddChild(&view_); |
| 290 FOR_EACH_OBSERVER(ContentViewCoreImplObserver, | 292 FOR_EACH_OBSERVER(ContentViewCoreImplObserver, |
| 291 observer_list_, | 293 observer_list_, |
| 292 OnAttachedToWindow()); | 294 OnAttachedToWindow()); |
| 293 } else { | 295 } else { |
| 294 FOR_EACH_OBSERVER(ContentViewCoreImplObserver, | 296 FOR_EACH_OBSERVER(ContentViewCoreImplObserver, |
| 295 observer_list_, | 297 observer_list_, |
| 296 OnDetachedFromWindow()); | 298 OnDetachedFromWindow()); |
| 297 view_.SetWindowAndroid(nullptr); | 299 view_.RemoveFromParent(); |
| 298 } | 300 } |
| 299 } | 301 } |
| 300 | 302 |
| 301 base::android::ScopedJavaLocalRef<jobject> | 303 base::android::ScopedJavaLocalRef<jobject> |
| 302 ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env, | 304 ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env, |
| 303 const JavaParamRef<jobject>& obj) { | 305 const JavaParamRef<jobject>& obj) { |
| 304 return web_contents_->GetJavaWebContents(); | 306 return web_contents_->GetJavaWebContents(); |
| 305 } | 307 } |
| 306 | 308 |
| 307 base::android::ScopedJavaLocalRef<jobject> | 309 base::android::ScopedJavaLocalRef<jobject> |
| (...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 return ScopedJavaLocalRef<jobject>(); | 1665 return ScopedJavaLocalRef<jobject>(); |
| 1664 | 1666 |
| 1665 return view->GetJavaObject(); | 1667 return view->GetJavaObject(); |
| 1666 } | 1668 } |
| 1667 | 1669 |
| 1668 bool RegisterContentViewCore(JNIEnv* env) { | 1670 bool RegisterContentViewCore(JNIEnv* env) { |
| 1669 return RegisterNativesImpl(env) && JNI_DragEvent::RegisterNativesImpl(env); | 1671 return RegisterNativesImpl(env) && JNI_DragEvent::RegisterNativesImpl(env); |
| 1670 } | 1672 } |
| 1671 | 1673 |
| 1672 } // namespace content | 1674 } // namespace content |
| OLD | NEW |