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 "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 #include "content/browser/screen_orientation/screen_orientation_provider.h"
18 // Tizen uses the Views native window but adds its own features like orientation
19 // handling and integration with system indicator bar.
20 class NativeAppWindowTizen
21 : public aura::WindowObserver,
22 public NativeAppWindowViews,
23 public SensorProvider::Observer,
24 public content::ScreenOrientationProvider {
26 explicit NativeAppWindowTizen(const NativeAppWindow::CreateParams& params);
27 virtual ~NativeAppWindowTizen();
30 blink::WebScreenOrientationType FindNearestAllowedOrientation(
31 blink::WebScreenOrientationType orientation) const;
33 void SetDisplayRotation(gfx::Display);
35 // SensorProvider::Observer overrides:
36 virtual void OnScreenOrientationChanged(
37 blink::WebScreenOrientationType orientation) OVERRIDE;
39 // content::ScreenOrientationProvider overrides:
40 virtual void LockOrientation(
41 blink::WebScreenOrientationLockType orientations) OVERRIDE;
42 virtual void UnlockOrientation() OVERRIDE;
44 // NativeAppWindowViews overrides:
45 virtual void Initialize() OVERRIDE;
47 // WindowObserver overrides:
48 virtual void OnWindowVisibilityChanging(
49 aura::Window* window, bool visible) OVERRIDE;
50 virtual void OnWindowBoundsChanged(
52 const gfx::Rect& old_bounds,
53 const gfx::Rect& new_bounds) OVERRIDE;
54 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
56 // views::View overrides:
57 virtual void ViewHierarchyChanged(
58 const ViewHierarchyChangedDetails& details) OVERRIDE;
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_;
71 gfx::Display display_;
72 blink::WebScreenOrientationLockType orientation_lock_;
74 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowTizen);
79 #endif // XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_