2018-04-19 06:36:14 +00:00
|
|
|
// Copyright (c) 2018 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/ui/cocoa/electron_native_widget_mac.h"
|
2018-04-19 06:36:14 +00:00
|
|
|
|
2022-06-14 16:24:52 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "shell/browser/ui/cocoa/electron_ns_panel.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/ui/cocoa/electron_ns_window.h"
|
2018-04-24 08:23:08 +00:00
|
|
|
|
2018-04-19 06:36:14 +00:00
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
ElectronNativeWidgetMac::ElectronNativeWidgetMac(
|
2018-05-02 12:28:28 +00:00
|
|
|
NativeWindowMac* shell,
|
2022-06-14 16:24:52 +00:00
|
|
|
const std::string& window_type,
|
2018-04-24 08:23:08 +00:00
|
|
|
NSUInteger style_mask,
|
2018-04-19 06:36:14 +00:00
|
|
|
views::internal::NativeWidgetDelegate* delegate)
|
2018-04-24 08:23:08 +00:00
|
|
|
: views::NativeWidgetMac(delegate),
|
2018-05-02 12:28:28 +00:00
|
|
|
shell_(shell),
|
2022-06-14 16:24:52 +00:00
|
|
|
window_type_(window_type),
|
2018-04-24 08:23:08 +00:00
|
|
|
style_mask_(style_mask) {}
|
2018-04-19 06:36:14 +00:00
|
|
|
|
2021-06-04 04:16:13 +00:00
|
|
|
ElectronNativeWidgetMac::~ElectronNativeWidgetMac() = default;
|
2018-04-19 06:36:14 +00:00
|
|
|
|
2018-04-19 07:01:19 +00:00
|
|
|
NativeWidgetMacNSWindow* ElectronNativeWidgetMac::CreateNSWindow(
|
2019-05-22 19:56:21 +00:00
|
|
|
const remote_cocoa::mojom::CreateWindowParams* params) {
|
2022-06-14 16:24:52 +00:00
|
|
|
if (window_type_ == "panel") {
|
|
|
|
return [[[ElectronNSPanel alloc] initWithShell:shell_
|
|
|
|
styleMask:style_mask_] autorelease];
|
|
|
|
} else {
|
|
|
|
return [[[ElectronNSWindow alloc] initWithShell:shell_
|
|
|
|
styleMask:style_mask_] autorelease];
|
|
|
|
}
|
2018-04-19 06:36:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace electron
|