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