Upstream version 6.34.113.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / ui / native_app_window_tizen.h
1 // Copyright (c) 2013 Intel Corporation. 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 XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_
6 #define XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_
7
8 #include "xwalk/runtime/browser/ui/screen_orientation.h"
9 #include "xwalk/runtime/browser/ui/native_app_window_views.h"
10 #include "xwalk/tizen/mobile/sensor/sensor_provider.h"
11 #include "xwalk/tizen/mobile/ui/tizen_system_indicator_widget.h"
12 #include "xwalk/tizen/mobile/ui/widget_container_view.h"
13 #include "ui/aura/window_observer.h"
14
15 namespace xwalk {
16
17 // Tizen uses the Views native window but adds its own features like orientation
18 // handling and integration with system indicator bar.
19 class NativeAppWindowTizen
20     : public aura::WindowObserver,
21       public NativeAppWindowViews,
22       public SensorProvider::Observer,
23       public MultiOrientationScreen {
24  public:
25   explicit NativeAppWindowTizen(const NativeAppWindow::CreateParams& params);
26   virtual ~NativeAppWindowTizen();
27
28
29  private:
30   gfx::Transform GetRotationTransform() const;
31   void ApplyDisplayRotation();
32
33   // NativeAppWindowViews overrides:
34   virtual void Initialize() OVERRIDE;
35
36   // WindowObserver overrides:
37   virtual void OnWindowVisibilityChanging(aura::Window* window,
38                                           bool visible) OVERRIDE;
39   virtual void OnWindowBoundsChanged(aura::Window* window,
40                                      const gfx::Rect& old_bounds,
41                                      const gfx::Rect& new_bounds) OVERRIDE;
42   virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
43
44   // views::View overrides:
45   virtual void ViewHierarchyChanged(
46       const ViewHierarchyChangedDetails& details) OVERRIDE;
47
48   // SensorProvider::Observer overrides:
49   virtual void OnRotationChanged(gfx::Display::Rotation rotation) OVERRIDE;
50
51   void UpdateTopViewOverlay();
52
53   // MultiOrientationScreen overrides:
54   virtual Orientation GetCurrentOrientation() const OVERRIDE;
55   virtual void OnAllowedOrientationsChanged(
56       OrientationMask orientations) OVERRIDE;
57
58   gfx::Display::Rotation GetClosestAllowedRotation(
59       gfx::Display::Rotation) const;
60
61 #if defined(OS_TIZEN_MOBILE)
62   // The system indicator is implemented as a widget because it needs to
63   // receive events and may also be an overlay on top of the rest of the
64   // content, regular views do not support this. We add it to the container,
65   // that is a view that doesn't draw anything, just passes the bounds
66   // information to the topview layout.
67   // The |indicator_widget_| is owned by the WidgetContainerView.
68   TizenSystemIndicatorWidget* indicator_widget_;
69   scoped_ptr<WidgetContainerView> indicator_container_;
70 #endif
71
72   gfx::Display display_;
73   OrientationMask allowed_orientations_;
74
75   DISALLOW_COPY_AND_ASSIGN(NativeAppWindowTizen);
76 };
77
78 }  // namespace xwalk
79
80 #endif  // XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_