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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 float dpi_scale, | 215 float dpi_scale, |
216 const JavaRef<jobject>& java_bridge_retained_object_set) | 216 const JavaRef<jobject>& java_bridge_retained_object_set) |
217 : WebContentsObserver(web_contents), | 217 : WebContentsObserver(web_contents), |
218 java_ref_(env, obj), | 218 java_ref_(env, obj), |
219 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 219 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
220 page_scale_(1), | 220 page_scale_(1), |
221 dpi_scale_(dpi_scale), | 221 dpi_scale_(dpi_scale), |
222 device_orientation_(0), | 222 device_orientation_(0), |
223 accessibility_enabled_(false) { | 223 accessibility_enabled_(false) { |
224 GetViewAndroid()->SetLayer(cc::Layer::Create()); | 224 GetViewAndroid()->SetLayer(cc::Layer::Create()); |
225 gfx::Size physical_size( | |
226 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), | |
227 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); | |
228 GetViewAndroid()->GetLayer()->SetBounds(physical_size); | |
boliu
2017/05/10 17:09:53
does that mean you need to bring these calls back?
Khushal
2017/05/10 18:13:59
Nope, its not necessary. A layer's bounds need to
| |
229 | 225 |
230 // Currently, the only use case we have for overriding a user agent involves | 226 // Currently, the only use case we have for overriding a user agent involves |
231 // spoofing a desktop Linux user agent for "Request desktop site". | 227 // spoofing a desktop Linux user agent for "Request desktop site". |
232 // Automatically set it for all WebContents so that it is available when a | 228 // Automatically set it for all WebContents so that it is available when a |
233 // NavigationEntry requires the user agent to be overridden. | 229 // NavigationEntry requires the user agent to be overridden. |
234 const char kLinuxInfoStr[] = "X11; Linux x86_64"; | 230 const char kLinuxInfoStr[] = "X11; Linux x86_64"; |
235 std::string product = content::GetContentClient()->GetProduct(); | 231 std::string product = content::GetContentClient()->GetProduct(); |
236 std::string spoofed_ua = | 232 std::string spoofed_ua = |
237 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); | 233 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); |
238 web_contents->SetUserAgentOverride(spoofed_ua); | 234 web_contents->SetUserAgentOverride(spoofed_ua); |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
654 return Java_ContentViewCore_getContext(env, obj); | 650 return Java_ContentViewCore_getContext(env, obj); |
655 } | 651 } |
656 | 652 |
657 gfx::Size ContentViewCoreImpl::GetViewSize() const { | 653 gfx::Size ContentViewCoreImpl::GetViewSize() const { |
658 gfx::Size size = GetViewportSizeDip(); | 654 gfx::Size size = GetViewportSizeDip(); |
659 if (DoBrowserControlsShrinkBlinkSize()) | 655 if (DoBrowserControlsShrinkBlinkSize()) |
660 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip()); | 656 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip()); |
661 return size; | 657 return size; |
662 } | 658 } |
663 | 659 |
664 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const { | |
665 JNIEnv* env = AttachCurrentThread(); | |
666 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | |
667 if (j_obj.is_null()) | |
668 return gfx::Size(); | |
669 return gfx::Size( | |
670 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj), | |
671 Java_ContentViewCore_getPhysicalBackingHeightPix(env, j_obj)); | |
672 } | |
673 | |
674 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const { | 660 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const { |
675 JNIEnv* env = AttachCurrentThread(); | 661 JNIEnv* env = AttachCurrentThread(); |
676 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 662 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
677 if (j_obj.is_null()) | 663 if (j_obj.is_null()) |
678 return gfx::Size(); | 664 return gfx::Size(); |
679 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj), | 665 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj), |
680 Java_ContentViewCore_getViewportHeightPix(env, j_obj)); | 666 Java_ContentViewCore_getViewportHeightPix(env, j_obj)); |
681 } | 667 } |
682 | 668 |
683 int ContentViewCoreImpl::GetTopControlsHeightPix() const { | 669 int ContentViewCoreImpl::GetTopControlsHeightPix() const { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1028 void ContentViewCoreImpl::RemoveJavascriptInterface( | 1014 void ContentViewCoreImpl::RemoveJavascriptInterface( |
1029 JNIEnv* env, | 1015 JNIEnv* env, |
1030 const JavaParamRef<jobject>& /* obj */, | 1016 const JavaParamRef<jobject>& /* obj */, |
1031 const JavaParamRef<jstring>& name) { | 1017 const JavaParamRef<jstring>& name) { |
1032 java_bridge_dispatcher_host_->RemoveNamedObject( | 1018 java_bridge_dispatcher_host_->RemoveNamedObject( |
1033 ConvertJavaStringToUTF8(env, name)); | 1019 ConvertJavaStringToUTF8(env, name)); |
1034 } | 1020 } |
1035 | 1021 |
1036 void ContentViewCoreImpl::WasResized(JNIEnv* env, | 1022 void ContentViewCoreImpl::WasResized(JNIEnv* env, |
1037 const JavaParamRef<jobject>& obj) { | 1023 const JavaParamRef<jobject>& obj) { |
1038 gfx::Size physical_size( | |
1039 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), | |
1040 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); | |
1041 GetViewAndroid()->GetLayer()->SetBounds(physical_size); | |
1042 | |
1043 SendScreenRectsAndResizeWidget(); | 1024 SendScreenRectsAndResizeWidget(); |
1044 } | 1025 } |
1045 | 1026 |
1046 void ContentViewCoreImpl::SetAccessibilityEnabled( | 1027 void ContentViewCoreImpl::SetAccessibilityEnabled( |
1047 JNIEnv* env, | 1028 JNIEnv* env, |
1048 const JavaParamRef<jobject>& obj, | 1029 const JavaParamRef<jobject>& obj, |
1049 bool enabled) { | 1030 bool enabled) { |
1050 SetAccessibilityEnabledInternal(enabled); | 1031 SetAccessibilityEnabledInternal(enabled); |
1051 } | 1032 } |
1052 | 1033 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1280 return ScopedJavaLocalRef<jobject>(); | 1261 return ScopedJavaLocalRef<jobject>(); |
1281 | 1262 |
1282 return view->GetJavaObject(); | 1263 return view->GetJavaObject(); |
1283 } | 1264 } |
1284 | 1265 |
1285 bool RegisterContentViewCore(JNIEnv* env) { | 1266 bool RegisterContentViewCore(JNIEnv* env) { |
1286 return RegisterNativesImpl(env); | 1267 return RegisterNativesImpl(env); |
1287 } | 1268 } |
1288 | 1269 |
1289 } // namespace content | 1270 } // namespace content |
OLD | NEW |