| 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 float dpi_scale, | 211 float dpi_scale, |
| 212 const JavaRef<jobject>& java_bridge_retained_object_set) | 212 const JavaRef<jobject>& java_bridge_retained_object_set) |
| 213 : WebContentsObserver(web_contents), | 213 : WebContentsObserver(web_contents), |
| 214 java_ref_(env, obj), | 214 java_ref_(env, obj), |
| 215 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 215 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 216 page_scale_(1), | 216 page_scale_(1), |
| 217 dpi_scale_(dpi_scale), | 217 dpi_scale_(dpi_scale), |
| 218 device_orientation_(0), | 218 device_orientation_(0), |
| 219 accessibility_enabled_(false) { | 219 accessibility_enabled_(false) { |
| 220 GetViewAndroid()->SetLayer(cc::Layer::Create()); | 220 GetViewAndroid()->SetLayer(cc::Layer::Create()); |
| 221 gfx::Size physical_size( | |
| 222 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), | |
| 223 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); | |
| 224 GetViewAndroid()->GetLayer()->SetBounds(physical_size); | |
| 225 | 221 |
| 226 // Currently, the only use case we have for overriding a user agent involves | 222 // Currently, the only use case we have for overriding a user agent involves |
| 227 // spoofing a desktop Linux user agent for "Request desktop site". | 223 // spoofing a desktop Linux user agent for "Request desktop site". |
| 228 // Automatically set it for all WebContents so that it is available when a | 224 // Automatically set it for all WebContents so that it is available when a |
| 229 // NavigationEntry requires the user agent to be overridden. | 225 // NavigationEntry requires the user agent to be overridden. |
| 230 const char kLinuxInfoStr[] = "X11; Linux x86_64"; | 226 const char kLinuxInfoStr[] = "X11; Linux x86_64"; |
| 231 std::string product = content::GetContentClient()->GetProduct(); | 227 std::string product = content::GetContentClient()->GetProduct(); |
| 232 std::string spoofed_ua = | 228 std::string spoofed_ua = |
| 233 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); | 229 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); |
| 234 web_contents->SetUserAgentOverride(spoofed_ua); | 230 web_contents->SetUserAgentOverride(spoofed_ua); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 return size_dip; | 711 return size_dip; |
| 716 } | 712 } |
| 717 | 713 |
| 718 gfx::Size ContentViewCoreImpl::GetViewSize() const { | 714 gfx::Size ContentViewCoreImpl::GetViewSize() const { |
| 719 gfx::Size size = GetViewportSizeDip(); | 715 gfx::Size size = GetViewportSizeDip(); |
| 720 if (DoBrowserControlsShrinkBlinkSize()) | 716 if (DoBrowserControlsShrinkBlinkSize()) |
| 721 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip()); | 717 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip()); |
| 722 return size; | 718 return size; |
| 723 } | 719 } |
| 724 | 720 |
| 725 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const { | |
| 726 JNIEnv* env = AttachCurrentThread(); | |
| 727 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | |
| 728 if (j_obj.is_null()) | |
| 729 return gfx::Size(); | |
| 730 return gfx::Size( | |
| 731 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj), | |
| 732 Java_ContentViewCore_getPhysicalBackingHeightPix(env, j_obj)); | |
| 733 } | |
| 734 | |
| 735 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const { | 721 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const { |
| 736 JNIEnv* env = AttachCurrentThread(); | 722 JNIEnv* env = AttachCurrentThread(); |
| 737 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 723 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 738 if (j_obj.is_null()) | 724 if (j_obj.is_null()) |
| 739 return gfx::Size(); | 725 return gfx::Size(); |
| 740 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj), | 726 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj), |
| 741 Java_ContentViewCore_getViewportHeightPix(env, j_obj)); | 727 Java_ContentViewCore_getViewportHeightPix(env, j_obj)); |
| 742 } | 728 } |
| 743 | 729 |
| 744 int ContentViewCoreImpl::GetTopControlsHeightPix() const { | 730 int ContentViewCoreImpl::GetTopControlsHeightPix() const { |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 void ContentViewCoreImpl::RemoveJavascriptInterface( | 1229 void ContentViewCoreImpl::RemoveJavascriptInterface( |
| 1244 JNIEnv* env, | 1230 JNIEnv* env, |
| 1245 const JavaParamRef<jobject>& /* obj */, | 1231 const JavaParamRef<jobject>& /* obj */, |
| 1246 const JavaParamRef<jstring>& name) { | 1232 const JavaParamRef<jstring>& name) { |
| 1247 java_bridge_dispatcher_host_->RemoveNamedObject( | 1233 java_bridge_dispatcher_host_->RemoveNamedObject( |
| 1248 ConvertJavaStringToUTF8(env, name)); | 1234 ConvertJavaStringToUTF8(env, name)); |
| 1249 } | 1235 } |
| 1250 | 1236 |
| 1251 void ContentViewCoreImpl::WasResized(JNIEnv* env, | 1237 void ContentViewCoreImpl::WasResized(JNIEnv* env, |
| 1252 const JavaParamRef<jobject>& obj) { | 1238 const JavaParamRef<jobject>& obj) { |
| 1253 gfx::Size physical_size( | 1239 GetViewAndroid()->UpdateLayerBounds(); |
| 1254 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), | |
| 1255 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); | |
| 1256 GetViewAndroid()->GetLayer()->SetBounds(physical_size); | |
| 1257 | |
| 1258 SendScreenRectsAndResizeWidget(); | 1240 SendScreenRectsAndResizeWidget(); |
| 1259 } | 1241 } |
| 1260 | 1242 |
| 1261 long ContentViewCoreImpl::GetNativeImeAdapter( | 1243 long ContentViewCoreImpl::GetNativeImeAdapter( |
| 1262 JNIEnv* env, | 1244 JNIEnv* env, |
| 1263 const JavaParamRef<jobject>& obj) { | 1245 const JavaParamRef<jobject>& obj) { |
| 1264 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); | 1246 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); |
| 1265 if (!rwhva) | 1247 if (!rwhva) |
| 1266 return 0; | 1248 return 0; |
| 1267 return rwhva->GetNativeImeAdapter(); | 1249 return rwhva->GetNativeImeAdapter(); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 return ScopedJavaLocalRef<jobject>(); | 1581 return ScopedJavaLocalRef<jobject>(); |
| 1600 | 1582 |
| 1601 return view->GetJavaObject(); | 1583 return view->GetJavaObject(); |
| 1602 } | 1584 } |
| 1603 | 1585 |
| 1604 bool RegisterContentViewCore(JNIEnv* env) { | 1586 bool RegisterContentViewCore(JNIEnv* env) { |
| 1605 return RegisterNativesImpl(env); | 1587 return RegisterNativesImpl(env); |
| 1606 } | 1588 } |
| 1607 | 1589 |
| 1608 } // namespace content | 1590 } // namespace content |
| OLD | NEW |