Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / mojo / examples / aura_demo / window_tree_host_mojo.h
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MOJO_EXAMPLES_AURA_DEMO_WINDOW_TREE_HOST_MOJO_H_
6 #define MOJO_EXAMPLES_AURA_DEMO_WINDOW_TREE_HOST_MOJO_H_
7
8 #include "base/bind.h"
9 #include "mojo/public/bindings/remote_ptr.h"
10 #include "mojom/native_viewport.h"
11 #include "ui/aura/window_tree_host.h"
12 #include "ui/events/event_source.h"
13 #include "ui/gfx/rect.h"
14
15 namespace ui {
16 class ContextFactory;
17 }
18
19 namespace mojo {
20 namespace examples {
21
22 class WindowTreeHostMojo : public aura::WindowTreeHost,
23                            public ui::EventSource,
24                            public NativeViewportClient {
25  public:
26   WindowTreeHostMojo(ScopedNativeViewportHandle viewport_handle,
27                      const gfx::Rect& bounds,
28                      const base::Callback<void()>& compositor_created_callback);
29   virtual ~WindowTreeHostMojo();
30
31   gfx::Rect bounds() const { return bounds_; }
32   ScopedMessagePipeHandle TakeGLES2PipeHandle() { return gles2_handle_.Pass(); }
33
34  private:
35   // WindowTreeHost:
36   virtual aura::RootWindow* GetRootWindow() OVERRIDE;
37   virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
38   virtual void Show() OVERRIDE;
39   virtual void Hide() OVERRIDE;
40   virtual void ToggleFullScreen() OVERRIDE;
41   virtual gfx::Rect GetBounds() const OVERRIDE;
42   virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
43   virtual gfx::Insets GetInsets() const OVERRIDE;
44   virtual void SetInsets(const gfx::Insets& insets) OVERRIDE;
45   virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
46   virtual void SetCapture() OVERRIDE;
47   virtual void ReleaseCapture() OVERRIDE;
48   virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
49   virtual bool ConfineCursorToRootWindow() OVERRIDE;
50   virtual void UnConfineCursor() OVERRIDE;
51   virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
52   virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
53   virtual void PrepareForShutdown() OVERRIDE;
54   virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE;
55   virtual void MoveCursorToNative(const gfx::Point& location) OVERRIDE;
56   virtual void OnCursorVisibilityChangedNative(bool show) OVERRIDE;
57
58   // ui::EventSource:
59   virtual ui::EventProcessor* GetEventProcessor() OVERRIDE;
60
61   // Overridden from NativeViewportClient:
62   virtual void OnCreated() MOJO_OVERRIDE;
63   virtual void OnDestroyed() OVERRIDE;
64   virtual void OnBoundsChanged(const Rect& bounds) OVERRIDE;
65   virtual void OnEvent(const Event& event) OVERRIDE;
66
67   static ui::ContextFactory* context_factory_;
68
69   ScopedMessagePipeHandle gles2_handle_;
70   RemotePtr<NativeViewport> native_viewport_;
71   base::Callback<void()> compositor_created_callback_;
72
73   gfx::Rect bounds_;
74
75   DISALLOW_COPY_AND_ASSIGN(WindowTreeHostMojo);
76 };
77
78 }  // namespace examples
79 }  // namespace mojo
80
81 #endif  // MOJO_EXAMPLES_AURA_DEMO_WINDOW_TREE_HOST_MOJO_H_