Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 2626723003: Revert "Introduce ViewRoot forwarding input/view events to native" (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 WebContents* web_contents, 223 WebContents* web_contents,
224 float dpi_scale, 224 float dpi_scale,
225 const JavaRef<jobject>& java_bridge_retained_object_set) 225 const JavaRef<jobject>& java_bridge_retained_object_set)
226 : WebContentsObserver(web_contents), 226 : WebContentsObserver(web_contents),
227 java_ref_(env, obj), 227 java_ref_(env, obj),
228 web_contents_(static_cast<WebContentsImpl*>(web_contents)), 228 web_contents_(static_cast<WebContentsImpl*>(web_contents)),
229 page_scale_(1), 229 page_scale_(1),
230 dpi_scale_(dpi_scale), 230 dpi_scale_(dpi_scale),
231 device_orientation_(0), 231 device_orientation_(0),
232 accessibility_enabled_(false) { 232 accessibility_enabled_(false) {
233 GetViewAndroid()->SetLayer(cc::Layer::Create());
234 gfx::Size physical_size(
235 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
236 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
237 GetViewAndroid()->GetLayer()->SetBounds(physical_size);
238
233 // Currently, the only use case we have for overriding a user agent involves 239 // Currently, the only use case we have for overriding a user agent involves
234 // spoofing a desktop Linux user agent for "Request desktop site". 240 // spoofing a desktop Linux user agent for "Request desktop site".
235 // Automatically set it for all WebContents so that it is available when a 241 // Automatically set it for all WebContents so that it is available when a
236 // NavigationEntry requires the user agent to be overridden. 242 // NavigationEntry requires the user agent to be overridden.
237 const char kLinuxInfoStr[] = "X11; Linux x86_64"; 243 const char kLinuxInfoStr[] = "X11; Linux x86_64";
238 std::string product = content::GetContentClient()->GetProduct(); 244 std::string product = content::GetContentClient()->GetProduct();
239 std::string spoofed_ua = 245 std::string spoofed_ua =
240 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); 246 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product);
241 web_contents->SetUserAgentOverride(spoofed_ua); 247 web_contents->SetUserAgentOverride(spoofed_ua);
242 248
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 return size_dip; 725 return size_dip;
720 } 726 }
721 727
722 gfx::Size ContentViewCoreImpl::GetViewSize() const { 728 gfx::Size ContentViewCoreImpl::GetViewSize() const {
723 gfx::Size size = GetViewportSizeDip(); 729 gfx::Size size = GetViewportSizeDip();
724 if (DoBrowserControlsShrinkBlinkSize()) 730 if (DoBrowserControlsShrinkBlinkSize())
725 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip()); 731 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip());
726 return size; 732 return size;
727 } 733 }
728 734
735 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const {
736 JNIEnv* env = AttachCurrentThread();
737 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
738 if (j_obj.is_null())
739 return gfx::Size();
740 return gfx::Size(
741 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj),
742 Java_ContentViewCore_getPhysicalBackingHeightPix(env, j_obj));
743 }
744
729 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const { 745 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const {
730 JNIEnv* env = AttachCurrentThread(); 746 JNIEnv* env = AttachCurrentThread();
731 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 747 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
732 if (j_obj.is_null()) 748 if (j_obj.is_null())
733 return gfx::Size(); 749 return gfx::Size();
734 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj), 750 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj),
735 Java_ContentViewCore_getViewportHeightPix(env, j_obj)); 751 Java_ContentViewCore_getViewportHeightPix(env, j_obj));
736 } 752 }
737 753
738 int ContentViewCoreImpl::GetTopControlsHeightPix() const { 754 int ContentViewCoreImpl::GetTopControlsHeightPix() const {
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 void ContentViewCoreImpl::RemoveJavascriptInterface( 1258 void ContentViewCoreImpl::RemoveJavascriptInterface(
1243 JNIEnv* env, 1259 JNIEnv* env,
1244 const JavaParamRef<jobject>& /* obj */, 1260 const JavaParamRef<jobject>& /* obj */,
1245 const JavaParamRef<jstring>& name) { 1261 const JavaParamRef<jstring>& name) {
1246 java_bridge_dispatcher_host_->RemoveNamedObject( 1262 java_bridge_dispatcher_host_->RemoveNamedObject(
1247 ConvertJavaStringToUTF8(env, name)); 1263 ConvertJavaStringToUTF8(env, name));
1248 } 1264 }
1249 1265
1250 void ContentViewCoreImpl::WasResized(JNIEnv* env, 1266 void ContentViewCoreImpl::WasResized(JNIEnv* env,
1251 const JavaParamRef<jobject>& obj) { 1267 const JavaParamRef<jobject>& obj) {
1268 gfx::Size physical_size(
1269 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
1270 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
1271 GetViewAndroid()->GetLayer()->SetBounds(physical_size);
1272
1252 SendScreenRectsAndResizeWidget(); 1273 SendScreenRectsAndResizeWidget();
1253 } 1274 }
1254 1275
1255 long ContentViewCoreImpl::GetNativeImeAdapter( 1276 long ContentViewCoreImpl::GetNativeImeAdapter(
1256 JNIEnv* env, 1277 JNIEnv* env,
1257 const JavaParamRef<jobject>& obj) { 1278 const JavaParamRef<jobject>& obj) {
1258 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); 1279 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid();
1259 if (!rwhva) 1280 if (!rwhva)
1260 return 0; 1281 return 0;
1261 return rwhva->GetNativeImeAdapter(); 1282 return rwhva->GetNativeImeAdapter();
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 const JavaParamRef<jobject>& jview_android_delegate, 1552 const JavaParamRef<jobject>& jview_android_delegate,
1532 jlong jwindow_android, 1553 jlong jwindow_android,
1533 jfloat dipScale, 1554 jfloat dipScale,
1534 const JavaParamRef<jobject>& retained_objects_set) { 1555 const JavaParamRef<jobject>& retained_objects_set) {
1535 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( 1556 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
1536 WebContents::FromJavaWebContents(jweb_contents)); 1557 WebContents::FromJavaWebContents(jweb_contents));
1537 CHECK(web_contents) << 1558 CHECK(web_contents) <<
1538 "A ContentViewCoreImpl should be created with a valid WebContents."; 1559 "A ContentViewCoreImpl should be created with a valid WebContents.";
1539 ui::ViewAndroid* view_android = web_contents->GetView()->GetNativeView(); 1560 ui::ViewAndroid* view_android = web_contents->GetView()->GetNativeView();
1540 view_android->SetDelegate(jview_android_delegate); 1561 view_android->SetDelegate(jview_android_delegate);
1541 view_android->SetLayer(cc::Layer::Create());
1542 1562
1543 ui::WindowAndroid* window_android = 1563 ui::WindowAndroid* window_android =
1544 reinterpret_cast<ui::WindowAndroid*>(jwindow_android); 1564 reinterpret_cast<ui::WindowAndroid*>(jwindow_android);
1545 DCHECK(window_android); 1565 DCHECK(window_android);
1546 window_android->AddChild(view_android); 1566 window_android->AddChild(view_android);
1547 1567
1548 // TODO: pass dipScale. 1568 // TODO: pass dipScale.
1549 ContentViewCoreImpl* view = new ContentViewCoreImpl( 1569 ContentViewCoreImpl* view = new ContentViewCoreImpl(
1550 env, obj, web_contents, dipScale, retained_objects_set); 1570 env, obj, web_contents, dipScale, retained_objects_set);
1551 return reinterpret_cast<intptr_t>(view); 1571 return reinterpret_cast<intptr_t>(view);
(...skipping 12 matching lines...) Expand all
1564 return ScopedJavaLocalRef<jobject>(); 1584 return ScopedJavaLocalRef<jobject>();
1565 1585
1566 return view->GetJavaObject(); 1586 return view->GetJavaObject();
1567 } 1587 }
1568 1588
1569 bool RegisterContentViewCore(JNIEnv* env) { 1589 bool RegisterContentViewCore(JNIEnv* env) {
1570 return RegisterNativesImpl(env); 1590 return RegisterNativesImpl(env);
1571 } 1591 }
1572 1592
1573 } // namespace content 1593 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/renderer_host/render_widget_host_view_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698