BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / constrained_window / constrained_window_sheet_controller.h
blobb299d6b395ea8c5d7bc8bd243782baeec75928d9
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 #ifndef CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_SHEET_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_SHEET_CONTROLLER_H_
8 #import <Cocoa/Cocoa.h>
9 #include <vector>
11 #include "base/mac/scoped_nsobject.h"
12 #include "base/memory/scoped_ptr.h"
14 namespace web_modal {
15 class WebContentsModalDialogHost;
18 class WebContentsModalDialogHostCocoa;
20 @protocol ConstrainedWindowSheet;
22 // This class manages multiple tab modal sheets for a single parent window. Each
23 // tab can have a single sheet and only the active tab's sheet will be visible.
24 // A tab in this case is the |parentView| passed to |-showSheet:forParentView:|.
25 @interface ConstrainedWindowSheetController : NSObject {
26 @private
27 base::scoped_nsobject<NSMutableArray> sheets_;
28 base::scoped_nsobject<NSWindow> parentWindow_;
29 base::scoped_nsobject<NSView> activeView_;
31 // Class that bridges the cross-platform web_modal APIs to the Cocoa sheet
32 // controller.
33 scoped_ptr<WebContentsModalDialogHostCocoa> dialogHost_;
36 @property(readonly, nonatomic)
37 web_modal::WebContentsModalDialogHost* dialogHost;
38 @property(readonly, nonatomic) NSWindow* parentWindow;
40 // Returns a sheet controller for |parentWindow|. If a sheet controller does not
41 // exist yet then one will be created.
42 + (ConstrainedWindowSheetController*)
43 controllerForParentWindow:(NSWindow*)parentWindow;
45 // Find a controller that's managing the given sheet. If no such controller
46 // exists then nil is returned.
47 + (ConstrainedWindowSheetController*)
48 controllerForSheet:(id<ConstrainedWindowSheet>)sheet;
50 // Find the sheet attached to the given overlay window.
51 + (id<ConstrainedWindowSheet>)sheetForOverlayWindow:(NSWindow*)overlayWindow;
53 // Shows the given sheet over |parentView|.
54 - (void)showSheet:(id<ConstrainedWindowSheet>)sheet
55 forParentView:(NSView*)parentView;
57 // Hides a sheet over the active view.
58 - (void)hideSheet;
60 // Calculates the position of the sheet for the given window size.
61 - (NSPoint)originForSheet:(id<ConstrainedWindowSheet>)sheet
62 withWindowSize:(NSSize)size;
64 // Closes the given sheet.
65 - (void)closeSheet:(id<ConstrainedWindowSheet>)sheet;
67 // Run a pulse animation for the given sheet. This does nothing if the sheet
68 // is not visible.
69 - (void)pulseSheet:(id<ConstrainedWindowSheet>)sheet;
71 // Gets the number of sheets attached to the controller's window.
72 - (int)sheetCount;
74 // The size of the overlay window, which can be used to determine a preferred
75 // maximum size for a dialog that should be contained within |parentView|.
76 - (NSSize)overlayWindowSizeForParentView:(NSView*)parentView;
78 @end
80 #endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_SHEET_CONTROLLER_H_