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

Unified Diff: components/view_manager/native_viewport/platform_viewport_common.cc

Issue 1180573004: android: Introduce a ui::PlatformWindow implementation for android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix-win-gn Created 5 years, 6 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
Index: components/view_manager/native_viewport/platform_viewport_common.cc
diff --git a/components/view_manager/native_viewport/platform_viewport_x11.cc b/components/view_manager/native_viewport/platform_viewport_common.cc
similarity index 88%
rename from components/view_manager/native_viewport/platform_viewport_x11.cc
rename to components/view_manager/native_viewport/platform_viewport_common.cc
index c661fb5c09edd68517aabb711d8fca8b8efccf2c..bf20626d3272912a840c7df16f084418e7142670 100644
--- a/components/view_manager/native_viewport/platform_viewport_x11.cc
+++ b/components/view_manager/native_viewport/platform_viewport_common.cc
@@ -17,7 +17,14 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/platform_window/platform_window.h"
#include "ui/platform_window/platform_window_delegate.h"
+
+#if defined(OS_WIN)
+#include "ui/platform_window/win/win_window.h"
+#elif defined(USE_X11)
#include "ui/platform_window/x11/x11_window.h"
+#elif defined(OS_ANDROID)
+#include "ui/platform_window/android/platform_window_android.h"
+#endif
namespace native_viewport {
namespace {
@@ -32,13 +39,13 @@ float ConvertUIWheelValueToMojoValue(int offset) {
}
} // namespace
-class PlatformViewportX11 : public PlatformViewport,
- public ui::PlatformWindowDelegate {
+class PlatformViewportCommon : public PlatformViewport,
+ public ui::PlatformWindowDelegate {
public:
- explicit PlatformViewportX11(Delegate* delegate) : delegate_(delegate) {
+ explicit PlatformViewportCommon(Delegate* delegate) : delegate_(delegate) {
}
- ~PlatformViewportX11() override {
+ ~PlatformViewportCommon() override {
// Destroy the platform-window while |this| is still alive.
platform_window_.reset();
}
@@ -53,7 +60,13 @@ class PlatformViewportX11 : public PlatformViewport,
metrics_->device_pixel_ratio = 1.f;
metrics_->size_in_pixels = mojo::Size::From(bounds.size());
+#if defined(OS_WIN)
+ platform_window_.reset(new ui::WinWindow(this, bounds));
+#elif defined(USE_X11)
platform_window_.reset(new ui::X11Window(this));
+#elif defined(OS_ANDROID)
+ platform_window_.reset(new ui::PlatformWindowAndroid(this));
+#endif
platform_window_->SetBounds(bounds);
}
@@ -108,6 +121,7 @@ class PlatformViewportX11 : public PlatformViewport,
break;
}
+#if defined(USE_X11)
// We want to emulate the WM_CHAR generation behaviour of Windows.
//
// On Linux, we've previously inserted characters by having
@@ -138,6 +152,7 @@ class PlatformViewportX11 : public PlatformViewport,
delegate_->OnEvent(mojo::Event::From(char_event));
}
+#endif
}
void OnCloseRequest() override { platform_window_->Close(); }
@@ -159,7 +174,7 @@ class PlatformViewportX11 : public PlatformViewport,
Delegate* delegate_;
mojo::ViewportMetricsPtr metrics_;
- DISALLOW_COPY_AND_ASSIGN(PlatformViewportX11);
+ DISALLOW_COPY_AND_ASSIGN(PlatformViewportCommon);
};
// static
@@ -167,7 +182,7 @@ scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate,
bool headless) {
if (headless)
return PlatformViewportHeadless::Create(delegate);
- return make_scoped_ptr(new PlatformViewportX11(delegate));
+ return make_scoped_ptr(new PlatformViewportCommon(delegate));
}
} // namespace native_viewport

Powered by Google App Engine
This is Rietveld 408576698