Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / constrained_window / constrained_window_sheet_controller.h
blob686946dd0a27e844e4e1b85587cd830fab778d98
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|. If |parentView| is not the active
54 // view then the sheet is not shown until the |parentView| becomes active.
55 - (void)showSheet:(id<ConstrainedWindowSheet>)sheet
56 forParentView:(NSView*)parentView;
58 // Calculates the position of the sheet for the given window size.
59 - (NSPoint)originForSheet:(id<ConstrainedWindowSheet>)sheet
60 withWindowSize:(NSSize)size;
62 // Closes the given sheet.
63 - (void)closeSheet:(id<ConstrainedWindowSheet>)sheet;
65 // Make |parentView| the current active view. If |parentView| has an attached
66 // sheet then the sheet is made visible.
67 - (void)parentViewDidBecomeActive:(NSView*)parentView;
69 // Run a pulse animation for the given sheet. This does nothing if the sheet
70 // is not visible.
71 - (void)pulseSheet:(id<ConstrainedWindowSheet>)sheet;
73 // Gets the number of sheets attached to the controller's window.
74 - (int)sheetCount;
76 // The size of the overlay window, which can be used to determine a preferred
77 // maximum size for a dialog that should be contained within |parentView|.
78 - (NSSize)overlayWindowSizeForParentView:(NSView*)parentView;
80 @end
82 #endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_SHEET_CONTROLLER_H_