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.
5 #ifndef XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_
6 #define XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
10 #include "ui/aura/window_observer.h"
11 #include "xwalk/runtime/browser/ui/screen_orientation.h"
12 #include "xwalk/runtime/browser/ui/native_app_window_views.h"
13 #include "xwalk/tizen/mobile/sensor/sensor_provider.h"
14 #include "xwalk/tizen/mobile/ui/tizen_system_indicator_widget.h"
15 #include "xwalk/tizen/mobile/ui/widget_container_view.h"
19 class SplashScreenTizen;
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 {
28 explicit NativeAppWindowTizen(const NativeAppWindow::CreateParams& params);
29 virtual ~NativeAppWindowTizen();
32 blink::WebScreenOrientationLockType orientations);
35 blink::WebScreenOrientationType FindNearestAllowedOrientation(
36 blink::WebScreenOrientationType orientation) const;
38 void SetDisplayRotation(gfx::Display);
40 // SensorProvider::Observer overrides:
41 void OnScreenOrientationChanged(
42 blink::WebScreenOrientationType orientation) override;
43 void OnSensorConnected() override;
45 // NativeAppWindowViews overrides:
46 void Initialize() override;
48 // WindowObserver overrides:
49 void OnWindowVisibilityChanging(
50 aura::Window* window, bool visible) override;
51 void OnWindowBoundsChanged(
53 const gfx::Rect& old_bounds,
54 const gfx::Rect& new_bounds) override;
55 void OnWindowDestroying(aura::Window* window) override;
57 // views::View overrides:
58 void ViewHierarchyChanged(
59 const ViewHierarchyChangedDetails& details) override;
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_;
72 gfx::Display display_;
73 blink::WebScreenOrientationLockType orientation_lock_;
74 scoped_ptr<SplashScreenTizen> splash_screen_;
76 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowTizen);
79 inline NativeAppWindowTizen* ToNativeAppWindowTizen(NativeAppWindow* window) {
80 return static_cast<NativeAppWindowTizen*>(window);
85 #endif // XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_