| 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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env, | 207 ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env, |
| 208 jobject obj) { | 208 jobject obj) { |
| 209 return reinterpret_cast<ContentViewCore*>( | 209 return reinterpret_cast<ContentViewCore*>( |
| 210 Java_ContentViewCore_getNativeContentViewCore(env, obj)); | 210 Java_ContentViewCore_getNativeContentViewCore(env, obj)); |
| 211 } | 211 } |
| 212 | 212 |
| 213 ContentViewCoreImpl::ContentViewCoreImpl( | 213 ContentViewCoreImpl::ContentViewCoreImpl( |
| 214 JNIEnv* env, | 214 JNIEnv* env, |
| 215 jobject obj, | 215 jobject obj, |
| 216 WebContents* web_contents, | 216 WebContents* web_contents, |
| 217 jobject view_android, | 217 jobject view_android_delegate, |
| 218 ui::WindowAndroid* window_android, | 218 ui::WindowAndroid* window_android, |
| 219 jobject java_bridge_retained_object_set) | 219 jobject java_bridge_retained_object_set) |
| 220 : WebContentsObserver(web_contents), | 220 : WebContentsObserver(web_contents), |
| 221 java_ref_(env, obj), | 221 java_ref_(env, obj), |
| 222 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 222 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 223 root_layer_(cc::SolidColorLayer::Create()), | 223 root_layer_(cc::SolidColorLayer::Create()), |
| 224 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()), | 224 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()), |
| 225 view_android_(new ui::ViewAndroid(view_android, window_android)), | 225 view_android_(new ui::ViewAndroid(view_android_delegate, window_android)), |
| 226 window_android_(window_android), | 226 window_android_(window_android), |
| 227 device_orientation_(0), | 227 device_orientation_(0), |
| 228 accessibility_enabled_(false) { | 228 accessibility_enabled_(false) { |
| 229 CHECK(web_contents) << | 229 CHECK(web_contents) << |
| 230 "A ContentViewCoreImpl should be created with a valid WebContents."; | 230 "A ContentViewCoreImpl should be created with a valid WebContents."; |
| 231 DCHECK(window_android_); | 231 DCHECK(window_android_); |
| 232 | 232 |
| 233 root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj)); | 233 root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj)); |
| 234 gfx::Size physical_size( | 234 gfx::Size physical_size( |
| 235 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), | 235 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), |
| (...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( | 1395 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( |
| 1396 static_cast<WebContentsImpl*>(web_contents())->GetView()); | 1396 static_cast<WebContentsImpl*>(web_contents())->GetView()); |
| 1397 DCHECK(wcva); | 1397 DCHECK(wcva); |
| 1398 wcva->SetContentViewCore(NULL); | 1398 wcva->SetContentViewCore(NULL); |
| 1399 } | 1399 } |
| 1400 | 1400 |
| 1401 // This is called for each ContentView. | 1401 // This is called for each ContentView. |
| 1402 jlong Init(JNIEnv* env, | 1402 jlong Init(JNIEnv* env, |
| 1403 jobject obj, | 1403 jobject obj, |
| 1404 jobject web_contents, | 1404 jobject web_contents, |
| 1405 jobject view_android, | 1405 jobject view_android_delegate, |
| 1406 jlong window_android, | 1406 jlong window_android, |
| 1407 jobject retained_objects_set) { | 1407 jobject retained_objects_set) { |
| 1408 ContentViewCoreImpl* view = new ContentViewCoreImpl( | 1408 ContentViewCoreImpl* view = new ContentViewCoreImpl( |
| 1409 env, obj, WebContents::FromJavaWebContents(web_contents), view_android, | 1409 env, obj, WebContents::FromJavaWebContents(web_contents), |
| 1410 view_android_delegate, |
| 1410 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1411 reinterpret_cast<ui::WindowAndroid*>(window_android), |
| 1411 retained_objects_set); | 1412 retained_objects_set); |
| 1412 return reinterpret_cast<intptr_t>(view); | 1413 return reinterpret_cast<intptr_t>(view); |
| 1413 } | 1414 } |
| 1414 | 1415 |
| 1415 static jobject FromWebContentsAndroid( | 1416 static jobject FromWebContentsAndroid( |
| 1416 JNIEnv* env, | 1417 JNIEnv* env, |
| 1417 jclass clazz, | 1418 jclass clazz, |
| 1418 jobject jweb_contents) { | 1419 jobject jweb_contents) { |
| 1419 WebContents* web_contents = WebContents::FromJavaWebContents(jweb_contents); | 1420 WebContents* web_contents = WebContents::FromJavaWebContents(jweb_contents); |
| 1420 if (!web_contents) | 1421 if (!web_contents) |
| 1421 return NULL; | 1422 return NULL; |
| 1422 | 1423 |
| 1423 ContentViewCore* view = ContentViewCore::FromWebContents(web_contents); | 1424 ContentViewCore* view = ContentViewCore::FromWebContents(web_contents); |
| 1424 if (!view) | 1425 if (!view) |
| 1425 return NULL; | 1426 return NULL; |
| 1426 | 1427 |
| 1427 return view->GetJavaObject().Release(); | 1428 return view->GetJavaObject().Release(); |
| 1428 } | 1429 } |
| 1429 | 1430 |
| 1430 bool RegisterContentViewCore(JNIEnv* env) { | 1431 bool RegisterContentViewCore(JNIEnv* env) { |
| 1431 return RegisterNativesImpl(env); | 1432 return RegisterNativesImpl(env); |
| 1432 } | 1433 } |
| 1433 | 1434 |
| 1434 } // namespace content | 1435 } // namespace content |
| OLD | NEW |