summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa/find_bar_text_field.mm
blob: 805fca36543319a0b7cca97eead3384508b80ec5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "chrome/browser/ui/cocoa/find_bar_text_field.h"

#include "base/logging.h"
#import "chrome/browser/ui/cocoa/find_bar_text_field_cell.h"
#import "chrome/browser/ui/cocoa/view_id_util.h"

@implementation FindBarTextField

+ (Class)cellClass {
  return [FindBarTextFieldCell class];
}

- (void)awakeFromNib {
  DCHECK([[self cell] isKindOfClass:[FindBarTextFieldCell class]]);

  [self registerForDraggedTypes:
          [NSArray arrayWithObjects:NSStringPboardType, nil]];
}

- (FindBarTextFieldCell*)findBarTextFieldCell {
  DCHECK([[self cell] isKindOfClass:[FindBarTextFieldCell class]]);
  return static_cast<FindBarTextFieldCell*>([self cell]);
}

- (ViewID)viewID {
  return VIEW_ID_FIND_IN_PAGE_TEXT_FIELD;
}

- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)info {
  // When a drag enters the text field, focus the field.  This will swap in the
  // field editor, which will then handle the drag itself.
  [[self window] makeFirstResponder:self];
  return NSDragOperationNone;
}

@end