blob: e8bdf285a7794625c9e07b62b8ab53c6fe0ce7e0 [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_WIDGET_NATIVE_WIDGET_MAC_H_
#define UI_VIEWS_WIDGET_NATIVE_WIDGET_MAC_H_
#include "ui/gfx/native_widget_types.h"
#include "ui/views/widget/native_widget_private.h"
namespace views {
namespace test {
class MockNativeWidgetMac;
}
class BridgedNativeWidget;
class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate {
public:
NativeWidgetMac(internal::NativeWidgetDelegate* delegate);
~NativeWidgetMac() override;
// Retrieves the bridge associated with the given NSWindow. Returns null if
// the supplied handle has no associated Widget.
static BridgedNativeWidget* GetBridgeForNativeWindow(
gfx::NativeWindow window);
// Deletes |bridge_| and informs |delegate_| that the native widget is
// destroyed.
// This is usually called from the NSWindowDelegate. A derived class can
// override this method for an early hook into the native window teardown.
virtual void OnWindowWillClose();
// internal::NativeWidgetPrivate:
void InitNativeWidget(const Widget::InitParams& params) override;
NonClientFrameView* CreateNonClientFrameView() override;
bool ShouldUseNativeFrame() const override;
bool ShouldWindowContentsBeTransparent() const override;
void FrameTypeChanged() override;
Widget* GetWidget() override;
const Widget* GetWidget() const override;
gfx::NativeView GetNativeView() const override;
gfx::NativeWindow GetNativeWindow() const override;
Widget* GetTopLevelWidget() override;
const ui::Compositor* GetCompositor() const override;
const ui::Layer* GetLayer() const override;
void ReorderNativeViews() override;
void ViewRemoved(View* view) override;
void SetNativeWindowProperty(const char* name, void* value) override;
void* GetNativeWindowProperty(const char* name) const override;
TooltipManager* GetTooltipManager() const override;
void SetCapture() override;
void ReleaseCapture() override;
bool HasCapture() const override;
InputMethod* CreateInputMethod() override;
internal::InputMethodDelegate* GetInputMethodDelegate() override;
ui::InputMethod* GetHostInputMethod() override;
void CenterWindow(const gfx::Size& size) override;
void GetWindowPlacement(gfx::Rect* bounds,
ui::WindowShowState* maximized) const override;
bool SetWindowTitle(const base::string16& title) override;
void SetWindowIcons(const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon) override;
void InitModalType(ui::ModalType modal_type) override;
gfx::Rect GetWindowBoundsInScreen() const override;
gfx::Rect GetClientAreaBoundsInScreen() const override;
gfx::Rect GetRestoredBounds() const override;
void SetBounds(const gfx::Rect& bounds) override;
void SetSize(const gfx::Size& size) override;
void StackAbove(gfx::NativeView native_view) override;
void StackAtTop() override;
void StackBelow(gfx::NativeView native_view) override;
void SetShape(gfx::NativeRegion shape) override;
void Close() override;
void CloseNow() override;
void Show() override;
void Hide() override;
void ShowMaximizedWithBounds(const gfx::Rect& restored_bounds) override;
void ShowWithWindowState(ui::WindowShowState state) override;
bool IsVisible() const override;
void Activate() override;
void Deactivate() override;
bool IsActive() const override;
void SetAlwaysOnTop(bool always_on_top) override;
bool IsAlwaysOnTop() const override;
void SetVisibleOnAllWorkspaces(bool always_visible) override;
void Maximize() override;
void Minimize() override;
bool IsMaximized() const override;
bool IsMinimized() const override;
void Restore() override;
void SetFullscreen(bool fullscreen) override;
bool IsFullscreen() const override;
void SetOpacity(unsigned char opacity) override;
void SetUseDragFrame(bool use_drag_frame) override;
void FlashFrame(bool flash_frame) override;
void RunShellDrag(View* view,
const ui::OSExchangeData& data,
const gfx::Point& location,
int operation,
ui::DragDropTypes::DragEventSource source) override;
void SchedulePaintInRect(const gfx::Rect& rect) override;
void SetCursor(gfx::NativeCursor cursor) override;
bool IsMouseEventsEnabled() const override;
void ClearNativeFocus() override;
gfx::Rect GetWorkAreaBoundsInScreen() const override;
Widget::MoveLoopResult RunMoveLoop(
const gfx::Vector2d& drag_offset,
Widget::MoveLoopSource source,
Widget::MoveLoopEscapeBehavior escape_behavior) override;
void EndMoveLoop() override;
void SetVisibilityChangedAnimationsEnabled(bool value) override;
void SetVisibilityAnimationDuration(const base::TimeDelta& duration) override;
void SetVisibilityAnimationTransition(
Widget::VisibilityTransition transition) override;
ui::NativeTheme* GetNativeTheme() const override;
void OnRootViewLayout() override;
bool IsTranslucentWindowOpacitySupported() const override;
void OnSizeConstraintsChanged() override;
void RepostNativeEvent(gfx::NativeEvent native_event) override;
protected:
// Creates the NSWindow that will be passed to the BridgedNativeWidget.
// Called by InitNativeWidget. The return value will be autoreleased.
virtual gfx::NativeWindow CreateNSWindow(const Widget::InitParams& params);
internal::NativeWidgetDelegate* delegate() { return delegate_; }
private:
friend class test::MockNativeWidgetMac;
internal::NativeWidgetDelegate* delegate_;
scoped_ptr<BridgedNativeWidget> bridge_;
Widget::InitParams::Ownership ownership_;
DISALLOW_COPY_AND_ASSIGN(NativeWidgetMac);
};
} // namespace views
#endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_MAC_H_