Index: mojo/services/native_viewport/platform_viewport.cc |
diff --git a/mojo/services/native_viewport/native_viewport_ozone.cc b/mojo/services/native_viewport/platform_viewport.cc |
similarity index 66% |
rename from mojo/services/native_viewport/native_viewport_ozone.cc |
rename to mojo/services/native_viewport/platform_viewport.cc |
index fa5648f5a5f28fc85b7b84a3f9ea7a78f4f50b55..1881ae0f6ea0884ca56c58cd7784b10d2fe81329 100644 |
--- a/mojo/services/native_viewport/native_viewport_ozone.cc |
+++ b/mojo/services/native_viewport/platform_viewport.cc |
@@ -1,33 +1,32 @@ |
-// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
#include "mojo/services/native_viewport/native_viewport.h" |
-#include "ui/events/event.h" |
-#include "ui/events/platform/platform_event_dispatcher.h" |
-#include "ui/events/platform/platform_event_source.h" |
-#include "ui/ozone/public/cursor_factory_ozone.h" |
-#include "ui/ozone/public/event_factory_ozone.h" |
-#include "ui/ozone/public/ozone_platform.h" |
-#include "ui/ozone/public/surface_factory_ozone.h" |
+#include "ui/gfx/rect.h" |
#include "ui/platform_window/platform_window.h" |
#include "ui/platform_window/platform_window_delegate.h" |
+#include "ui/platform_window/platform_window_factory.h" |
+ |
+#if defined(USE_X11) |
+#include "ui/platform_window/x11/x11_window_factory.h" |
+#elif defined(OS_WIN) |
+#include "ui/platform_window/win/win_window_factory.h" |
+#elif defined(USE_OZONE) |
+#include "ui/ozone/public/ozone_platform.h" |
+#endif |
namespace mojo { |
namespace services { |
-// TODO(spang): Deduplicate with NativeViewportX11.. but there's a hack |
-// in there that prevents this. |
-class NativeViewportOzone : public NativeViewport, |
- public ui::PlatformWindowDelegate { |
+class PlatformViewport : public NativeViewport, |
+ public ui::PlatformWindowDelegate { |
public: |
- explicit NativeViewportOzone(NativeViewportDelegate* delegate) |
- : delegate_(delegate) { |
- ui::OzonePlatform::InitializeForUI(); |
- } |
+ explicit PlatformViewport(NativeViewportDelegate* delegate) |
+ : delegate_(delegate) {} |
- virtual ~NativeViewportOzone() { |
+ virtual ~PlatformViewport() { |
// Destroy the platform-window while |this| is still alive. |
platform_window_.reset(); |
} |
@@ -35,8 +34,11 @@ class NativeViewportOzone : public NativeViewport, |
private: |
// Overridden from NativeViewport: |
virtual void Init(const gfx::Rect& bounds) OVERRIDE { |
+ CHECK(!platform_window_); |
+ |
platform_window_ = |
- ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); |
+ ui::PlatformWindowFactory::GetInstance()->CreatePlatformWindow(this, |
+ bounds); |
} |
virtual void Show() OVERRIDE { platform_window_->Show(); } |
@@ -86,13 +88,20 @@ class NativeViewportOzone : public NativeViewport, |
scoped_ptr<ui::PlatformWindow> platform_window_; |
NativeViewportDelegate* delegate_; |
- DISALLOW_COPY_AND_ASSIGN(NativeViewportOzone); |
+ DISALLOW_COPY_AND_ASSIGN(PlatformViewport); |
}; |
// static |
scoped_ptr<NativeViewport> NativeViewport::Create( |
NativeViewportDelegate* delegate) { |
- return scoped_ptr<NativeViewport>(new NativeViewportOzone(delegate)).Pass(); |
+#if defined(USE_X11) |
+ ui::X11WindowFactory::CreateIfNecessary(); |
+#elif defined(OS_WIN) |
+ ui::WinWindowFactory::CreateIfNecessary(); |
+#elif defined(USE_OZONE) |
+ ui::OzonePlatform::InitializeForUI(); |
+#endif |
+ return scoped_ptr<NativeViewport>(new PlatformViewport(delegate)).Pass(); |
} |
} // namespace services |