1 // Copyright (c) 2010 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. 4 5 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field.h" 6 7 #include "base/logging.h" 8 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field_cell.h" 9 #import "chrome/browser/ui/cocoa/view_id_util.h" 10 11 @implementation FindBarTextField 12 13 + (Class)cellClass { 14 return [FindBarTextFieldCell class]; 15 } 16 17 - (void)awakeFromNib { 18 DCHECK([[self cell] isKindOfClass:[FindBarTextFieldCell class]]); 19 20 [self registerForDraggedTypes: 21 [NSArray arrayWithObjects:NSStringPboardType, nil]]; 22 } 23 24 - (FindBarTextFieldCell*)findBarTextFieldCell { 25 DCHECK([[self cell] isKindOfClass:[FindBarTextFieldCell class]]); 26 return static_cast<FindBarTextFieldCell*>([self cell]); 27 } 28 29 - (ViewID)viewID { 30 return VIEW_ID_FIND_IN_PAGE_TEXT_FIELD; 31 } 32 33 - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)info { 34 // When a drag enters the text field, focus the field. This will swap in the 35 // field editor, which will then handle the drag itself. 36 [[self window] makeFirstResponder:self]; 37 return NSDragOperationNone; 38 } 39 40 @end 41