OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cocoa/extensions/shell_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/extensions/shell_window_cocoa.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/cocoa/browser_window_utils.h" | 10 #include "chrome/browser/ui/cocoa/browser_window_utils.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 | 50 |
51 @end | 51 @end |
52 | 52 |
53 @interface ShellNSWindow : UnderlayOpenGLHostingWindow | 53 @interface ShellNSWindow : UnderlayOpenGLHostingWindow |
54 | 54 |
55 - (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view; | 55 - (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view; |
56 | 56 |
57 @end | 57 @end |
58 | 58 |
| 59 // This is really a method on NSGrayFrame, so it should only be called on the |
| 60 // view passed into -[NSWindow drawCustomFrameRect:forView:]. |
| 61 @interface NSView (PrivateMethods) |
| 62 - (CGFloat)roundedCornerRadius; |
| 63 @end |
| 64 |
59 @implementation ShellNSWindow | 65 @implementation ShellNSWindow |
60 | 66 |
61 - (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view { | 67 - (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view { |
62 [[NSBezierPath bezierPathWithRect:rect] addClip]; | 68 [[NSBezierPath bezierPathWithRect:rect] addClip]; |
63 [[NSColor clearColor] set]; | 69 [[NSColor clearColor] set]; |
64 NSRectFill(rect); | 70 NSRectFill(rect); |
65 const CGFloat kWindowBorderRadius = 3.0; | 71 |
| 72 // Set up our clip. |
| 73 CGFloat cornerRadius = 4.0; |
| 74 if ([view respondsToSelector:@selector(roundedCornerRadius)]) |
| 75 cornerRadius = [view roundedCornerRadius]; |
66 [[NSBezierPath bezierPathWithRoundedRect:[view bounds] | 76 [[NSBezierPath bezierPathWithRoundedRect:[view bounds] |
67 xRadius:kWindowBorderRadius | 77 xRadius:cornerRadius |
68 yRadius:kWindowBorderRadius] addClip]; | 78 yRadius:cornerRadius] addClip]; |
69 [[NSColor whiteColor] set]; | 79 [[NSColor whiteColor] set]; |
70 NSRectFill(rect); | 80 NSRectFill(rect); |
71 } | 81 } |
72 | 82 |
73 @end | 83 @end |
74 | 84 |
75 ShellWindowCocoa::ShellWindowCocoa(Profile* profile, | 85 ShellWindowCocoa::ShellWindowCocoa(Profile* profile, |
76 const extensions::Extension* extension, | 86 const extensions::Extension* extension, |
77 const GURL& url, | 87 const GURL& url, |
78 const ShellWindow::CreateParams& params) | 88 const ShellWindow::CreateParams& params) |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 return [window_controller_ window]; | 324 return [window_controller_ window]; |
315 } | 325 } |
316 | 326 |
317 // static | 327 // static |
318 ShellWindow* ShellWindow::CreateImpl(Profile* profile, | 328 ShellWindow* ShellWindow::CreateImpl(Profile* profile, |
319 const extensions::Extension* extension, | 329 const extensions::Extension* extension, |
320 const GURL& url, | 330 const GURL& url, |
321 const ShellWindow::CreateParams& params) { | 331 const ShellWindow::CreateParams& params) { |
322 return new ShellWindowCocoa(profile, extension, url, params); | 332 return new ShellWindowCocoa(profile, extension, url, params); |
323 } | 333 } |
OLD | NEW |