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.
4 
5 #ifndef COMPONENTS_REMOTE_COCOA_APP_SHIM_NATIVE_WIDGET_MAC_NSWINDOW_H_
6 #define COMPONENTS_REMOTE_COCOA_APP_SHIM_NATIVE_WIDGET_MAC_NSWINDOW_H_
7 
8 #import <Cocoa/Cocoa.h>
9 
10 #include "base/mac/foundation_util.h"
11 #include "components/remote_cocoa/app_shim/remote_cocoa_app_shim_export.h"
12 #import "ui/base/cocoa/command_dispatcher.h"
13 
14 namespace remote_cocoa {
15 class NativeWidgetNSWindowBridge;
16 }  // namespace remote_cocoa
17 
18 @protocol WindowTouchBarDelegate;
19 
20 // Weak lets Chrome launch even if a future macOS doesn't have the below classes
21 WEAK_IMPORT_ATTRIBUTE
22 @interface NSNextStepFrame : NSView
23 @end
24 
25 WEAK_IMPORT_ATTRIBUTE
26 @interface NSThemeFrame : NSView
27 @end
28 
29 REMOTE_COCOA_APP_SHIM_EXPORT
30 @interface NativeWidgetMacNSWindowBorderlessFrame : NSNextStepFrame
31 @end
32 
33 REMOTE_COCOA_APP_SHIM_EXPORT
34 @interface NativeWidgetMacNSWindowTitledFrame : NSThemeFrame
35 @end
36 
37 // The NSWindow used by BridgedNativeWidget. Provides hooks into AppKit that
38 // can only be accomplished by overriding methods.
39 REMOTE_COCOA_APP_SHIM_EXPORT
40 @interface NativeWidgetMacNSWindow : NSWindow <CommandDispatchingWindow>
41 
42 // Set a CommandDispatcherDelegate, i.e. to implement key event handling.
43 - (void)setCommandDispatcherDelegate:(id<CommandDispatcherDelegate>)delegate;
44 
45 // Selector passed to [NSApp beginSheet:]. Forwards to [self delegate], if set.
46 - (void)sheetDidEnd:(NSWindow*)sheet
47          returnCode:(NSInteger)returnCode
48         contextInfo:(void*)contextInfo;
49 
50 // Set a WindowTouchBarDelegate to allow creation of a custom TouchBar when
51 // AppKit follows the responder chain and reaches the NSWindow when trying to
52 // create one.
53 - (void)setWindowTouchBarDelegate:(id<WindowTouchBarDelegate>)delegate;
54 
55 // Identifier for the NativeWidgetMac from which this window was created. This
56 // may be used to look up the NativeWidgetMacNSWindowHost in the browser process
57 // or the NativeWidgetNSWindowBridge in a display process.
58 @property(assign, nonatomic) uint64_t bridgedNativeWidgetId;
59 
60 // The NativeWidgetNSWindowBridge that this will use to call back to the host.
61 @property(assign, nonatomic) remote_cocoa::NativeWidgetNSWindowBridge* bridge;
62 @end
63 
64 #endif  // COMPONENTS_REMOTE_COCOA_APP_SHIM_NATIVE_WIDGET_MAC_NSWINDOW_H_
65