OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/apps/app_window_native_widget_mac.h" | 5 #include "chrome/browser/ui/views/apps/app_window_native_widget_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
| 9 #import "chrome/browser/ui/cocoa/apps/titlebar_background_view.h" |
9 #import "chrome/browser/ui/views/frame/native_widget_mac_frameless_nswindow.h" | 10 #import "chrome/browser/ui/views/frame/native_widget_mac_frameless_nswindow.h" |
| 11 #include "extensions/browser/app_window/native_app_window.h" |
10 #import "ui/base/cocoa/window_size_constants.h" | 12 #import "ui/base/cocoa/window_size_constants.h" |
11 | 13 |
12 AppWindowNativeWidgetMac::AppWindowNativeWidgetMac(views::Widget* widget) | 14 AppWindowNativeWidgetMac::AppWindowNativeWidgetMac( |
13 : NativeWidgetMac(widget) { | 15 views::Widget* widget, |
| 16 extensions::NativeAppWindow* native_app_window) |
| 17 : NativeWidgetMac(widget), native_app_window_(native_app_window) { |
14 } | 18 } |
15 | 19 |
16 AppWindowNativeWidgetMac::~AppWindowNativeWidgetMac() { | 20 AppWindowNativeWidgetMac::~AppWindowNativeWidgetMac() { |
17 } | 21 } |
18 | 22 |
19 NSWindow* AppWindowNativeWidgetMac::CreateNSWindow( | 23 NSWindow* AppWindowNativeWidgetMac::CreateNSWindow( |
20 const views::Widget::InitParams& params) { | 24 const views::Widget::InitParams& params) { |
21 // If the window has a standard frame, use the same NSWindow as | 25 // If the window has a native or colored frame, use the same NSWindow as |
22 // NativeWidgetMac. | 26 // NativeWidgetMac. |
23 if (!params.remove_standard_frame) | 27 if (!native_app_window_->IsFrameless()) { |
24 return NativeWidgetMac::CreateNSWindow(params); | 28 NSWindow* ns_window = NativeWidgetMac::CreateNSWindow(params); |
| 29 if (native_app_window_->HasFrameColor()) { |
| 30 [TitlebarBackgroundView |
| 31 addToNSWindow:ns_window |
| 32 activeColor:native_app_window_->ActiveFrameColor() |
| 33 inactiveColor:native_app_window_->InactiveFrameColor()]; |
| 34 } |
| 35 return ns_window; |
| 36 } |
25 | 37 |
26 // NSTexturedBackgroundWindowMask is needed to implement draggable window | 38 // NSTexturedBackgroundWindowMask is needed to implement draggable window |
27 // regions. | 39 // regions. |
28 NSUInteger style_mask = NSTexturedBackgroundWindowMask | NSTitledWindowMask | | 40 NSUInteger style_mask = NSTexturedBackgroundWindowMask | NSTitledWindowMask | |
29 NSClosableWindowMask | NSMiniaturizableWindowMask | | 41 NSClosableWindowMask | NSMiniaturizableWindowMask | |
30 NSResizableWindowMask; | 42 NSResizableWindowMask; |
31 return [[[NativeWidgetMacFramelessNSWindow alloc] | 43 return [[[NativeWidgetMacFramelessNSWindow alloc] |
32 initWithContentRect:ui::kWindowSizeDeterminedLater | 44 initWithContentRect:ui::kWindowSizeDeterminedLater |
33 styleMask:style_mask | 45 styleMask:style_mask |
34 backing:NSBackingStoreBuffered | 46 backing:NSBackingStoreBuffered |
35 defer:YES] autorelease]; | 47 defer:YES] autorelease]; |
36 } | 48 } |
OLD | NEW |