Add ICU message format support
[chromium-blink-merge.git] / ui / views / widget / native_widget_aura.h
blob2e1db2e77e9bb71f315d35540ecf84f2df564d55
1 // Copyright (c) 2012 The Chromium Authors. 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 UI_VIEWS_WIDGET_NATIVE_WIDGET_AURA_H_
6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_AURA_H_
8 #include "base/memory/scoped_vector.h"
9 #include "base/memory/weak_ptr.h"
10 #include "ui/aura/client/focus_change_observer.h"
11 #include "ui/aura/window_delegate.h"
12 #include "ui/aura/window_observer.h"
13 #include "ui/base/cursor/cursor.h"
14 #include "ui/events/event_constants.h"
15 #include "ui/views/views_export.h"
16 #include "ui/views/widget/native_widget_private.h"
17 #include "ui/wm/public/activation_change_observer.h"
18 #include "ui/wm/public/activation_delegate.h"
19 #include "ui/wm/public/drag_drop_delegate.h"
21 namespace aura {
22 class Window;
24 namespace gfx {
25 class FontList;
28 namespace views {
30 class DropHelper;
31 class TooltipManagerAura;
32 class WindowReorderer;
34 class VIEWS_EXPORT NativeWidgetAura
35 : public internal::NativeWidgetPrivate,
36 public aura::WindowDelegate,
37 public aura::WindowObserver,
38 public aura::client::ActivationDelegate,
39 public aura::client::ActivationChangeObserver,
40 public aura::client::FocusChangeObserver,
41 public aura::client::DragDropDelegate {
42 public:
43 explicit NativeWidgetAura(internal::NativeWidgetDelegate* delegate);
45 // Called internally by NativeWidgetAura and DesktopNativeWidgetAura to
46 // associate |native_widget| with |window|.
47 static void RegisterNativeWidgetForWindow(
48 internal::NativeWidgetPrivate* native_widget,
49 aura::Window* window);
51 // Overridden from internal::NativeWidgetPrivate:
52 void InitNativeWidget(const Widget::InitParams& params) override;
53 NonClientFrameView* CreateNonClientFrameView() override;
54 bool ShouldUseNativeFrame() const override;
55 bool ShouldWindowContentsBeTransparent() const override;
56 void FrameTypeChanged() override;
57 Widget* GetWidget() override;
58 const Widget* GetWidget() const override;
59 gfx::NativeView GetNativeView() const override;
60 gfx::NativeWindow GetNativeWindow() const override;
61 Widget* GetTopLevelWidget() override;
62 const ui::Compositor* GetCompositor() const override;
63 const ui::Layer* GetLayer() const override;
64 void ReorderNativeViews() override;
65 void ViewRemoved(View* view) override;
66 void SetNativeWindowProperty(const char* name, void* value) override;
67 void* GetNativeWindowProperty(const char* name) const override;
68 TooltipManager* GetTooltipManager() const override;
69 void SetCapture() override;
70 void ReleaseCapture() override;
71 bool HasCapture() const override;
72 ui::InputMethod* GetInputMethod() override;
73 void CenterWindow(const gfx::Size& size) override;
74 void GetWindowPlacement(gfx::Rect* bounds,
75 ui::WindowShowState* maximized) const override;
76 bool SetWindowTitle(const base::string16& title) override;
77 void SetWindowIcons(const gfx::ImageSkia& window_icon,
78 const gfx::ImageSkia& app_icon) override;
79 void InitModalType(ui::ModalType modal_type) override;
80 gfx::Rect GetWindowBoundsInScreen() const override;
81 gfx::Rect GetClientAreaBoundsInScreen() const override;
82 gfx::Rect GetRestoredBounds() const override;
83 void SetBounds(const gfx::Rect& bounds) override;
84 void SetSize(const gfx::Size& size) override;
85 void StackAbove(gfx::NativeView native_view) override;
86 void StackAtTop() override;
87 void StackBelow(gfx::NativeView native_view) override;
88 void SetShape(SkRegion* shape) override;
89 void Close() override;
90 void CloseNow() override;
91 void Show() override;
92 void Hide() override;
93 void ShowMaximizedWithBounds(const gfx::Rect& restored_bounds) override;
94 void ShowWithWindowState(ui::WindowShowState state) override;
95 bool IsVisible() const override;
96 void Activate() override;
97 void Deactivate() override;
98 bool IsActive() const override;
99 void SetAlwaysOnTop(bool always_on_top) override;
100 bool IsAlwaysOnTop() const override;
101 void SetVisibleOnAllWorkspaces(bool always_visible) override;
102 void Maximize() override;
103 void Minimize() override;
104 bool IsMaximized() const override;
105 bool IsMinimized() const override;
106 void Restore() override;
107 void SetFullscreen(bool fullscreen) override;
108 bool IsFullscreen() const override;
109 void SetOpacity(unsigned char opacity) override;
110 void SetUseDragFrame(bool use_drag_frame) override;
111 void FlashFrame(bool flash_frame) override;
112 void RunShellDrag(View* view,
113 const ui::OSExchangeData& data,
114 const gfx::Point& location,
115 int operation,
116 ui::DragDropTypes::DragEventSource source) override;
117 void SchedulePaintInRect(const gfx::Rect& rect) override;
118 void SetCursor(gfx::NativeCursor cursor) override;
119 bool IsMouseEventsEnabled() const override;
120 void ClearNativeFocus() override;
121 gfx::Rect GetWorkAreaBoundsInScreen() const override;
122 Widget::MoveLoopResult RunMoveLoop(
123 const gfx::Vector2d& drag_offset,
124 Widget::MoveLoopSource source,
125 Widget::MoveLoopEscapeBehavior escape_behavior) override;
126 void EndMoveLoop() override;
127 void SetVisibilityChangedAnimationsEnabled(bool value) override;
128 void SetVisibilityAnimationDuration(const base::TimeDelta& duration) override;
129 void SetVisibilityAnimationTransition(
130 Widget::VisibilityTransition transition) override;
131 ui::NativeTheme* GetNativeTheme() const override;
132 void OnRootViewLayout() override;
133 bool IsTranslucentWindowOpacitySupported() const override;
134 void OnSizeConstraintsChanged() override;
135 void RepostNativeEvent(gfx::NativeEvent native_event) override;
137 // Overridden from aura::WindowDelegate:
138 gfx::Size GetMinimumSize() const override;
139 gfx::Size GetMaximumSize() const override;
140 void OnBoundsChanged(const gfx::Rect& old_bounds,
141 const gfx::Rect& new_bounds) override;
142 gfx::NativeCursor GetCursor(const gfx::Point& point) override;
143 int GetNonClientComponent(const gfx::Point& point) const override;
144 bool ShouldDescendIntoChildForEventHandling(
145 aura::Window* child,
146 const gfx::Point& location) override;
147 bool CanFocus() override;
148 void OnCaptureLost() override;
149 void OnPaint(const ui::PaintContext& context) override;
150 void OnDeviceScaleFactorChanged(float device_scale_factor) override;
151 void OnWindowDestroying(aura::Window* window) override;
152 void OnWindowDestroyed(aura::Window* window) override;
153 void OnWindowTargetVisibilityChanged(bool visible) override;
154 bool HasHitTestMask() const override;
155 void GetHitTestMask(gfx::Path* mask) const override;
157 // Overridden from aura::WindowObserver:
158 void OnWindowPropertyChanged(aura::Window* window,
159 const void* key,
160 intptr_t old) override;
162 // Overridden from ui::EventHandler:
163 void OnKeyEvent(ui::KeyEvent* event) override;
164 void OnMouseEvent(ui::MouseEvent* event) override;
165 void OnScrollEvent(ui::ScrollEvent* event) override;
166 void OnGestureEvent(ui::GestureEvent* event) override;
168 // Overridden from aura::client::ActivationDelegate:
169 bool ShouldActivate() const override;
171 // Overridden from aura::client::ActivationChangeObserver:
172 void OnWindowActivated(
173 aura::client::ActivationChangeObserver::ActivationReason reason,
174 aura::Window* gained_active,
175 aura::Window* lost_active) override;
177 // Overridden from aura::client::FocusChangeObserver:
178 void OnWindowFocused(aura::Window* gained_focus,
179 aura::Window* lost_focus) override;
181 // Overridden from aura::client::DragDropDelegate:
182 void OnDragEntered(const ui::DropTargetEvent& event) override;
183 int OnDragUpdated(const ui::DropTargetEvent& event) override;
184 void OnDragExited() override;
185 int OnPerformDrop(const ui::DropTargetEvent& event) override;
187 protected:
188 ~NativeWidgetAura() override;
190 internal::NativeWidgetDelegate* delegate() { return delegate_; }
192 private:
193 class ActiveWindowObserver;
195 bool IsDocked() const;
196 void SetInitialFocus(ui::WindowShowState show_state);
198 internal::NativeWidgetDelegate* delegate_;
200 // WARNING: set to NULL when destroyed. As the Widget is not necessarily
201 // destroyed along with |window_| all usage of |window_| should first verify
202 // non-NULL.
203 aura::Window* window_;
205 // See class documentation for Widget in widget.h for a note about ownership.
206 Widget::InitParams::Ownership ownership_;
208 // Are we in the destructor?
209 bool destroying_;
211 gfx::NativeCursor cursor_;
213 // The saved window state for exiting full screen state.
214 ui::WindowShowState saved_window_state_;
216 scoped_ptr<TooltipManagerAura> tooltip_manager_;
218 // Reorders child windows of |window_| associated with a view based on the
219 // order of the associated views in the widget's view hierarchy.
220 scoped_ptr<WindowReorderer> window_reorderer_;
222 scoped_ptr<DropHelper> drop_helper_;
223 int last_drop_operation_;
225 // The following factory is used for calls to close the NativeWidgetAura
226 // instance.
227 base::WeakPtrFactory<NativeWidgetAura> close_widget_factory_;
229 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAura);
232 } // namespace views
234 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_AURA_H_