OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_VIEWS_WIDGET_NATIVE_WIDGET_MAC_H_ | 5 #ifndef UI_VIEWS_WIDGET_NATIVE_WIDGET_MAC_H_ |
6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_MAC_H_ | 6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_MAC_H_ |
7 | 7 |
8 #include "ui/gfx/native_widget_types.h" | 8 #include "ui/gfx/native_widget_types.h" |
9 #include "ui/views/widget/native_widget_private.h" | 9 #include "ui/views/widget/native_widget_private.h" |
10 | 10 |
11 namespace views { | 11 namespace views { |
12 namespace test { | 12 namespace test { |
13 class MockNativeWidgetMac; | 13 class MockNativeWidgetMac; |
14 } | 14 } |
15 | 15 |
16 class BridgedNativeWidget; | 16 class BridgedNativeWidget; |
17 | 17 |
18 class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate { | 18 class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate { |
19 public: | 19 public: |
20 NativeWidgetMac(internal::NativeWidgetDelegate* delegate); | 20 NativeWidgetMac(internal::NativeWidgetDelegate* delegate); |
21 virtual ~NativeWidgetMac(); | 21 ~NativeWidgetMac() override; |
22 | 22 |
23 // Retrieves the bridge associated with the given NSWindow. Returns null if | 23 // Retrieves the bridge associated with the given NSWindow. Returns null if |
24 // the supplied handle has no associated Widget. | 24 // the supplied handle has no associated Widget. |
25 static BridgedNativeWidget* GetBridgeForNativeWindow( | 25 static BridgedNativeWidget* GetBridgeForNativeWindow( |
26 gfx::NativeWindow window); | 26 gfx::NativeWindow window); |
27 | 27 |
28 // Deletes |bridge_| and informs |delegate_| that the native widget is | 28 // Deletes |bridge_| and informs |delegate_| that the native widget is |
29 // destroyed. | 29 // destroyed. |
30 void OnWindowWillClose(); | 30 void OnWindowWillClose(); |
31 | 31 |
32 // internal::NativeWidgetPrivate: | 32 // internal::NativeWidgetPrivate: |
33 virtual void InitNativeWidget(const Widget::InitParams& params) override; | 33 void InitNativeWidget(const Widget::InitParams& params) override; |
34 virtual NonClientFrameView* CreateNonClientFrameView() override; | 34 NonClientFrameView* CreateNonClientFrameView() override; |
35 virtual bool ShouldUseNativeFrame() const override; | 35 bool ShouldUseNativeFrame() const override; |
36 virtual bool ShouldWindowContentsBeTransparent() const override; | 36 bool ShouldWindowContentsBeTransparent() const override; |
37 virtual void FrameTypeChanged() override; | 37 void FrameTypeChanged() override; |
38 virtual Widget* GetWidget() override; | 38 Widget* GetWidget() override; |
39 virtual const Widget* GetWidget() const override; | 39 const Widget* GetWidget() const override; |
40 virtual gfx::NativeView GetNativeView() const override; | 40 gfx::NativeView GetNativeView() const override; |
41 virtual gfx::NativeWindow GetNativeWindow() const override; | 41 gfx::NativeWindow GetNativeWindow() const override; |
42 virtual Widget* GetTopLevelWidget() override; | 42 Widget* GetTopLevelWidget() override; |
43 virtual const ui::Compositor* GetCompositor() const override; | 43 const ui::Compositor* GetCompositor() const override; |
44 virtual const ui::Layer* GetLayer() const override; | 44 const ui::Layer* GetLayer() const override; |
45 virtual void ReorderNativeViews() override; | 45 void ReorderNativeViews() override; |
46 virtual void ViewRemoved(View* view) override; | 46 void ViewRemoved(View* view) override; |
47 virtual void SetNativeWindowProperty(const char* name, void* value) override; | 47 void SetNativeWindowProperty(const char* name, void* value) override; |
48 virtual void* GetNativeWindowProperty(const char* name) const override; | 48 void* GetNativeWindowProperty(const char* name) const override; |
49 virtual TooltipManager* GetTooltipManager() const override; | 49 TooltipManager* GetTooltipManager() const override; |
50 virtual void SetCapture() override; | 50 void SetCapture() override; |
51 virtual void ReleaseCapture() override; | 51 void ReleaseCapture() override; |
52 virtual bool HasCapture() const override; | 52 bool HasCapture() const override; |
53 virtual InputMethod* CreateInputMethod() override; | 53 InputMethod* CreateInputMethod() override; |
54 virtual internal::InputMethodDelegate* GetInputMethodDelegate() override; | 54 internal::InputMethodDelegate* GetInputMethodDelegate() override; |
55 virtual ui::InputMethod* GetHostInputMethod() override; | 55 ui::InputMethod* GetHostInputMethod() override; |
56 virtual void CenterWindow(const gfx::Size& size) override; | 56 void CenterWindow(const gfx::Size& size) override; |
57 virtual void GetWindowPlacement( | 57 void GetWindowPlacement(gfx::Rect* bounds, |
58 gfx::Rect* bounds, | 58 ui::WindowShowState* maximized) const override; |
59 ui::WindowShowState* maximized) const override; | 59 bool SetWindowTitle(const base::string16& title) override; |
60 virtual bool SetWindowTitle(const base::string16& title) override; | 60 void SetWindowIcons(const gfx::ImageSkia& window_icon, |
61 virtual void SetWindowIcons(const gfx::ImageSkia& window_icon, | 61 const gfx::ImageSkia& app_icon) override; |
62 const gfx::ImageSkia& app_icon) override; | 62 void InitModalType(ui::ModalType modal_type) override; |
63 virtual void InitModalType(ui::ModalType modal_type) override; | 63 gfx::Rect GetWindowBoundsInScreen() const override; |
64 virtual gfx::Rect GetWindowBoundsInScreen() const override; | 64 gfx::Rect GetClientAreaBoundsInScreen() const override; |
65 virtual gfx::Rect GetClientAreaBoundsInScreen() const override; | 65 gfx::Rect GetRestoredBounds() const override; |
66 virtual gfx::Rect GetRestoredBounds() const override; | 66 void SetBounds(const gfx::Rect& bounds) override; |
67 virtual void SetBounds(const gfx::Rect& bounds) override; | 67 void SetSize(const gfx::Size& size) override; |
68 virtual void SetSize(const gfx::Size& size) override; | 68 void StackAbove(gfx::NativeView native_view) override; |
69 virtual void StackAbove(gfx::NativeView native_view) override; | 69 void StackAtTop() override; |
70 virtual void StackAtTop() override; | 70 void StackBelow(gfx::NativeView native_view) override; |
71 virtual void StackBelow(gfx::NativeView native_view) override; | 71 void SetShape(gfx::NativeRegion shape) override; |
72 virtual void SetShape(gfx::NativeRegion shape) override; | 72 void Close() override; |
73 virtual void Close() override; | 73 void CloseNow() override; |
74 virtual void CloseNow() override; | 74 void Show() override; |
75 virtual void Show() override; | 75 void Hide() override; |
76 virtual void Hide() override; | 76 void ShowMaximizedWithBounds(const gfx::Rect& restored_bounds) override; |
77 virtual void ShowMaximizedWithBounds( | 77 void ShowWithWindowState(ui::WindowShowState state) override; |
78 const gfx::Rect& restored_bounds) override; | 78 bool IsVisible() const override; |
79 virtual void ShowWithWindowState(ui::WindowShowState state) override; | 79 void Activate() override; |
80 virtual bool IsVisible() const override; | 80 void Deactivate() override; |
81 virtual void Activate() override; | 81 bool IsActive() const override; |
82 virtual void Deactivate() override; | 82 void SetAlwaysOnTop(bool always_on_top) override; |
83 virtual bool IsActive() const override; | 83 bool IsAlwaysOnTop() const override; |
84 virtual void SetAlwaysOnTop(bool always_on_top) override; | 84 void SetVisibleOnAllWorkspaces(bool always_visible) override; |
85 virtual bool IsAlwaysOnTop() const override; | 85 void Maximize() override; |
86 virtual void SetVisibleOnAllWorkspaces(bool always_visible) override; | 86 void Minimize() override; |
87 virtual void Maximize() override; | 87 bool IsMaximized() const override; |
88 virtual void Minimize() override; | 88 bool IsMinimized() const override; |
89 virtual bool IsMaximized() const override; | 89 void Restore() override; |
90 virtual bool IsMinimized() const override; | 90 void SetFullscreen(bool fullscreen) override; |
91 virtual void Restore() override; | 91 bool IsFullscreen() const override; |
92 virtual void SetFullscreen(bool fullscreen) override; | 92 void SetOpacity(unsigned char opacity) override; |
93 virtual bool IsFullscreen() const override; | 93 void SetUseDragFrame(bool use_drag_frame) override; |
94 virtual void SetOpacity(unsigned char opacity) override; | 94 void FlashFrame(bool flash_frame) override; |
95 virtual void SetUseDragFrame(bool use_drag_frame) override; | 95 void RunShellDrag(View* view, |
96 virtual void FlashFrame(bool flash_frame) override; | 96 const ui::OSExchangeData& data, |
97 virtual void RunShellDrag(View* view, | 97 const gfx::Point& location, |
98 const ui::OSExchangeData& data, | 98 int operation, |
99 const gfx::Point& location, | 99 ui::DragDropTypes::DragEventSource source) override; |
100 int operation, | 100 void SchedulePaintInRect(const gfx::Rect& rect) override; |
101 ui::DragDropTypes::DragEventSource source) override; | 101 void SetCursor(gfx::NativeCursor cursor) override; |
102 virtual void SchedulePaintInRect(const gfx::Rect& rect) override; | 102 bool IsMouseEventsEnabled() const override; |
103 virtual void SetCursor(gfx::NativeCursor cursor) override; | 103 void ClearNativeFocus() override; |
104 virtual bool IsMouseEventsEnabled() const override; | 104 gfx::Rect GetWorkAreaBoundsInScreen() const override; |
105 virtual void ClearNativeFocus() override; | 105 Widget::MoveLoopResult RunMoveLoop( |
106 virtual gfx::Rect GetWorkAreaBoundsInScreen() const override; | |
107 virtual Widget::MoveLoopResult RunMoveLoop( | |
108 const gfx::Vector2d& drag_offset, | 106 const gfx::Vector2d& drag_offset, |
109 Widget::MoveLoopSource source, | 107 Widget::MoveLoopSource source, |
110 Widget::MoveLoopEscapeBehavior escape_behavior) override; | 108 Widget::MoveLoopEscapeBehavior escape_behavior) override; |
111 virtual void EndMoveLoop() override; | 109 void EndMoveLoop() override; |
112 virtual void SetVisibilityChangedAnimationsEnabled(bool value) override; | 110 void SetVisibilityChangedAnimationsEnabled(bool value) override; |
113 virtual void SetVisibilityAnimationDuration( | 111 void SetVisibilityAnimationDuration(const base::TimeDelta& duration) override; |
114 const base::TimeDelta& duration) override; | 112 void SetVisibilityAnimationTransition( |
115 virtual void SetVisibilityAnimationTransition( | |
116 Widget::VisibilityTransition transition) override; | 113 Widget::VisibilityTransition transition) override; |
117 virtual ui::NativeTheme* GetNativeTheme() const override; | 114 ui::NativeTheme* GetNativeTheme() const override; |
118 virtual void OnRootViewLayout() override; | 115 void OnRootViewLayout() override; |
119 virtual bool IsTranslucentWindowOpacitySupported() const override; | 116 bool IsTranslucentWindowOpacitySupported() const override; |
120 virtual void OnSizeConstraintsChanged() override; | 117 void OnSizeConstraintsChanged() override; |
121 virtual void RepostNativeEvent(gfx::NativeEvent native_event) override; | 118 void RepostNativeEvent(gfx::NativeEvent native_event) override; |
122 | 119 |
123 protected: | 120 protected: |
124 internal::NativeWidgetDelegate* delegate() { return delegate_; } | 121 internal::NativeWidgetDelegate* delegate() { return delegate_; } |
125 | 122 |
126 private: | 123 private: |
127 friend class test::MockNativeWidgetMac; | 124 friend class test::MockNativeWidgetMac; |
128 | 125 |
129 internal::NativeWidgetDelegate* delegate_; | 126 internal::NativeWidgetDelegate* delegate_; |
130 scoped_ptr<BridgedNativeWidget> bridge_; | 127 scoped_ptr<BridgedNativeWidget> bridge_; |
131 | 128 |
132 Widget::InitParams::Ownership ownership_; | 129 Widget::InitParams::Ownership ownership_; |
133 | 130 |
134 DISALLOW_COPY_AND_ASSIGN(NativeWidgetMac); | 131 DISALLOW_COPY_AND_ASSIGN(NativeWidgetMac); |
135 }; | 132 }; |
136 | 133 |
137 } // namespace views | 134 } // namespace views |
138 | 135 |
139 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_MAC_H_ | 136 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_MAC_H_ |
OLD | NEW |