autocomplete_text_field_editor.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
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.
4
5#import <Cocoa/Cocoa.h>
6
7#include "base/memory/scoped_nsobject.h"
8#import "chrome/browser/ui/cocoa/url_drop_target.h"
9
10@class AutocompleteTextField;
11class AutocompleteTextFieldObserver;
12
13// AutocompleteTextFieldEditor customized the AutocompletTextField
14// field editor (helper text-view used in editing).  It intercepts UI
15// events for forwarding to the core Omnibox code.  It also undoes
16// some of the effects of using styled text in the Omnibox (the text
17// is styled but should not appear that way when copied to the
18// pasteboard).
19
20// Field editor used for the autocomplete field.
21@interface AutocompleteTextFieldEditor : NSTextView<URLDropTarget> {
22  // Handles being a drag-and-drop target. We handle DnD directly instead
23  // allowing the |AutocompletTextField| to handle it (by making an empty
24  // |-updateDragTypeRegistration|), since the latter results in a weird
25  // start-up time regression.
26  scoped_nsobject<URLDropTargetHandler> dropHandler_;
27
28  scoped_nsobject<NSCharacterSet> forbiddenCharacters_;
29
30  // Indicates if the field editor's interpretKeyEvents: method is being called.
31  // If it's YES, then we should postpone the call to the observer's
32  // OnDidChange() method after the field editor's interpretKeyEvents: method
33  // is finished, rather than calling it in textDidChange: method. Because the
34  // input method may update the marked text after inserting some text, but we
35  // need the observer be aware of the marked text as well.
36  BOOL interpretingKeyEvents_;
37
38  // Indicates if the text has been changed by key events.
39  BOOL textChangedByKeyEvents_;
40}
41
42// The delegate is always an AutocompleteTextField*.  Override the superclass
43// implementations to allow for proper typing.
44- (AutocompleteTextField*)delegate;
45- (void)setDelegate:(AutocompleteTextField*)delegate;
46
47// Sets attributed string programatically through the field editor's text
48// storage object.
49- (void)setAttributedString:(NSAttributedString*)aString;
50
51@end
52
53@interface AutocompleteTextFieldEditor(PrivateTestMethods)
54- (AutocompleteTextFieldObserver*)observer;
55- (void)pasteAndGo:sender;
56- (void)copyURL:sender;
57@end
58