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

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

Issue 2416403002: Reland of Android: support multiple displays on C++ side (Closed)
Patch Set: JNI generated and registered in ui/android; ensure primary DisplayAndroid by going to app context 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
« no previous file with comments | « no previous file | ui/android/BUILD.gn » ('j') | ui/android/DEPS » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 void DisplayToScreenInfo(const display::Display& display, ScreenInfo* results) {
33 const display::Display& display =
34 display::Screen::GetScreen()->GetPrimaryDisplay();
35 results->rect = display.bounds(); 33 results->rect = display.bounds();
36 // TODO(husky): Remove any system controls from availableRect. 34 // TODO(husky): Remove any system controls from availableRect.
37 results->available_rect = display.work_area(); 35 results->available_rect = display.work_area();
38 results->device_scale_factor = display.device_scale_factor(); 36 results->device_scale_factor = display.device_scale_factor();
39 results->orientation_angle = display.RotationAsDegree(); 37 results->orientation_angle = display.RotationAsDegree();
40 results->orientation_type = 38 results->orientation_type =
41 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 39 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
42 gfx::DeviceDisplayInfo info; 40 gfx::DeviceDisplayInfo info;
43 results->depth = display.color_depth(); 41 results->depth = display.color_depth();
44 results->depth_per_component = display.depth_per_component(); 42 results->depth_per_component = display.depth_per_component();
45 results->is_monochrome = display.is_monochrome(); 43 results->is_monochrome = display.is_monochrome();
46 } 44 }
45 }
46
47 // static
48 void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) {
49 DisplayToScreenInfo(display::Screen::GetScreen()->GetPrimaryDisplay(),
50 results);
51 }
47 52
48 WebContentsView* CreateWebContentsView( 53 WebContentsView* CreateWebContentsView(
49 WebContentsImpl* web_contents, 54 WebContentsImpl* web_contents,
50 WebContentsViewDelegate* delegate, 55 WebContentsViewDelegate* delegate,
51 RenderViewHostDelegateView** render_view_host_delegate_view) { 56 RenderViewHostDelegateView** render_view_host_delegate_view) {
52 WebContentsViewAndroid* rv = new WebContentsViewAndroid( 57 WebContentsViewAndroid* rv = new WebContentsViewAndroid(
53 web_contents, delegate); 58 web_contents, delegate);
54 *render_view_host_delegate_view = rv; 59 *render_view_host_delegate_view = rv;
55 return rv; 60 return rv;
56 } 61 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 102
98 // TODO(sievers): This should return null. 103 // TODO(sievers): This should return null.
99 return GetNativeView(); 104 return GetNativeView();
100 } 105 }
101 106
102 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const { 107 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const {
103 return content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr; 108 return content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr;
104 } 109 }
105 110
106 void WebContentsViewAndroid::GetScreenInfo(ScreenInfo* result) const { 111 void WebContentsViewAndroid::GetScreenInfo(ScreenInfo* result) const {
107 // ScreenInfo isn't tied to the widget on Android. Always return the default. 112 // Since API 17 Android supports multiple displays with different properties.
108 WebContentsView::GetDefaultScreenInfo(result); 113
114 gfx::NativeView native_view = GetNativeView();
115 display::Display display =
116 native_view
117 ? display::Screen::GetScreen()->GetDisplayNearestWindow(native_view)
118 : display::Screen::GetScreen()->GetPrimaryDisplay();
119 DisplayToScreenInfo(display, result);
109 } 120 }
110 121
111 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const { 122 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const {
112 *out = content_view_core_ ? gfx::Rect(content_view_core_->GetViewSize()) 123 *out = content_view_core_ ? gfx::Rect(content_view_core_->GetViewSize())
113 : gfx::Rect(); 124 : gfx::Rect();
114 } 125 }
115 126
116 void WebContentsViewAndroid::SetPageTitle(const base::string16& title) { 127 void WebContentsViewAndroid::SetPageTitle(const base::string16& title) {
117 if (content_view_core_) 128 if (content_view_core_)
118 content_view_core_->SetTitle(title); 129 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 331 // 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). 332 // iterated past the last focusable element on the page).
322 void WebContentsViewAndroid::TakeFocus(bool reverse) { 333 void WebContentsViewAndroid::TakeFocus(bool reverse) {
323 if (web_contents_->GetDelegate() && 334 if (web_contents_->GetDelegate() &&
324 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) 335 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse))
325 return; 336 return;
326 web_contents_->GetRenderWidgetHostView()->Focus(); 337 web_contents_->GetRenderWidgetHostView()->Focus();
327 } 338 }
328 339
329 } // namespace content 340 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | ui/android/BUILD.gn » ('j') | ui/android/DEPS » ('J')

Powered by Google App Engine
This is Rietveld 408576698