Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / draggable_button.mm
blob0b3bcd8a8dda092dd80568de7f46f0806f33256f
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/draggable_button.h"
7 #include "base/logging.h"
9 @implementation DraggableButton
11 - (id)initWithFrame:(NSRect)frame {
12   if ((self = [super initWithFrame:frame])) {
13     draggableButtonImpl_.reset(
14         [[DraggableButtonImpl alloc] initWithButton:self]);
15   }
16   return self;
19 - (id)initWithCoder:(NSCoder*)coder {
20   if ((self = [super initWithCoder:coder])) {
21     draggableButtonImpl_.reset(
22         [[DraggableButtonImpl alloc] initWithButton:self]);
23   }
24   return self;
27 - (DraggableButtonImpl*)draggableButton {
28   return draggableButtonImpl_.get();
31 - (void)mouseUp:(NSEvent*)theEvent {
32   if ([draggableButtonImpl_ mouseUpImpl:theEvent] ==
33           kDraggableButtonMixinCallSuper) {
34     [super mouseUp:theEvent];
35   }
38 - (void)mouseDown:(NSEvent*)theEvent {
39   // The impl spins an event loop to distinguish clicks from drags,
40   // which could result in our destruction.  Wire ourselves down for
41   // the duration.
42   base::scoped_nsobject<DraggableButton> keepAlive([self retain]);
44   if ([draggableButtonImpl_ mouseDownImpl:theEvent] ==
45           kDraggableButtonMixinCallSuper) {
46     [super mouseDown:theEvent];
47   }
50 - (void)beginDrag:(NSEvent*)dragEvent {
51   // Must be overridden by subclasses.
52   NOTREACHED();
55 @end  // @interface DraggableButton