Chromium Code Reviews| 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 89% |
| rename from components/view_manager/native_viewport/platform_viewport_x11.cc |
| rename to components/view_manager/native_viewport/platform_viewport_common.cc |
| index c661fb5c09edd68517aabb711d8fca8b8efccf2c..b7191fbdc00bd2a8f586cf0a553ae7e1d96e2210 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, |
| +class PlatformViewportCommon : public PlatformViewport, |
| public ui::PlatformWindowDelegate { |
|
Ben Goodger (Google)
2015/06/11 17:37:09
nit: indent
sadrul
2015/06/11 21:09:54
Done.
|
| 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)); |
| +#elif defined(USE_X11) |
| platform_window_.reset(new ui::X11Window(this)); |
| +#elif defined(OS_ANDROID) |
| + platform_window_.reset(new ui::PlatformWindowAndroid(this)); |
| +#endif |
|
sadrul
2015/06/11 16:05:36
It's a bit ugly, but since NativeViewport will be
|
| 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 |