Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/cocoa/autocomplete_text_field.h

Issue 211030: [Mac] Expose AutocompleteEditViewMac to Cocoa code. (Closed)
Patch Set: Rohit's comments Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_ 5 #ifndef CHROME_BROWSER_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_
6 #define CHROME_BROWSER_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_ 6 #define CHROME_BROWSER_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 @class AutocompleteTextFieldCell; 10 @class AutocompleteTextFieldCell;
11 11
12 // AutocompleteTextField intercepts UI actions for forwarding to 12 // AutocompleteTextField intercepts UI actions for forwarding to
13 // AutocompleteEditViewMac (*), and provides a custom look. It works 13 // AutocompleteEditViewMac (*), and provides a custom look. It works
14 // together with AutocompleteTextFieldEditor (mostly for intercepting 14 // together with AutocompleteTextFieldEditor (mostly for intercepting
15 // user actions) and AutocompleteTextFieldCell (mostly for custom 15 // user actions) and AutocompleteTextFieldCell (mostly for custom
16 // drawing). 16 // drawing).
17 // 17 //
18 // For historical reasons, chrome/browser/autocomplete is the core 18 // For historical reasons, chrome/browser/autocomplete is the core
19 // implementation of the Omnibox. Chrome code seems to vary between 19 // implementation of the Omnibox. Chrome code seems to vary between
20 // autocomplete and Omnibox in describing this. 20 // autocomplete and Omnibox in describing this.
21 // 21 //
22 // (*) AutocompleteEditViewMac is a view in the MVC sense for the 22 // (*) AutocompleteEditViewMac is a view in the MVC sense for the
23 // Chrome internals, though it's really more of a mish-mash of model, 23 // Chrome internals, though it's really more of a mish-mash of model,
24 // view, and controller. 24 // view, and controller.
25 25
26 // AutocompleteTextFieldDelegateMethods are meant to be similar to 26 // Provides a hook so that we can call directly down to
27 // NSControl delegate methods, adding additional intercepts relevant 27 // AutocompleteEditViewMac rather than traversing the delegate chain.
28 // to the Omnibox implementation. 28
29 class AutocompleteTextFieldObserver {
30 public:
31
32 // Called when the control-key state changes while the field is
33 // first responder.
34 virtual void OnControlKeyChanged(bool pressed) = 0;
35
36 // Called when the user pastes into the field.
37 virtual void OnPaste() = 0;
38 };
29 39
30 @protocol AutocompleteTextFieldDelegateMethods 40 @protocol AutocompleteTextFieldDelegateMethods
31
32 // Delegate -textShouldPaste: implementation to the field being
33 // edited. See AutocompleteTextFieldEditor implementation.
34 - (BOOL)control:(NSControl*)control textShouldPaste:(NSText*)fieldEditor;
35
36 // Returns nil if paste actions are not supported. 41 // Returns nil if paste actions are not supported.
37 - (NSString*)control:(NSControl*)control 42 - (NSString*)control:(NSControl*)control
38 textPasteActionString:(NSText*)fieldEditor; 43 textPasteActionString:(NSText*)fieldEditor;
39 - (void)control:(NSControl*)control textDidPasteAndGo:(NSText*)fieldEditor; 44 - (void)control:(NSControl*)control textDidPasteAndGo:(NSText*)fieldEditor;
40
41 // Let the delegate track -flagsChanged: events.
42 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent;
43
44 @end 45 @end
45 46
46 @interface AutocompleteTextField : NSTextField { 47 @interface AutocompleteTextField : NSTextField {
48 @private
49 AutocompleteTextFieldObserver* observer_; // weak, owned by location bar.
47 } 50 }
48 51
49 - (BOOL)textShouldPaste:(NSText*)fieldEditor; 52 @property AutocompleteTextFieldObserver* observer;
50 53
51 // Convenience method to return the cell, casted appropriately. 54 // Convenience method to return the cell, casted appropriately.
52 - (AutocompleteTextFieldCell*)autocompleteTextFieldCell; 55 - (AutocompleteTextFieldCell*)autocompleteTextFieldCell;
53 56
54 // If the keyword, keyword hint, or search hint changed, then the 57 // If the keyword, keyword hint, or search hint changed, then the
55 // field needs to be relaidout. This accomplishes that in a manner 58 // field needs to be relaidout. This accomplishes that in a manner
56 // which doesn't disrupt the field delegate. 59 // which doesn't disrupt the field delegate.
57 - (void)resetFieldEditorFrameIfNeeded; 60 - (void)resetFieldEditorFrameIfNeeded;
58 61
59 @end 62 @end
60 63
61 #endif // CHROME_BROWSER_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_ 64 #endif // CHROME_BROWSER_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_mac.mm ('k') | chrome/browser/cocoa/autocomplete_text_field.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698