- update source.
[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
43   // views::View overrides:
44   virtual void ViewHierarchyChanged(
45       const ViewHierarchyChangedDetails& details) OVERRIDE;
46
47   // SensorProvider::Observer overrides:
48   virtual void OnRotationChanged(gfx::Display::Rotation rotation) OVERRIDE;
49
50   void UpdateTopViewOverlay();
51
52   // MultiOrientationScreen overrides:
53   virtual Orientation GetCurrentOrientation() const OVERRIDE;
54   virtual void OnAllowedOrientationsChanged(
55       OrientationMask orientations) OVERRIDE;
56
57   gfx::Display::Rotation GetClosestAllowedRotation(
58       gfx::Display::Rotation) const;
59
60   // The system indicator is implemented as a widget because it needs to
61   // receive events and may also be an overlay on top of the rest of the
62   // content, regular views do not support this. We add it to the container,
63   // that is a view that doesn't draw anything, just passes the bounds
64   // information to the topview layout.
65   scoped_ptr<TizenSystemIndicatorWidget> indicator_widget_;
66   scoped_ptr<WidgetContainerView> indicator_container_;
67   gfx::Display display_;
68   OrientationMask allowed_orientations_;
69
70   DISALLOW_COPY_AND_ASSIGN(NativeAppWindowTizen);
71 };
72
73 }  // namespace xwalk
74
75 #endif  // XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_