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 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_info.h"
7 #include "base/mac/foundation_util.h"
8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h"
9 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.h"
11 @implementation ConstrainedWindowSheetInfo
13 @synthesize sheetDidShow = sheetDidShow_;
15 - (id)initWithSheet:(id<ConstrainedWindowSheet>)sheet
16 parentView:(NSView*)parentView
17 overlayWindow:(NSWindow*)overlayWindow {
18 if ((self = [super init])) {
19 sheet_.reset([sheet retain]);
20 parentView_.reset([parentView retain]);
21 overlayWindow_.reset([overlayWindow retain]);
26 - (id<ConstrainedWindowSheet>)sheet {
30 - (NSView*)parentView {
34 - (NSWindow*)overlayWindow {
35 return overlayWindow_;
41 // Overlay window is already invisible so just stop accepting mouse events.
42 [overlayWindow_ setIgnoresMouseEvents:YES];
44 // Make sure the now invisible sheet doesn't keep keyboard focus
45 [[overlayWindow_ parentWindow] makeKeyWindow];
49 [overlayWindow_ setIgnoresMouseEvents:NO];
53 [sheet_ showSheetForWindow:overlayWindow_];
56 [sheet_ makeSheetKeyAndOrderFront];