Index: content/browser/web_contents/web_contents_view_android.cc |
diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc |
index 0222bc629b44766fe282fe8df395257522a925a6..333db41b44a4e46e5c68538ac4d5a3c8e3ed97b8 100644 |
--- a/content/browser/web_contents/web_contents_view_android.cc |
+++ b/content/browser/web_contents/web_contents_view_android.cc |
@@ -28,10 +28,8 @@ using base::android::ScopedJavaLocalRef; |
namespace content { |
-// static |
-void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) { |
- const display::Display& display = |
- display::Screen::GetScreen()->GetPrimaryDisplay(); |
+namespace { |
+void DisplayToScreenInfo(const display::Display& display, ScreenInfo* results) { |
results->rect = display.bounds(); |
// TODO(husky): Remove any system controls from availableRect. |
results->available_rect = display.work_area(); |
@@ -44,6 +42,13 @@ void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) { |
results->depth_per_component = display.depth_per_component(); |
results->is_monochrome = display.is_monochrome(); |
} |
+} |
+ |
+// static |
+void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) { |
+ DisplayToScreenInfo(display::Screen::GetScreen()->GetPrimaryDisplay(), |
+ results); |
+} |
WebContentsView* CreateWebContentsView( |
WebContentsImpl* web_contents, |
@@ -104,8 +109,14 @@ gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const { |
} |
void WebContentsViewAndroid::GetScreenInfo(ScreenInfo* result) const { |
- // ScreenInfo isn't tied to the widget on Android. Always return the default. |
- WebContentsView::GetDefaultScreenInfo(result); |
+ // Since API 17 Android supports multiple displays with different properties. |
+ |
+ gfx::NativeView native_view = GetNativeView(); |
+ display::Display display = |
+ native_view |
+ ? display::Screen::GetScreen()->GetDisplayNearestWindow(native_view) |
+ : display::Screen::GetScreen()->GetPrimaryDisplay(); |
+ DisplayToScreenInfo(display, result); |
} |
void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const { |