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

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

Issue 2133873004: content: Move Surfaces related code out of RWHVA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missed overscroll change Created 4 years, 4 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 web_contents_(static_cast<WebContentsImpl*>(web_contents)), 216 web_contents_(static_cast<WebContentsImpl*>(web_contents)),
217 page_scale_(1), 217 page_scale_(1),
218 dpi_scale_(ui::GetScaleFactorForNativeView(&view_)), 218 dpi_scale_(ui::GetScaleFactorForNativeView(&view_)),
219 device_orientation_(0), 219 device_orientation_(0),
220 accessibility_enabled_(false) { 220 accessibility_enabled_(false) {
221 CHECK(web_contents) << 221 CHECK(web_contents) <<
222 "A ContentViewCoreImpl should be created with a valid WebContents."; 222 "A ContentViewCoreImpl should be created with a valid WebContents.";
223 DCHECK(window_android); 223 DCHECK(window_android);
224 DCHECK(!view_android_delegate.is_null()); 224 DCHECK(!view_android_delegate.is_null());
225 window_android->AddChild(&view_); 225 window_android->AddChild(&view_);
226 view_.SetLayer(cc::SolidColorLayer::Create()); 226 view_.SetLayer(cc::Layer::Create());
227 view_.GetLayer()->SetBackgroundColor(GetBackgroundColor(env, obj));
228 gfx::Size physical_size( 227 gfx::Size physical_size(
229 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), 228 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
230 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); 229 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
231 view_.GetLayer()->SetBounds(physical_size); 230 view_.GetLayer()->SetBounds(physical_size);
232 view_.GetLayer()->SetIsDrawable(true);
233 231
234 // Currently, the only use case we have for overriding a user agent involves 232 // Currently, the only use case we have for overriding a user agent involves
235 // spoofing a desktop Linux user agent for "Request desktop site". 233 // spoofing a desktop Linux user agent for "Request desktop site".
236 // Automatically set it for all WebContents so that it is available when a 234 // Automatically set it for all WebContents so that it is available when a
237 // NavigationEntry requires the user agent to be overridden. 235 // NavigationEntry requires the user agent to be overridden.
238 const char kLinuxInfoStr[] = "X11; Linux x86_64"; 236 const char kLinuxInfoStr[] = "X11; Linux x86_64";
239 std::string product = content::GetContentClient()->GetProduct(); 237 std::string product = content::GetContentClient()->GetProduct();
240 std::string spoofed_ua = 238 std::string spoofed_ua =
241 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); 239 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product);
242 web_contents->SetUserAgentOverride(spoofed_ua); 240 web_contents->SetUserAgentOverride(spoofed_ua);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 JNIEnv* env = AttachCurrentThread(); 469 JNIEnv* env = AttachCurrentThread();
472 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 470 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
473 if (obj.is_null()) 471 if (obj.is_null())
474 return; 472 return;
475 ScopedJavaLocalRef<jstring> jtitle = 473 ScopedJavaLocalRef<jstring> jtitle =
476 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title)); 474 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title));
477 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj()); 475 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj());
478 } 476 }
479 477
480 void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) { 478 void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) {
481 view_.GetLayer()->SetBackgroundColor(color);
482
483 JNIEnv* env = AttachCurrentThread(); 479 JNIEnv* env = AttachCurrentThread();
484 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 480 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
485 if (obj.is_null()) 481 if (obj.is_null())
486 return; 482 return;
487 Java_ContentViewCore_onBackgroundColorChanged(env, obj.obj(), color); 483 Java_ContentViewCore_onBackgroundColorChanged(env, obj.obj(), color);
488 } 484 }
489 485
490 void ContentViewCoreImpl::ShowSelectPopupMenu( 486 void ContentViewCoreImpl::ShowSelectPopupMenu(
491 RenderFrameHost* frame, 487 RenderFrameHost* frame,
492 const gfx::Rect& bounds, 488 const gfx::Rect& bounds,
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 821 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
826 if (j_obj.is_null()) 822 if (j_obj.is_null())
827 return false; 823 return false;
828 return Java_ContentViewCore_doTopControlsShrinkBlinkSize(env, j_obj.obj()); 824 return Java_ContentViewCore_doTopControlsShrinkBlinkSize(env, j_obj.obj());
829 } 825 }
830 826
831 float ContentViewCoreImpl::GetTopControlsHeightDip() const { 827 float ContentViewCoreImpl::GetTopControlsHeightDip() const {
832 return GetTopControlsHeightPix() / dpi_scale(); 828 return GetTopControlsHeightPix() / dpi_scale();
833 } 829 }
834 830
835 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) {
836 view_.GetLayer()->InsertChild(layer, 0);
837 view_.GetLayer()->SetIsDrawable(false);
838 }
839
840 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) {
841 layer->RemoveFromParent();
842
843 if (view_.GetLayer()->children().empty())
844 view_.GetLayer()->SetIsDrawable(true);
845 }
846
847 void ContentViewCoreImpl::MoveRangeSelectionExtent(const gfx::PointF& extent) { 831 void ContentViewCoreImpl::MoveRangeSelectionExtent(const gfx::PointF& extent) {
848 if (!web_contents_) 832 if (!web_contents_)
849 return; 833 return;
850 834
851 web_contents_->MoveRangeSelectionExtent(gfx::ToRoundedPoint(extent)); 835 web_contents_->MoveRangeSelectionExtent(gfx::ToRoundedPoint(extent));
852 } 836 }
853 837
854 void ContentViewCoreImpl::SelectBetweenCoordinates(const gfx::PointF& base, 838 void ContentViewCoreImpl::SelectBetweenCoordinates(const gfx::PointF& base,
855 const gfx::PointF& extent) { 839 const gfx::PointF& extent) {
856 if (!web_contents_) 840 if (!web_contents_)
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 return ScopedJavaLocalRef<jobject>(); 1622 return ScopedJavaLocalRef<jobject>();
1639 1623
1640 return view->GetJavaObject(); 1624 return view->GetJavaObject();
1641 } 1625 }
1642 1626
1643 bool RegisterContentViewCore(JNIEnv* env) { 1627 bool RegisterContentViewCore(JNIEnv* env) {
1644 return RegisterNativesImpl(env); 1628 return RegisterNativesImpl(env);
1645 } 1629 }
1646 1630
1647 } // namespace content 1631 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698