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/native_app_window_frame_view_mac.h"
7 #import <Cocoa/Cocoa.h>
9 #include "extensions/browser/app_window/native_app_window.h"
10 #include "ui/base/hit_test.h"
11 #import "ui/gfx/mac/coordinate_conversion.h"
12 #include "ui/views/widget/widget.h"
14 NativeAppWindowFrameViewMac::NativeAppWindowFrameViewMac(
16 extensions::NativeAppWindow* window)
17 : views::NativeFrameView(frame), native_app_window_(window) {
20 NativeAppWindowFrameViewMac::~NativeAppWindowFrameViewMac() {
23 gfx::Rect NativeAppWindowFrameViewMac::GetWindowBoundsForClientBounds(
24 const gfx::Rect& client_bounds) const {
25 NSWindow* ns_window = GetWidget()->GetNativeWindow();
26 gfx::Rect window_bounds = gfx::ScreenRectFromNSRect([ns_window
27 frameRectForContentRect:gfx::ScreenRectToNSRect(client_bounds)]);
28 // Enforce minimum size (1, 1) in case that |client_bounds| is passed with
30 if (window_bounds.IsEmpty())
31 window_bounds.set_size(gfx::Size(1, 1));
35 int NativeAppWindowFrameViewMac::NonClientHitTest(const gfx::Point& point) {
36 if (!bounds().Contains(point))
39 if (GetWidget()->IsFullscreen())
42 // Check for possible draggable region in the client area for the frameless
44 SkRegion* draggable_region = native_app_window_->GetDraggableRegion();
45 if (draggable_region && draggable_region->contains(point.x(), point.y()))