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

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

Issue 2136373002: Make WindowAndroid a ViewAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@view3
Patch Set: Created 4 years, 5 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 ContentViewCoreImpl::ContentViewCoreImpl( 212 ContentViewCoreImpl::ContentViewCoreImpl(
213 JNIEnv* env, 213 JNIEnv* env,
214 jobject obj, 214 jobject obj,
215 WebContents* web_contents, 215 WebContents* web_contents,
216 const base::android::JavaRef<jobject>& view_android_delegate, 216 const base::android::JavaRef<jobject>& view_android_delegate,
217 ui::WindowAndroid* window_android, 217 ui::WindowAndroid* window_android,
218 jobject java_bridge_retained_object_set) 218 jobject java_bridge_retained_object_set)
219 : WebContentsObserver(web_contents), 219 : WebContentsObserver(web_contents),
220 java_ref_(env, obj), 220 java_ref_(env, obj),
221 view_(view_android_delegate, window_android), 221 view_(view_android_delegate),
222 web_contents_(static_cast<WebContentsImpl*>(web_contents)), 222 web_contents_(static_cast<WebContentsImpl*>(web_contents)),
223 page_scale_(1), 223 page_scale_(1),
224 dpi_scale_(ui::GetScaleFactorForNativeView(&view_)), 224 dpi_scale_(ui::GetScaleFactorForNativeView(&view_)),
225 device_orientation_(0), 225 device_orientation_(0),
226 accessibility_enabled_(false) { 226 accessibility_enabled_(false) {
227 CHECK(web_contents) << 227 CHECK(web_contents) <<
228 "A ContentViewCoreImpl should be created with a valid WebContents."; 228 "A ContentViewCoreImpl should be created with a valid WebContents.";
229 DCHECK(window_android); 229 DCHECK(window_android);
230 DCHECK(!view_android_delegate.is_null()); 230 DCHECK(!view_android_delegate.is_null());
231 window_android->AddChild(&view_);
231 view_.SetLayer(cc::SolidColorLayer::Create()); 232 view_.SetLayer(cc::SolidColorLayer::Create());
232 view_.GetLayer()->SetBackgroundColor(GetBackgroundColor(env, obj)); 233 view_.GetLayer()->SetBackgroundColor(GetBackgroundColor(env, obj));
233 gfx::Size physical_size( 234 gfx::Size physical_size(
234 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), 235 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
235 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); 236 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
236 view_.GetLayer()->SetBounds(physical_size); 237 view_.GetLayer()->SetBounds(physical_size);
237 view_.GetLayer()->SetIsDrawable(true); 238 view_.GetLayer()->SetIsDrawable(true);
238 239
239 // Currently, the only use case we have for overriding a user agent involves 240 // Currently, the only use case we have for overriding a user agent involves
240 // spoofing a desktop Linux user agent for "Request desktop site". 241 // spoofing a desktop Linux user agent for "Request desktop site".
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 env, j_obj.obj(), reinterpret_cast<intptr_t>(this)); 279 env, j_obj.obj(), reinterpret_cast<intptr_t>(this));
279 } 280 }
280 } 281 }
281 282
282 void ContentViewCoreImpl::UpdateWindowAndroid( 283 void ContentViewCoreImpl::UpdateWindowAndroid(
283 JNIEnv* env, 284 JNIEnv* env,
284 const base::android::JavaParamRef<jobject>& obj, 285 const base::android::JavaParamRef<jobject>& obj,
285 jlong window_android) { 286 jlong window_android) {
286 if (window_android) { 287 if (window_android) {
287 DCHECK(!view_.GetWindowAndroid()); 288 DCHECK(!view_.GetWindowAndroid());
288 view_.SetWindowAndroid( 289 ui::WindowAndroid* window =
289 reinterpret_cast<ui::WindowAndroid*>(window_android)); 290 reinterpret_cast<ui::WindowAndroid*>(window_android);
291 window->AddChild(&view_);
290 FOR_EACH_OBSERVER(ContentViewCoreImplObserver, 292 FOR_EACH_OBSERVER(ContentViewCoreImplObserver,
291 observer_list_, 293 observer_list_,
292 OnAttachedToWindow()); 294 OnAttachedToWindow());
293 } else { 295 } else {
294 FOR_EACH_OBSERVER(ContentViewCoreImplObserver, 296 FOR_EACH_OBSERVER(ContentViewCoreImplObserver,
295 observer_list_, 297 observer_list_,
296 OnDetachedFromWindow()); 298 OnDetachedFromWindow());
297 view_.SetWindowAndroid(nullptr); 299 view_.RemoveFromParent();
298 } 300 }
299 } 301 }
300 302
301 base::android::ScopedJavaLocalRef<jobject> 303 base::android::ScopedJavaLocalRef<jobject>
302 ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env, 304 ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env,
303 const JavaParamRef<jobject>& obj) { 305 const JavaParamRef<jobject>& obj) {
304 return web_contents_->GetJavaWebContents(); 306 return web_contents_->GetJavaWebContents();
305 } 307 }
306 308
307 base::android::ScopedJavaLocalRef<jobject> 309 base::android::ScopedJavaLocalRef<jobject>
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 return; 863 return;
862 864
863 web_contents_->SelectRange(base_point, extent_point); 865 web_contents_->SelectRange(base_point, extent_point);
864 } 866 }
865 867
866 const base::android::JavaRef<jobject>& 868 const base::android::JavaRef<jobject>&
867 ContentViewCoreImpl::GetViewAndroidDelegate() const { 869 ContentViewCoreImpl::GetViewAndroidDelegate() const {
868 return view_.GetViewAndroidDelegate(); 870 return view_.GetViewAndroidDelegate();
869 } 871 }
870 872
871 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { 873 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() {
Yusuf 2016/07/13 19:54:36 why remove this?
no sievers 2016/07/13 23:32:12 Done. WindowAndroid::GetWindowAndroid() const over
872 return view_.GetWindowAndroid(); 874 return view_.GetWindowAndroid();
873 } 875 }
874 876
875 cc::Layer* ContentViewCoreImpl::GetLayer() const { 877 cc::Layer* ContentViewCoreImpl::GetLayer() const {
876 return view_.GetLayer(); 878 return view_.GetLayer();
877 } 879 }
878 880
879 ui::ViewAndroid* ContentViewCoreImpl::GetViewAndroid() { 881 ui::ViewAndroid* ContentViewCoreImpl::GetViewAndroid() {
880 return &view_; 882 return &view_;
881 } 883 }
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 return ScopedJavaLocalRef<jobject>(); 1656 return ScopedJavaLocalRef<jobject>();
1655 1657
1656 return view->GetJavaObject(); 1658 return view->GetJavaObject();
1657 } 1659 }
1658 1660
1659 bool RegisterContentViewCore(JNIEnv* env) { 1661 bool RegisterContentViewCore(JNIEnv* env) {
1660 return RegisterNativesImpl(env) && JNI_DragEvent::RegisterNativesImpl(env); 1662 return RegisterNativesImpl(env) && JNI_DragEvent::RegisterNativesImpl(env);
1661 } 1663 }
1662 1664
1663 } // namespace content 1665 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698