Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / views / cocoa / views_nswindow_delegate.mm
blob6a344a38fa330e02742142f85982dc5cdfd6ee76
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
3 // found in the LICENSE file.
5 #import "ui/views/cocoa/views_nswindow_delegate.h"
7 #include "base/logging.h"
8 #import "ui/views/cocoa/bridged_content_view.h"
9 #import "ui/views/cocoa/bridged_native_widget.h"
10 #include "ui/views/widget/native_widget_mac.h"
12 @implementation ViewsNSWindowDelegate
14 - (id)initWithBridgedNativeWidget:(views::BridgedNativeWidget*)parent {
15   DCHECK(parent);
16   if ((self = [super init])) {
17     parent_ = parent;
18   }
19   return self;
22 - (views::NativeWidgetMac*)nativeWidgetMac {
23   return parent_->native_widget_mac();
26 - (NSCursor*)cursor {
27   return cursor_.get();
30 - (void)setCursor:(NSCursor*)newCursor {
31   if (cursor_.get() == newCursor)
32     return;
34   cursor_.reset([newCursor retain]);
35   [parent_->ns_window() resetCursorRects];
38 - (void)onWindowOrderWillChange:(NSWindowOrderingMode)orderingMode {
39   parent_->OnVisibilityChangedTo(orderingMode != NSWindowOut);
42 - (void)onWindowOrderChanged:(NSNotification*)notification {
43   parent_->OnVisibilityChanged();
46 - (void)onWindowWillDisplay {
47   parent_->OnVisibilityChangedTo(true);
50 - (void)sheetDidEnd:(NSWindow*)sheet
51          returnCode:(NSInteger)returnCode
52         contextInfo:(void*)contextInfo {
53   [sheet orderOut:nil];
54   parent_->OnWindowWillClose();
57 // NSWindowDelegate implementation.
59 - (void)windowDidFailToEnterFullScreen:(NSWindow*)window {
60   // Cocoa should already have sent an (unexpected) windowDidExitFullScreen:
61   // notification, and the attempt to get back into fullscreen should fail.
62   // Nothing to do except verify |parent_| is no longer trying to fullscreen.
63   DCHECK(!parent_->target_fullscreen_state());
66 - (void)windowDidFailToExitFullScreen:(NSWindow*)window {
67   // Unlike entering fullscreen, windowDidFailToExitFullScreen: is sent *before*
68   // windowDidExitFullScreen:. Also, failing to exit fullscreen just dumps the
69   // window out of fullscreen without an animation; still sending the expected,
70   // windowDidExitFullScreen: notification. So, again, nothing to do here.
71   DCHECK(!parent_->target_fullscreen_state());
74 - (void)windowDidResize:(NSNotification*)notification {
75   parent_->OnSizeChanged();
78 - (void)windowDidBecomeKey:(NSNotification*)notification {
79   parent_->OnWindowKeyStatusChangedTo(true);
82 - (void)windowDidResignKey:(NSNotification*)notification {
83   parent_->OnWindowKeyStatusChangedTo(false);
86 - (void)windowWillClose:(NSNotification*)notification {
87   DCHECK([parent_->ns_window() isEqual:[notification object]]);
88   parent_->OnWindowWillClose();
91 - (void)windowDidMiniaturize:(NSNotification*)notification {
92   parent_->OnVisibilityChanged();
95 - (void)windowDidDeminiaturize:(NSNotification*)notification {
96   parent_->OnVisibilityChanged();
99 - (void)windowDidChangeBackingProperties:(NSNotification*)notification {
100   parent_->OnBackingPropertiesChanged();
103 - (void)windowWillEnterFullScreen:(NSNotification*)notification {
104   parent_->OnFullscreenTransitionStart(true);
107 - (void)windowDidEnterFullScreen:(NSNotification*)notification {
108   parent_->OnFullscreenTransitionComplete(true);
111 - (void)windowWillExitFullScreen:(NSNotification*)notification {
112   parent_->OnFullscreenTransitionStart(false);
115 - (void)windowDidExitFullScreen:(NSNotification*)notification {
116   parent_->OnFullscreenTransitionComplete(false);
119 @end