Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / tabs / tab_strip_background_view.mm
blob4b32010d44e65a67c702b90540b9b1f7ec77acf8
1 // Copyright 2014 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 #import "chrome/browser/ui/cocoa/tabs/tab_strip_background_view.h"
7 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
8 #import "ui/base/cocoa/nsview_additions.h"
10 @implementation TabStripBackgroundView
12 - (void)drawRect:(NSRect)dirtyRect {
13   // Only the top corners are rounded. For simplicity, round all 4 corners but
14   // draw the bottom corners outside of the visible bounds.
15   float cornerRadius = 4.0;
16   NSRect roundedRect = [self bounds];
17   roundedRect.origin.y -= cornerRadius;
18   roundedRect.size.height += cornerRadius;
19   [[NSBezierPath bezierPathWithRoundedRect:roundedRect
20                                    xRadius:cornerRadius
21                                    yRadius:cornerRadius] addClip];
22   BOOL themed = [FramedBrowserWindow drawWindowThemeInDirtyRect:dirtyRect
23                                                         forView:self
24                                                          bounds:roundedRect
25                                            forceBlackBackground:NO];
27   // Draw a 1px border on the top edge and top corners.
28   if (themed) {
29     CGFloat lineWidth = [self cr_lineWidth];
30     // Inset the vertical lines by 0.5px so that the top line gets a full pixel.
31     // Outset the horizontal lines by 0.5px so that they are not visible, but
32     // still get the rounded corners to get a border.
33     NSRect strokeRect = NSInsetRect(roundedRect, -lineWidth/2, lineWidth/2);
34     NSBezierPath* path = [NSBezierPath bezierPathWithRoundedRect:strokeRect
35                                                          xRadius:cornerRadius
36                                                          yRadius:cornerRadius];
37     [path setLineWidth:lineWidth];
38     [[NSColor colorWithCalibratedWhite:1.0 alpha:0.5] set];
39     [path stroke];
40   }
43 // ThemedWindowDrawing implementation.
45 - (void)windowDidChangeTheme {
46   [self setNeedsDisplay:YES];
49 - (void)windowDidChangeActive {
50   [self setNeedsDisplay:YES];
53 @end