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

Side by Side Diff: content/browser/web_contents/web_contents_view_android.cc

Issue 2428383006: Decouple VR Shell DPR and CSS size from Physical Displays. (Closed)
Patch Set: Fix load-bearing debugging code ;) Created 4 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/web_contents/web_contents_view_android.h" 5 #include "content/browser/web_contents/web_contents_view_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/browser/android/content_view_core_impl.h" 10 #include "content/browser/android/content_view_core_impl.h"
(...skipping 10 matching lines...) Expand all
21 #include "ui/gfx/android/java_bitmap.h" 21 #include "ui/gfx/android/java_bitmap.h"
22 #include "ui/gfx/image/image_skia.h" 22 #include "ui/gfx/image/image_skia.h"
23 23
24 using base::android::AttachCurrentThread; 24 using base::android::AttachCurrentThread;
25 using base::android::ConvertUTF16ToJavaString; 25 using base::android::ConvertUTF16ToJavaString;
26 using base::android::JavaRef; 26 using base::android::JavaRef;
27 using base::android::ScopedJavaLocalRef; 27 using base::android::ScopedJavaLocalRef;
28 28
29 namespace content { 29 namespace content {
30 30
31 // static 31 namespace {
32 void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) { 32
33 const display::Display& display = 33 void GetScreenInfoForWindow(ScreenInfo* results,
34 display::Screen::GetScreen()->GetPrimaryDisplay(); 34 ui::ViewAndroid* window) {
35 display::Screen* screen = display::Screen::GetScreen();
36 const display::Display display = window
37 ? screen->GetDisplayNearestWindow(window)
38 : screen->GetPrimaryDisplay();
35 results->rect = display.bounds(); 39 results->rect = display.bounds();
36 // TODO(husky): Remove any system controls from availableRect. 40 // TODO(husky): Remove any system controls from availableRect.
37 results->available_rect = display.work_area(); 41 results->available_rect = display.work_area();
38 results->device_scale_factor = display.device_scale_factor(); 42 results->device_scale_factor = display.device_scale_factor();
39 results->orientation_angle = display.RotationAsDegree(); 43 results->orientation_angle = display.RotationAsDegree();
40 results->orientation_type = 44 results->orientation_type =
41 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 45 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
42 gfx::DeviceDisplayInfo info; 46 gfx::DeviceDisplayInfo info;
43 results->depth = display.color_depth(); 47 results->depth = display.color_depth();
44 results->depth_per_component = display.depth_per_component(); 48 results->depth_per_component = display.depth_per_component();
45 results->is_monochrome = display.is_monochrome(); 49 results->is_monochrome = display.is_monochrome();
46 } 50 }
47 51
52 } // namespace
53
54 // static
55 void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) {
56 GetScreenInfoForWindow(results, nullptr);
57 }
58
48 WebContentsView* CreateWebContentsView( 59 WebContentsView* CreateWebContentsView(
49 WebContentsImpl* web_contents, 60 WebContentsImpl* web_contents,
50 WebContentsViewDelegate* delegate, 61 WebContentsViewDelegate* delegate,
51 RenderViewHostDelegateView** render_view_host_delegate_view) { 62 RenderViewHostDelegateView** render_view_host_delegate_view) {
52 WebContentsViewAndroid* rv = new WebContentsViewAndroid( 63 WebContentsViewAndroid* rv = new WebContentsViewAndroid(
53 web_contents, delegate); 64 web_contents, delegate);
54 *render_view_host_delegate_view = rv; 65 *render_view_host_delegate_view = rv;
55 return rv; 66 return rv;
56 } 67 }
57 68
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 108
98 // TODO(sievers): This should return null. 109 // TODO(sievers): This should return null.
99 return GetNativeView(); 110 return GetNativeView();
100 } 111 }
101 112
102 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const { 113 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const {
103 return content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr; 114 return content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr;
104 } 115 }
105 116
106 void WebContentsViewAndroid::GetScreenInfo(ScreenInfo* result) const { 117 void WebContentsViewAndroid::GetScreenInfo(ScreenInfo* result) const {
107 // ScreenInfo isn't tied to the widget on Android. Always return the default. 118 GetScreenInfoForWindow(result, GetNativeView());
108 WebContentsView::GetDefaultScreenInfo(result);
109 } 119 }
110 120
111 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const { 121 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const {
112 *out = content_view_core_ ? gfx::Rect(content_view_core_->GetViewSize()) 122 *out = content_view_core_ ? gfx::Rect(content_view_core_->GetViewSize())
113 : gfx::Rect(); 123 : gfx::Rect();
114 } 124 }
115 125
116 void WebContentsViewAndroid::SetPageTitle(const base::string16& title) { 126 void WebContentsViewAndroid::SetPageTitle(const base::string16& title) {
117 if (content_view_core_) 127 if (content_view_core_)
118 content_view_core_->SetTitle(title); 128 content_view_core_->SetTitle(title);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // This is called when we the renderer asks us to take focus back (i.e., it has 330 // This is called when we the renderer asks us to take focus back (i.e., it has
321 // iterated past the last focusable element on the page). 331 // iterated past the last focusable element on the page).
322 void WebContentsViewAndroid::TakeFocus(bool reverse) { 332 void WebContentsViewAndroid::TakeFocus(bool reverse) {
323 if (web_contents_->GetDelegate() && 333 if (web_contents_->GetDelegate() &&
324 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) 334 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse))
325 return; 335 return;
326 web_contents_->GetRenderWidgetHostView()->Focus(); 336 web_contents_->GetRenderWidgetHostView()->Focus();
327 } 337 }
328 338
329 } // namespace content 339 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698