Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ui / ozone / platform / dri / ozone_platform_dri.cc
index ce5587b..09dadb3 100644 (file)
@@ -4,33 +4,70 @@
 
 #include "ui/ozone/platform/dri/ozone_platform_dri.h"
 
+#include "ui/events/ozone/device/device_manager.h"
 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
+#include "ui/events/ozone/evdev/event_factory_evdev.h"
+#include "ui/ozone/ime/input_method_context_factory_ozone.h"
 #include "ui/ozone/ozone_platform.h"
+#include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h"
+#include "ui/ozone/platform/dri/dri_surface_factory.h"
+
+#if defined(OS_CHROMEOS)
+#include "ui/ozone/platform/dri/chromeos/native_display_delegate_dri.h"
+#endif
 
 namespace ui {
 
-OzonePlatformDri::OzonePlatformDri()
-    : cursor_factory_ozone_(&surface_factory_ozone_),
-      event_factory_ozone_(&cursor_factory_ozone_) {}
+namespace {
+
+// OzonePlatform for Linux DRI (Direct Rendering Infrastructure)
+//
+// This platform is Linux without any display server (no X, wayland, or
+// anything). This means chrome alone owns the display and input devices.
+class OzonePlatformDri : public OzonePlatform {
+ public:
+  OzonePlatformDri()
+      : device_manager_(CreateDeviceManager()),
+        cursor_factory_ozone_(&surface_factory_ozone_),
+        event_factory_ozone_(&cursor_factory_ozone_, device_manager_.get()) {}
+  virtual ~OzonePlatformDri() {}
 
-OzonePlatformDri::~OzonePlatformDri() {}
+  // OzonePlatform:
+  virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE {
+    return &surface_factory_ozone_;
+  }
+  virtual ui::EventFactoryOzone* GetEventFactoryOzone() OVERRIDE {
+    return &event_factory_ozone_;
+  }
+  virtual ui::InputMethodContextFactoryOzone*
+  GetInputMethodContextFactoryOzone() OVERRIDE {
+    return &input_method_context_factory_ozone_;
+  }
+  virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
+    return &cursor_factory_ozone_;
+  }
+#if defined(OS_CHROMEOS)
+  virtual scoped_ptr<ui::NativeDisplayDelegate> CreateNativeDisplayDelegate()
+      OVERRIDE {
+    return scoped_ptr<ui::NativeDisplayDelegate>(
+        new NativeDisplayDelegateDri(&surface_factory_ozone_,
+                                     device_manager_.get()));
+  }
+#endif
 
-gfx::SurfaceFactoryOzone* OzonePlatformDri::GetSurfaceFactoryOzone() {
-  return &surface_factory_ozone_;
-}
+ private:
+  scoped_ptr<DeviceManager> device_manager_;
 
-ui::EventFactoryOzone* OzonePlatformDri::GetEventFactoryOzone() {
-  return &event_factory_ozone_;
-}
+  ui::DriSurfaceFactory surface_factory_ozone_;
+  ui::CursorFactoryEvdevDri cursor_factory_ozone_;
+  ui::EventFactoryEvdev event_factory_ozone_;
+  // This creates a minimal input context.
+  ui::InputMethodContextFactoryOzone input_method_context_factory_ozone_;
 
-ui::InputMethodContextFactoryOzone*
-OzonePlatformDri::GetInputMethodContextFactoryOzone() {
-  return &input_method_context_factory_ozone_;
-}
+  DISALLOW_COPY_AND_ASSIGN(OzonePlatformDri);
+};
 
-ui::CursorFactoryOzone* OzonePlatformDri::GetCursorFactoryOzone() {
-  return &cursor_factory_ozone_;
-}
+}  // namespace
 
 OzonePlatform* CreateOzonePlatformDri() { return new OzonePlatformDri; }