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( | 221 gfx::Size physical_size(GetViewAndroid()->GetPhysicalBackingSize()); |
boliu
2016/12/02 23:53:22
this and below seems redundant, retrieve the physi
Jinsuk Kim
2016/12/05 11:07:44
I don't think it is necessary to set the bounds he
| |
222 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), | |
223 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); | |
224 GetViewAndroid()->GetLayer()->SetBounds(physical_size); | 222 GetViewAndroid()->GetLayer()->SetBounds(physical_size); |
225 | 223 |
226 // Currently, the only use case we have for overriding a user agent involves | 224 // Currently, the only use case we have for overriding a user agent involves |
227 // spoofing a desktop Linux user agent for "Request desktop site". | 225 // spoofing a desktop Linux user agent for "Request desktop site". |
228 // Automatically set it for all WebContents so that it is available when a | 226 // Automatically set it for all WebContents so that it is available when a |
229 // NavigationEntry requires the user agent to be overridden. | 227 // NavigationEntry requires the user agent to be overridden. |
230 const char kLinuxInfoStr[] = "X11; Linux x86_64"; | 228 const char kLinuxInfoStr[] = "X11; Linux x86_64"; |
231 std::string product = content::GetContentClient()->GetProduct(); | 229 std::string product = content::GetContentClient()->GetProduct(); |
232 std::string spoofed_ua = | 230 std::string spoofed_ua = |
233 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); | 231 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
715 return size_dip; | 713 return size_dip; |
716 } | 714 } |
717 | 715 |
718 gfx::Size ContentViewCoreImpl::GetViewSize() const { | 716 gfx::Size ContentViewCoreImpl::GetViewSize() const { |
719 gfx::Size size = GetViewportSizeDip(); | 717 gfx::Size size = GetViewportSizeDip(); |
720 if (DoBrowserControlsShrinkBlinkSize()) | 718 if (DoBrowserControlsShrinkBlinkSize()) |
721 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip()); | 719 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip()); |
722 return size; | 720 return size; |
723 } | 721 } |
724 | 722 |
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 { | 723 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const { |
736 JNIEnv* env = AttachCurrentThread(); | 724 JNIEnv* env = AttachCurrentThread(); |
737 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 725 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
738 if (j_obj.is_null()) | 726 if (j_obj.is_null()) |
739 return gfx::Size(); | 727 return gfx::Size(); |
740 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj), | 728 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj), |
741 Java_ContentViewCore_getViewportHeightPix(env, j_obj)); | 729 Java_ContentViewCore_getViewportHeightPix(env, j_obj)); |
742 } | 730 } |
743 | 731 |
744 int ContentViewCoreImpl::GetTopControlsHeightPix() const { | 732 int ContentViewCoreImpl::GetTopControlsHeightPix() const { |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1243 void ContentViewCoreImpl::RemoveJavascriptInterface( | 1231 void ContentViewCoreImpl::RemoveJavascriptInterface( |
1244 JNIEnv* env, | 1232 JNIEnv* env, |
1245 const JavaParamRef<jobject>& /* obj */, | 1233 const JavaParamRef<jobject>& /* obj */, |
1246 const JavaParamRef<jstring>& name) { | 1234 const JavaParamRef<jstring>& name) { |
1247 java_bridge_dispatcher_host_->RemoveNamedObject( | 1235 java_bridge_dispatcher_host_->RemoveNamedObject( |
1248 ConvertJavaStringToUTF8(env, name)); | 1236 ConvertJavaStringToUTF8(env, name)); |
1249 } | 1237 } |
1250 | 1238 |
1251 void ContentViewCoreImpl::WasResized(JNIEnv* env, | 1239 void ContentViewCoreImpl::WasResized(JNIEnv* env, |
1252 const JavaParamRef<jobject>& obj) { | 1240 const JavaParamRef<jobject>& obj) { |
1253 gfx::Size physical_size( | 1241 gfx::Size physical_size(GetViewAndroid()->GetPhysicalBackingSize()); |
1254 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), | |
1255 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); | |
1256 GetViewAndroid()->GetLayer()->SetBounds(physical_size); | 1242 GetViewAndroid()->GetLayer()->SetBounds(physical_size); |
1257 | 1243 |
1258 SendScreenRectsAndResizeWidget(); | 1244 SendScreenRectsAndResizeWidget(); |
1259 } | 1245 } |
1260 | 1246 |
1261 long ContentViewCoreImpl::GetNativeImeAdapter( | 1247 long ContentViewCoreImpl::GetNativeImeAdapter( |
1262 JNIEnv* env, | 1248 JNIEnv* env, |
1263 const JavaParamRef<jobject>& obj) { | 1249 const JavaParamRef<jobject>& obj) { |
1264 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); | 1250 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); |
1265 if (!rwhva) | 1251 if (!rwhva) |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1599 return ScopedJavaLocalRef<jobject>(); | 1585 return ScopedJavaLocalRef<jobject>(); |
1600 | 1586 |
1601 return view->GetJavaObject(); | 1587 return view->GetJavaObject(); |
1602 } | 1588 } |
1603 | 1589 |
1604 bool RegisterContentViewCore(JNIEnv* env) { | 1590 bool RegisterContentViewCore(JNIEnv* env) { |
1605 return RegisterNativesImpl(env); | 1591 return RegisterNativesImpl(env); |
1606 } | 1592 } |
1607 | 1593 |
1608 } // namespace content | 1594 } // namespace content |
OLD | NEW |