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 69% |
rename from mojo/services/native_viewport/native_viewport_ozone.cc |
rename to mojo/services/native_viewport/platform_viewport.cc |
index 31e02fe15969b7be5d1d270705956940644744a4..b7372332497ca9425d5dda886ce6d5f1665cd14b 100644 |
--- a/mojo/services/native_viewport/native_viewport_ozone.cc |
+++ b/mojo/services/native_viewport/platform_viewport.cc |
@@ -1,33 +1,30 @@ |
-// 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(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(); |
spang
2014/07/21 16:59:07
did this move somewhere?
sadrul
2014/07/21 17:39:54
I had this below after line 96, but it looks like
|
- } |
+ explicit PlatformViewport(NativeViewportDelegate* delegate) |
+ : delegate_(delegate) {} |
- virtual ~NativeViewportOzone() { |
+ virtual ~PlatformViewport() { |
// Destroy the platform-window while |this| is still alive. |
platform_window_.reset(); |
} |
@@ -35,8 +32,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(); } |
@@ -84,14 +84,17 @@ 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( |
shell::Context* context, |
NativeViewportDelegate* delegate) { |
- return scoped_ptr<NativeViewport>(new NativeViewportOzone(delegate)).Pass(); |
+#if defined(USE_X11) |
+ ui::X11WindowFactory::CreateIfNecessary(); |
+#endif |
+ return scoped_ptr<NativeViewport>(new PlatformViewport(delegate)).Pass(); |
} |
} // namespace services |