Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / find_bar / find_bar_text_field.mm
blob3216d795fb7343637790a5863185092e80121bfc
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.
5 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field.h"
7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h"
9 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field_cell.h"
10 #import "chrome/browser/ui/cocoa/view_id_util.h"
12 @implementation FindBarTextField
14 + (Class)cellClass {
15   return [FindBarTextFieldCell class];
18 - (void)awakeFromNib {
19   DCHECK([[self cell] isKindOfClass:[FindBarTextFieldCell class]]);
21   [self registerForDraggedTypes:
22           [NSArray arrayWithObjects:NSStringPboardType, nil]];
25 - (FindBarTextFieldCell*)findBarTextFieldCell {
26   DCHECK([[self cell] isKindOfClass:[FindBarTextFieldCell class]]);
27   return static_cast<FindBarTextFieldCell*>([self cell]);
30 - (ViewID)viewID {
31   return VIEW_ID_FIND_IN_PAGE_TEXT_FIELD;
34 - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)info {
35   // When a drag enters the text field, focus the field.  This will swap in the
36   // field editor, which will then handle the drag itself.
37   [[self window] makeFirstResponder:self];
38   return NSDragOperationNone;
41 // Disable default automated replacements, see <http://crbug.com/173405>.
42 - (void)textDidBeginEditing:(NSNotification*)aNotification {
43   // NSTextDidBeginEditingNotification is from NSText, but this only
44   // applies to NSTextView instances.
45   NSTextView* textView =
46       base::mac::ObjCCast<NSTextView>([aNotification object]);
47   NSTextCheckingTypes checkingTypes = [textView enabledTextCheckingTypes];
48   checkingTypes &= ~NSTextCheckingTypeReplacement;
49   checkingTypes &= ~NSTextCheckingTypeCorrection;
50   [textView setEnabledTextCheckingTypes:checkingTypes];
53 // Implemented to allow the findbar to respond to "Paste and Match Style" menu
54 // commands.
55 - (void)pasteAndMatchStyle:(id)sender {
56   [[self currentEditor] paste:sender];
59 @end