Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
|
mfomitchev
2015/11/04 23:21:14
2015
bshe
2015/11/11 00:38:29
Done.
| |
| 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_ANDROID_NATIVE_WIDGET_ANDROID_H_ |
| 6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_MAC_H_ | 6 #define UI_VIEWS_WIDGET_ANDROID_NATIVE_WIDGET_ANDROID_H_ |
| 7 | 7 |
| 8 #include "ui/gfx/native_widget_types.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 9 #include "ui/views/widget/native_widget_private.h" | 10 #include "ui/views/widget/native_widget_private.h" |
| 10 | 11 |
| 11 #if defined(__OBJC__) | 12 namespace aura { |
| 12 @class NativeWidgetMacNSWindow; | 13 class Window; |
| 13 #else | 14 class WindowTreeHost; |
| 14 class NativeWidgetMacNSWindow; | 15 namespace client { |
| 15 #endif | 16 class DefaultCaptureClient; |
| 17 class WindowTreeClient; | |
| 18 } | |
| 19 } | |
| 20 | |
| 21 namespace wm { | |
| 22 class FocusController; | |
| 23 } | |
| 24 | |
| 25 namespace gfx { | |
| 26 class Rect; | |
| 27 class Size; | |
| 28 } | |
| 16 | 29 |
| 17 namespace views { | 30 namespace views { |
| 18 namespace test { | |
| 19 class HitTestNativeWidgetMac; | |
| 20 class MockNativeWidgetMac; | |
| 21 } | |
| 22 | 31 |
| 23 class BridgedNativeWidget; | 32 class VIEWS_EXPORT NativeWidgetAndroid : public internal::NativeWidgetPrivate { |
| 33 public: | |
| 34 explicit NativeWidgetAndroid(internal::NativeWidgetDelegate* delegate); | |
| 35 ~NativeWidgetAndroid() override; | |
| 36 aura::WindowTreeHost* host() { return host_.get(); } | |
| 24 | 37 |
| 25 class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate { | 38 protected: |
| 26 public: | 39 // Overridden from internal::NativeWidgetPrivate: |
| 27 NativeWidgetMac(internal::NativeWidgetDelegate* delegate); | |
| 28 ~NativeWidgetMac() override; | |
| 29 | |
| 30 // Retrieves the bridge associated with the given NSWindow. Returns null if | |
| 31 // the supplied handle has no associated Widget. | |
| 32 static BridgedNativeWidget* GetBridgeForNativeWindow( | |
| 33 gfx::NativeWindow window); | |
| 34 | |
| 35 // Return true if the delegate's modal type is window-modal. These display as | |
| 36 // a native window "sheet", and have a different lifetime to regular windows. | |
| 37 bool IsWindowModalSheet() const; | |
| 38 | |
| 39 // Deletes |bridge_| and informs |delegate_| that the native widget is | |
| 40 // destroyed. | |
| 41 // This is usually called from the NSWindowDelegate. A derived class can | |
| 42 // override this method for an early hook into the native window teardown. | |
| 43 virtual void OnWindowWillClose(); | |
| 44 | |
| 45 // Returns the vertical position that sheets should be anchored, in pixels | |
| 46 // from the bottom of the window. | |
| 47 virtual int SheetPositionY(); | |
| 48 | |
| 49 // internal::NativeWidgetPrivate: | |
| 50 void InitNativeWidget(const Widget::InitParams& params) override; | 40 void InitNativeWidget(const Widget::InitParams& params) override; |
| 51 NonClientFrameView* CreateNonClientFrameView() override; | 41 NonClientFrameView* CreateNonClientFrameView() override; |
| 52 bool ShouldUseNativeFrame() const override; | 42 bool ShouldUseNativeFrame() const override; |
| 53 bool ShouldWindowContentsBeTransparent() const override; | 43 bool ShouldWindowContentsBeTransparent() const override; |
| 54 void FrameTypeChanged() override; | 44 void FrameTypeChanged() override; |
| 55 Widget* GetWidget() override; | 45 Widget* GetWidget() override; |
| 56 const Widget* GetWidget() const override; | 46 const Widget* GetWidget() const override; |
| 57 gfx::NativeView GetNativeView() const override; | 47 gfx::NativeView GetNativeView() const override; |
| 58 gfx::NativeWindow GetNativeWindow() const override; | 48 gfx::NativeWindow GetNativeWindow() const override; |
| 59 Widget* GetTopLevelWidget() override; | 49 Widget* GetTopLevelWidget() override; |
| 60 const ui::Compositor* GetCompositor() const override; | 50 const ui::Compositor* GetCompositor() const override; |
| 61 const ui::Layer* GetLayer() const override; | 51 const ui::Layer* GetLayer() const override; |
| 62 void ReorderNativeViews() override; | 52 void ReorderNativeViews() override; |
| 63 void ViewRemoved(View* view) override; | 53 void ViewRemoved(View* view) override; |
| 64 void SetNativeWindowProperty(const char* name, void* value) override; | 54 void SetNativeWindowProperty(const char* name, void* value) override; |
| 65 void* GetNativeWindowProperty(const char* name) const override; | 55 void* GetNativeWindowProperty(const char* name) const override; |
| 66 TooltipManager* GetTooltipManager() const override; | 56 TooltipManager* GetTooltipManager() const override; |
| 67 void SetCapture() override; | 57 void SetCapture() override; |
| 68 void ReleaseCapture() override; | 58 void ReleaseCapture() override; |
| 69 bool HasCapture() const override; | 59 bool HasCapture() const override; |
| 70 ui::InputMethod* GetInputMethod() override; | 60 ui::InputMethod* GetInputMethod() override; |
| 71 void CenterWindow(const gfx::Size& size) override; | 61 void CenterWindow(const gfx::Size& size) override; |
| 72 void GetWindowPlacement(gfx::Rect* bounds, | 62 void GetWindowPlacement(gfx::Rect* bounds, |
| 73 ui::WindowShowState* show_state) const override; | 63 ui::WindowShowState* maximized) const override; |
|
sadrul
2015/11/04 19:00:53
|show_state| would make more sense, instead of |ma
bshe
2015/11/11 00:38:29
Done.
| |
| 74 bool SetWindowTitle(const base::string16& title) override; | 64 bool SetWindowTitle(const base::string16& title) override; |
| 75 void SetWindowIcons(const gfx::ImageSkia& window_icon, | 65 void SetWindowIcons(const gfx::ImageSkia& window_icon, |
| 76 const gfx::ImageSkia& app_icon) override; | 66 const gfx::ImageSkia& app_icon) override; |
| 77 void InitModalType(ui::ModalType modal_type) override; | 67 void InitModalType(ui::ModalType modal_type) override; |
| 78 gfx::Rect GetWindowBoundsInScreen() const override; | 68 gfx::Rect GetWindowBoundsInScreen() const override; |
| 79 gfx::Rect GetClientAreaBoundsInScreen() const override; | 69 gfx::Rect GetClientAreaBoundsInScreen() const override; |
| 80 gfx::Rect GetRestoredBounds() const override; | 70 gfx::Rect GetRestoredBounds() const override; |
| 81 void SetBounds(const gfx::Rect& bounds) override; | 71 void SetBounds(const gfx::Rect& bounds) override; |
| 82 void SetSize(const gfx::Size& size) override; | 72 void SetSize(const gfx::Size& size) override; |
| 83 void StackAbove(gfx::NativeView native_view) override; | 73 void StackAbove(gfx::NativeView native_view) override; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 void SetVisibilityChangedAnimationsEnabled(bool value) override; | 115 void SetVisibilityChangedAnimationsEnabled(bool value) override; |
| 126 void SetVisibilityAnimationDuration(const base::TimeDelta& duration) override; | 116 void SetVisibilityAnimationDuration(const base::TimeDelta& duration) override; |
| 127 void SetVisibilityAnimationTransition( | 117 void SetVisibilityAnimationTransition( |
| 128 Widget::VisibilityTransition transition) override; | 118 Widget::VisibilityTransition transition) override; |
| 129 ui::NativeTheme* GetNativeTheme() const override; | 119 ui::NativeTheme* GetNativeTheme() const override; |
| 130 void OnRootViewLayout() override; | 120 void OnRootViewLayout() override; |
| 131 bool IsTranslucentWindowOpacitySupported() const override; | 121 bool IsTranslucentWindowOpacitySupported() const override; |
| 132 void OnSizeConstraintsChanged() override; | 122 void OnSizeConstraintsChanged() override; |
| 133 void RepostNativeEvent(gfx::NativeEvent native_event) override; | 123 void RepostNativeEvent(gfx::NativeEvent native_event) override; |
| 134 | 124 |
| 135 protected: | 125 private: |
| 136 // Creates the NSWindow that will be passed to the BridgedNativeWidget. | 126 internal::NativeWidgetDelegate* delegate_; |
| 137 // Called by InitNativeWidget. The return value will be autoreleased. | 127 scoped_ptr<aura::WindowTreeHost> host_; |
| 138 virtual NativeWidgetMacNSWindow* CreateNSWindow( | 128 scoped_ptr<wm::FocusController> focus_client_; |
| 139 const Widget::InitParams& params); | 129 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; |
| 130 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; | |
| 140 | 131 |
| 141 internal::NativeWidgetDelegate* delegate() { return delegate_; } | 132 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAndroid); |
| 142 | |
| 143 private: | |
| 144 friend class test::MockNativeWidgetMac; | |
| 145 friend class test::HitTestNativeWidgetMac; | |
| 146 | |
| 147 internal::NativeWidgetDelegate* delegate_; | |
| 148 scoped_ptr<BridgedNativeWidget> bridge_; | |
| 149 | |
| 150 Widget::InitParams::Ownership ownership_; | |
| 151 | |
| 152 DISALLOW_COPY_AND_ASSIGN(NativeWidgetMac); | |
| 153 }; | 133 }; |
| 154 | 134 |
| 155 } // namespace views | 135 } // namespace views |
| 156 | 136 |
| 157 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_MAC_H_ | 137 #endif // UI_VIEWS_WIDGET_ANDROID_NATIVE_WIDGET_ANDROID_H_ |
| OLD | NEW |