| 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 WebContentsView* CreateWebContentsView( | 54 WebContentsView* CreateWebContentsView( |
| 50 WebContentsImpl* web_contents, | 55 WebContentsImpl* web_contents, |
| 51 WebContentsViewDelegate* delegate, | 56 WebContentsViewDelegate* delegate, |
| 52 RenderViewHostDelegateView** render_view_host_delegate_view) { | 57 RenderViewHostDelegateView** render_view_host_delegate_view) { |
| 53 WebContentsViewAndroid* rv = new WebContentsViewAndroid( | 58 WebContentsViewAndroid* rv = new WebContentsViewAndroid( |
| 54 web_contents, delegate); | 59 web_contents, delegate); |
| 55 *render_view_host_delegate_view = rv; | 60 *render_view_host_delegate_view = rv; |
| 56 return rv; | 61 return rv; |
| 57 } | 62 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 105 |
| 101 // TODO(sievers): This should return null. | 106 // TODO(sievers): This should return null. |
| 102 return GetNativeView(); | 107 return GetNativeView(); |
| 103 } | 108 } |
| 104 | 109 |
| 105 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const { | 110 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const { |
| 106 return content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr; | 111 return content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr; |
| 107 } | 112 } |
| 108 | 113 |
| 109 void WebContentsViewAndroid::GetScreenInfo(ScreenInfo* result) const { | 114 void WebContentsViewAndroid::GetScreenInfo(ScreenInfo* result) const { |
| 110 // ScreenInfo isn't tied to the widget on Android. Always return the default. | 115 // Since API 17 Android supports multiple displays with different properties. |
| 111 WebContentsView::GetDefaultScreenInfo(result); | 116 |
| 117 gfx::NativeView native_view = GetNativeView(); |
| 118 display::Display display = |
| 119 native_view |
| 120 ? display::Screen::GetScreen()->GetDisplayNearestWindow(native_view) |
| 121 : display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 122 DisplayToScreenInfo(display, result); |
| 112 } | 123 } |
| 113 | 124 |
| 114 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const { | 125 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const { |
| 115 *out = content_view_core_ ? gfx::Rect(content_view_core_->GetViewSize()) | 126 *out = content_view_core_ ? gfx::Rect(content_view_core_->GetViewSize()) |
| 116 : gfx::Rect(); | 127 : gfx::Rect(); |
| 117 } | 128 } |
| 118 | 129 |
| 119 void WebContentsViewAndroid::SetPageTitle(const base::string16& title) { | 130 void WebContentsViewAndroid::SetPageTitle(const base::string16& title) { |
| 120 if (content_view_core_) | 131 if (content_view_core_) |
| 121 content_view_core_->SetTitle(title); | 132 content_view_core_->SetTitle(title); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 // This is called when we the renderer asks us to take focus back (i.e., it has | 334 // This is called when we the renderer asks us to take focus back (i.e., it has |
| 324 // iterated past the last focusable element on the page). | 335 // iterated past the last focusable element on the page). |
| 325 void WebContentsViewAndroid::TakeFocus(bool reverse) { | 336 void WebContentsViewAndroid::TakeFocus(bool reverse) { |
| 326 if (web_contents_->GetDelegate() && | 337 if (web_contents_->GetDelegate() && |
| 327 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) | 338 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) |
| 328 return; | 339 return; |
| 329 web_contents_->GetRenderWidgetHostView()->Focus(); | 340 web_contents_->GetRenderWidgetHostView()->Focus(); |
| 330 } | 341 } |
| 331 | 342 |
| 332 } // namespace content | 343 } // namespace content |
| OLD | NEW |