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