1 // Copyright 2015 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/views/apps/app_window_native_widget_mac.h"
7 #import <Cocoa/Cocoa.h>
9 #import "chrome/browser/ui/cocoa/apps/titlebar_background_view.h"
10 #import "chrome/browser/ui/views/frame/native_widget_mac_frameless_nswindow.h"
11 #include "extensions/browser/app_window/native_app_window.h"
12 #import "ui/base/cocoa/window_size_constants.h"
14 AppWindowNativeWidgetMac::AppWindowNativeWidgetMac(
15 views::Widget* widget,
16 extensions::NativeAppWindow* native_app_window)
17 : NativeWidgetMac(widget), native_app_window_(native_app_window) {
20 AppWindowNativeWidgetMac::~AppWindowNativeWidgetMac() {
23 NativeWidgetMacNSWindow* AppWindowNativeWidgetMac::CreateNSWindow(
24 const views::Widget::InitParams& params) {
25 // If the window has a native or colored frame, use the same NSWindow as
27 if (!native_app_window_->IsFrameless()) {
28 NativeWidgetMacNSWindow* ns_window =
29 NativeWidgetMac::CreateNSWindow(params);
30 if (native_app_window_->HasFrameColor()) {
31 [TitlebarBackgroundView
32 addToNSWindow:ns_window
33 activeColor:native_app_window_->ActiveFrameColor()
34 inactiveColor:native_app_window_->InactiveFrameColor()];
39 // NSTexturedBackgroundWindowMask is needed to implement draggable window
41 NSUInteger style_mask = NSTexturedBackgroundWindowMask | NSTitledWindowMask |
42 NSClosableWindowMask | NSMiniaturizableWindowMask |
43 NSResizableWindowMask;
44 return [[[NativeWidgetMacFramelessNSWindow alloc]
45 initWithContentRect:ui::kWindowSizeDeterminedLater
47 backing:NSBackingStoreBuffered
48 defer:NO] autorelease];