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

Unified Diff: content/browser/web_contents/web_contents_view_android.cc

Issue 2499173002: Android: Create ScreenInfo for the right display (Closed)
Patch Set: Rebased 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 49a6e0209a6b42928f94483a2107691225264880..7115f9359bc529cd69abd57211830b9f92ccf1d5 100644
--- a/content/browser/web_contents/web_contents_view_android.cc
+++ b/content/browser/web_contents/web_contents_view_android.cc
@@ -29,10 +29,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();
@@ -45,6 +43,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);
+}
// static
void SynchronousCompositor::SetClientForWebContents(
@@ -124,8 +129,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 {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698