OLD | NEW |
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 "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ui/gfx/android/java_bitmap.h" | 22 #include "ui/gfx/android/java_bitmap.h" |
23 #include "ui/gfx/image/image_skia.h" | 23 #include "ui/gfx/image/image_skia.h" |
24 | 24 |
25 using base::android::AttachCurrentThread; | 25 using base::android::AttachCurrentThread; |
26 using base::android::ConvertUTF16ToJavaString; | 26 using base::android::ConvertUTF16ToJavaString; |
27 using base::android::JavaRef; | 27 using base::android::JavaRef; |
28 using base::android::ScopedJavaLocalRef; | 28 using base::android::ScopedJavaLocalRef; |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 | 31 |
32 // static | 32 namespace { |
33 void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) { | 33 void DisplayToScreenInfo(const display::Display& display, ScreenInfo* results) { |
34 const display::Display& display = | |
35 display::Screen::GetScreen()->GetPrimaryDisplay(); | |
36 results->rect = display.bounds(); | 34 results->rect = display.bounds(); |
37 // TODO(husky): Remove any system controls from availableRect. | 35 // TODO(husky): Remove any system controls from availableRect. |
38 results->available_rect = display.work_area(); | 36 results->available_rect = display.work_area(); |
39 results->device_scale_factor = display.device_scale_factor(); | 37 results->device_scale_factor = display.device_scale_factor(); |
40 results->orientation_angle = display.RotationAsDegree(); | 38 results->orientation_angle = display.RotationAsDegree(); |
41 results->orientation_type = | 39 results->orientation_type = |
42 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 40 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
43 gfx::DeviceDisplayInfo info; | 41 gfx::DeviceDisplayInfo info; |
44 results->depth = display.color_depth(); | 42 results->depth = display.color_depth(); |
45 results->depth_per_component = display.depth_per_component(); | 43 results->depth_per_component = display.depth_per_component(); |
46 results->is_monochrome = display.is_monochrome(); | 44 results->is_monochrome = display.is_monochrome(); |
47 } | 45 } |
| 46 } |
| 47 |
| 48 // static |
| 49 void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) { |
| 50 DisplayToScreenInfo(display::Screen::GetScreen()->GetPrimaryDisplay(), |
| 51 results); |
| 52 } |
48 | 53 |
49 // static | 54 // static |
50 void SynchronousCompositor::SetClientForWebContents( | 55 void SynchronousCompositor::SetClientForWebContents( |
51 WebContents* contents, | 56 WebContents* contents, |
52 SynchronousCompositorClient* client) { | 57 SynchronousCompositorClient* client) { |
53 DCHECK(contents); | 58 DCHECK(contents); |
54 DCHECK(client); | 59 DCHECK(client); |
55 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( | 60 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( |
56 static_cast<WebContentsImpl*>(contents)->GetView()); | 61 static_cast<WebContentsImpl*>(contents)->GetView()); |
57 DCHECK(!wcva->synchronous_compositor_client()); | 62 DCHECK(!wcva->synchronous_compositor_client()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 122 |
118 // TODO(sievers): This should return null. | 123 // TODO(sievers): This should return null. |
119 return GetNativeView(); | 124 return GetNativeView(); |
120 } | 125 } |
121 | 126 |
122 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const { | 127 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const { |
123 return content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr; | 128 return content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr; |
124 } | 129 } |
125 | 130 |
126 void WebContentsViewAndroid::GetScreenInfo(ScreenInfo* result) const { | 131 void WebContentsViewAndroid::GetScreenInfo(ScreenInfo* result) const { |
127 // ScreenInfo isn't tied to the widget on Android. Always return the default. | 132 // Since API 17 Android supports multiple displays with different properties. |
128 WebContentsView::GetDefaultScreenInfo(result); | 133 |
| 134 gfx::NativeView native_view = GetNativeView(); |
| 135 display::Display display = |
| 136 native_view |
| 137 ? display::Screen::GetScreen()->GetDisplayNearestWindow(native_view) |
| 138 : display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 139 DisplayToScreenInfo(display, result); |
129 } | 140 } |
130 | 141 |
131 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const { | 142 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const { |
132 *out = content_view_core_ ? gfx::Rect(content_view_core_->GetViewSize()) | 143 *out = content_view_core_ ? gfx::Rect(content_view_core_->GetViewSize()) |
133 : gfx::Rect(); | 144 : gfx::Rect(); |
134 } | 145 } |
135 | 146 |
136 void WebContentsViewAndroid::SetPageTitle(const base::string16& title) { | 147 void WebContentsViewAndroid::SetPageTitle(const base::string16& title) { |
137 if (content_view_core_) | 148 if (content_view_core_) |
138 content_view_core_->SetTitle(title); | 149 content_view_core_->SetTitle(title); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // This is called when we the renderer asks us to take focus back (i.e., it has | 364 // This is called when we the renderer asks us to take focus back (i.e., it has |
354 // iterated past the last focusable element on the page). | 365 // iterated past the last focusable element on the page). |
355 void WebContentsViewAndroid::TakeFocus(bool reverse) { | 366 void WebContentsViewAndroid::TakeFocus(bool reverse) { |
356 if (web_contents_->GetDelegate() && | 367 if (web_contents_->GetDelegate() && |
357 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) | 368 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) |
358 return; | 369 return; |
359 web_contents_->GetRenderWidgetHostView()->Focus(); | 370 web_contents_->GetRenderWidgetHostView()->Focus(); |
360 } | 371 } |
361 | 372 |
362 } // namespace content | 373 } // namespace content |
OLD | NEW |