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

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: Update a map of Displays from Java 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/display_android.cc » ('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"
11 #include "content/browser/frame_host/interstitial_page_impl.h" 11 #include "content/browser/frame_host/interstitial_page_impl.h"
12 #include "content/browser/renderer_host/render_widget_host_view_android.h" 12 #include "content/browser/renderer_host/render_widget_host_view_android.h"
13 #include "content/browser/renderer_host/render_view_host_factory.h" 13 #include "content/browser/renderer_host/render_view_host_factory.h"
14 #include "content/browser/renderer_host/render_view_host_impl.h" 14 #include "content/browser/renderer_host/render_view_host_impl.h"
15 #include "content/browser/web_contents/web_contents_impl.h" 15 #include "content/browser/web_contents/web_contents_impl.h"
16 #include "content/public/browser/render_widget_host.h" 16 #include "content/public/browser/render_widget_host.h"
17 #include "content/public/browser/web_contents_delegate.h" 17 #include "content/public/browser/web_contents_delegate.h"
18 #include "content/public/common/drop_data.h" 18 #include "content/public/common/drop_data.h"
19 #include "ui/android/window_android.h"
19 #include "ui/display/screen.h" 20 #include "ui/display/screen.h"
20 #include "ui/gfx/android/device_display_info.h" 21 #include "ui/gfx/android/device_display_info.h"
21 #include "ui/gfx/android/java_bitmap.h" 22 #include "ui/gfx/android/java_bitmap.h"
22 #include "ui/gfx/image/image_skia.h" 23 #include "ui/gfx/image/image_skia.h"
23 24
24 using base::android::AttachCurrentThread; 25 using base::android::AttachCurrentThread;
25 using base::android::ConvertUTF16ToJavaString; 26 using base::android::ConvertUTF16ToJavaString;
26 using base::android::JavaRef; 27 using base::android::JavaRef;
27 using base::android::ScopedJavaLocalRef; 28 using base::android::ScopedJavaLocalRef;
28 29
29 namespace content { 30 namespace content {
30 31
31 // static 32 namespace {
32 void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) { 33 void DisplayToScreenInfo(const display::Display& display, ScreenInfo* results) {
33 const display::Display& display =
34 display::Screen::GetScreen()->GetPrimaryDisplay();
35 results->rect = display.bounds(); 34 results->rect = display.bounds();
36 // TODO(husky): Remove any system controls from availableRect. 35 // TODO(husky): Remove any system controls from availableRect.
37 results->available_rect = display.work_area(); 36 results->available_rect = display.work_area();
38 results->device_scale_factor = display.device_scale_factor(); 37 results->device_scale_factor = display.device_scale_factor();
39 results->orientation_angle = display.RotationAsDegree(); 38 results->orientation_angle = display.RotationAsDegree();
40 results->orientation_type = 39 results->orientation_type =
41 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 40 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
42 gfx::DeviceDisplayInfo info; 41 gfx::DeviceDisplayInfo info;
43 results->depth = display.color_depth(); 42 results->depth = display.color_depth();
44 results->depth_per_component = display.depth_per_component(); 43 results->depth_per_component = display.depth_per_component();
45 results->is_monochrome = display.is_monochrome(); 44 results->is_monochrome = display.is_monochrome();
46 } 45 }
46 }
47
48 // static
49 void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) {
50 DisplayToScreenInfo(display::Screen::GetScreen()->GetPrimaryDisplay(),
51 results);
52 }
47 53
48 WebContentsView* CreateWebContentsView( 54 WebContentsView* CreateWebContentsView(
49 WebContentsImpl* web_contents, 55 WebContentsImpl* web_contents,
50 WebContentsViewDelegate* delegate, 56 WebContentsViewDelegate* delegate,
51 RenderViewHostDelegateView** render_view_host_delegate_view) { 57 RenderViewHostDelegateView** render_view_host_delegate_view) {
52 WebContentsViewAndroid* rv = new WebContentsViewAndroid( 58 WebContentsViewAndroid* rv = new WebContentsViewAndroid(
53 web_contents, delegate); 59 web_contents, delegate);
54 *render_view_host_delegate_view = rv; 60 *render_view_host_delegate_view = rv;
55 return rv; 61 return rv;
56 } 62 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 103
98 // TODO(sievers): This should return null. 104 // TODO(sievers): This should return null.
99 return GetNativeView(); 105 return GetNativeView();
100 } 106 }
101 107
102 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const { 108 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const {
103 return content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr; 109 return content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr;
104 } 110 }
105 111
106 void WebContentsViewAndroid::GetScreenInfo(ScreenInfo* result) const { 112 void WebContentsViewAndroid::GetScreenInfo(ScreenInfo* result) const {
107 // ScreenInfo isn't tied to the widget on Android. Always return the default. 113 // Since API 17 Android supports multiple displays with different properties.
108 WebContentsView::GetDefaultScreenInfo(result); 114 ui::WindowAndroid* window =
mthiesse 2016/10/26 14:49:49 I think you could simplify this function to: Disp
Tima Vaisburd 2016/10/27 07:55:58 Good point! I rewrote this similarly, keeping prim
115 content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr;
116
117 if (window)
118 DisplayToScreenInfo(window->GetDisplay(), result);
119 else
120 WebContentsView::GetDefaultScreenInfo(result);
109 } 121 }
110 122
111 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const { 123 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const {
112 *out = content_view_core_ ? gfx::Rect(content_view_core_->GetViewSize()) 124 *out = content_view_core_ ? gfx::Rect(content_view_core_->GetViewSize())
113 : gfx::Rect(); 125 : gfx::Rect();
114 } 126 }
115 127
116 void WebContentsViewAndroid::SetPageTitle(const base::string16& title) { 128 void WebContentsViewAndroid::SetPageTitle(const base::string16& title) {
117 if (content_view_core_) 129 if (content_view_core_)
118 content_view_core_->SetTitle(title); 130 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 332 // 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). 333 // iterated past the last focusable element on the page).
322 void WebContentsViewAndroid::TakeFocus(bool reverse) { 334 void WebContentsViewAndroid::TakeFocus(bool reverse) {
323 if (web_contents_->GetDelegate() && 335 if (web_contents_->GetDelegate() &&
324 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) 336 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse))
325 return; 337 return;
326 web_contents_->GetRenderWidgetHostView()->Focus(); 338 web_contents_->GetRenderWidgetHostView()->Focus();
327 } 339 }
328 340
329 } // namespace content 341 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | ui/android/BUILD.gn » ('j') | ui/android/display_android.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698