Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / new_tab_button.mm
blob176c80c063885be46cd7e1fe9b1e95a47141bfc6
1 // Copyright (c) 2011 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/new_tab_button.h"
7 #import "chrome/browser/ui/cocoa/image_button_cell.h"
8 #include "grit/theme_resources.h"
9 #include "ui/base/resource/resource_bundle.h"
11 // A simple override of the ImageButtonCell to disable handling of
12 // -mouseEntered.
13 @interface NewTabButtonCell : ImageButtonCell
15 - (void)mouseEntered:(NSEvent*)theEvent;
17 @end
19 @implementation NewTabButtonCell
21 - (void)mouseEntered:(NSEvent*)theEvent {
22   // Ignore this since the NTB enter is handled by the TabStripController.
25 @end
28 @implementation NewTabButton
30 + (Class)cellClass {
31   return [NewTabButtonCell class];
34 - (BOOL)pointIsOverButton:(NSPoint)point {
35   NSPoint localPoint = [self convertPoint:point fromView:[self superview]];
36   NSRect pointRect = NSMakeRect(localPoint.x, localPoint.y, 1, 1);
37   ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
38   NSImage* buttonMask =
39       bundle.GetNativeImageNamed(IDR_NEWTAB_BUTTON_MASK).ToNSImage();
40   NSRect destinationRect = NSMakeRect(
41       (NSWidth(self.bounds) - [buttonMask size].width) / 2,
42       (NSHeight(self.bounds) - [buttonMask size].height) / 2,
43       [buttonMask size].width, [buttonMask size].height);
44   return [buttonMask hitTestRect:pointRect
45         withImageDestinationRect:destinationRect
46                          context:nil
47                            hints:nil
48                          flipped:YES];
51 // Override to only accept clicks within the bounds of the defined path, not
52 // the entire bounding box. |aPoint| is in the superview's coordinate system.
53 - (NSView*)hitTest:(NSPoint)aPoint {
54   if ([self pointIsOverButton:aPoint])
55     return [super hitTest:aPoint];
56   return nil;
59 // ThemedWindowDrawing implementation.
61 - (void)windowDidChangeTheme {
62   [self setNeedsDisplay:YES];
65 - (void)windowDidChangeActive {
66   [self setNeedsDisplay:YES];
69 @end