OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #import "chrome/browser/ui/cocoa/download/download_item_button.h" | 5 #import "chrome/browser/ui/cocoa/download/download_item_button.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" | 9 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" |
10 #import "chrome/browser/ui/cocoa/download/download_item_controller.h" | 10 #import "chrome/browser/ui/cocoa/download/download_item_controller.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 // Override to show a context menu on mouse down if clicked over the context | 25 // Override to show a context menu on mouse down if clicked over the context |
26 // menu area. | 26 // menu area. |
27 - (void)mouseDown:(NSEvent*)event { | 27 - (void)mouseDown:(NSEvent*)event { |
28 DCHECK(controller_); | 28 DCHECK(controller_); |
29 // Override so that we can pop up a context menu on mouse down. | 29 // Override so that we can pop up a context menu on mouse down. |
30 NSCell* cell = [self cell]; | 30 NSCell* cell = [self cell]; |
31 DCHECK([cell respondsToSelector:@selector(isMouseOverButtonPart)]); | 31 DCHECK([cell respondsToSelector:@selector(isMouseOverButtonPart)]); |
32 if ([reinterpret_cast<DownloadItemCell*>(cell) isMouseOverButtonPart]) { | 32 if ([reinterpret_cast<DownloadItemCell*>(cell) isMouseOverButtonPart]) { |
33 [super mouseDown:event]; | 33 [self.draggableButton mouseDown:event]; |
34 } else { | 34 } else { |
35 // Hold a reference to our controller in case the download completes and we | 35 // Hold a reference to our controller in case the download completes and we |
36 // represent a file that's auto-removed (e.g. a theme). | 36 // represent a file that's auto-removed (e.g. a theme). |
37 scoped_nsobject<DownloadItemController> ref([controller_ retain]); | 37 scoped_nsobject<DownloadItemController> ref([controller_ retain]); |
38 [cell setHighlighted:YES]; | 38 [cell setHighlighted:YES]; |
39 [[self menu] setDelegate:self]; | 39 [[self menu] setDelegate:self]; |
40 [NSMenu popUpContextMenu:[self menu] | 40 [NSMenu popUpContextMenu:[self menu] |
41 withEvent:[NSApp currentEvent] | 41 withEvent:[NSApp currentEvent] |
42 forView:self]; | 42 forView:self]; |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 - (void)menuDidClose:(NSMenu*)menu { | 46 - (void)menuDidClose:(NSMenu*)menu { |
47 [[self cell] setHighlighted:NO]; | 47 [[self cell] setHighlighted:NO]; |
48 } | 48 } |
49 | 49 |
50 - (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent*)event { | 50 - (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent*)event { |
51 return YES; | 51 return YES; |
52 } | 52 } |
53 | 53 |
54 @end | 54 @end |
OLD | NEW |