Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / constrained_window / constrained_window_sheet_info.mm
blob2af64cb698f7a34213bc8e76c22bdf0247c10077
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]);
22   }
23   return self;
26 - (id<ConstrainedWindowSheet>)sheet {
27   return sheet_;
30 - (NSView*)parentView {
31   return parentView_;
34 - (NSWindow*)overlayWindow {
35   return overlayWindow_;
38 - (void)hideSheet {
39   [sheet_ hideSheet];
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];
48 - (void)showSheet {
49   [overlayWindow_ setIgnoresMouseEvents:NO];
50   if (sheetDidShow_) {
51     [sheet_ unhideSheet];
52   } else {
53     [sheet_ showSheetForWindow:overlayWindow_];
54     sheetDidShow_ = YES;
55   }
56   [sheet_ makeSheetKeyAndOrderFront];
59 @end