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

Unified 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, 2 months 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 | ui/android/BUILD.gn » ('j') | ui/android/display_android.cc » ('J')
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 0222bc629b44766fe282fe8df395257522a925a6..986cac213a0fc5e75a1aaefacc26a434cffcef68 100644
--- a/content/browser/web_contents/web_contents_view_android.cc
+++ b/content/browser/web_contents/web_contents_view_android.cc
@@ -16,6 +16,7 @@
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/drop_data.h"
+#include "ui/android/window_android.h"
#include "ui/display/screen.h"
#include "ui/gfx/android/device_display_info.h"
#include "ui/gfx/android/java_bitmap.h"
@@ -28,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();
@@ -44,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);
+}
WebContentsView* CreateWebContentsView(
WebContentsImpl* web_contents,
@@ -104,8 +110,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.
+ 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
+ content_view_core_ ? content_view_core_->GetWindowAndroid() : nullptr;
+
+ if (window)
+ DisplayToScreenInfo(window->GetDisplay(), result);
+ else
+ WebContentsView::GetDefaultScreenInfo(result);
}
void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const {
« 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