Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / profiles / avatar_button.mm
bloba1d5c12c1c0122bfd5661dfa6b51480b16aa304c
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 #import "chrome/browser/ui/cocoa/profiles/avatar_button.h"
7 @interface AvatarButton (Private)
9 - (void)rightMouseDown:(NSEvent*)event;
10 - (void)performRightClick;
12 @end
14 @implementation AvatarButton
16 // Overrides -rightMouseDown and implements a custom mouse tracking loop.
17 - (void)rightMouseDown:(NSEvent*)event {
18   NSEvent* nextEvent = event;
19   BOOL mouseInBounds = NO;
20   hoverState_ = kHoverStateMouseDown;
22   do {
23     nextEvent = [[self window]
24         nextEventMatchingMask:NSRightMouseDraggedMask |
25                               NSRightMouseUpMask];
27     mouseInBounds = NSPointInRect(
28         [self convertPoint:[nextEvent locationInWindow] fromView:nil],
29         [self convertRect:[self frame] fromView:nil]);
30   } while (NSRightMouseUp != [nextEvent type]);
32   hoverState_ = kHoverStateNone;
34   if (mouseInBounds) {
35     hoverState_ = kHoverStateMouseOver;
36     [self performRightClick];
37   }
40 - (void)performRightClick {
41   [[super target] performSelector:rightAction_ withObject:self];
44 - (void)setRightAction:(SEL)selector {
45   rightAction_ = selector;
48 @end