OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_ |
6 #define CHROME_BROWSER_UI_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_ | 6 #define CHROME_BROWSER_UI_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // Return |true| if there is a selection to copy. | 46 // Return |true| if there is a selection to copy. |
47 virtual bool CanCopy() = 0; | 47 virtual bool CanCopy() = 0; |
48 | 48 |
49 // Creates a pasteboard item from the field's current selection. | 49 // Creates a pasteboard item from the field's current selection. |
50 virtual base::scoped_nsobject<NSPasteboardItem> CreatePasteboardItem() = 0; | 50 virtual base::scoped_nsobject<NSPasteboardItem> CreatePasteboardItem() = 0; |
51 | 51 |
52 // Copies the pasteboard item returned from |CreatePasteboardItem()| to | 52 // Copies the pasteboard item returned from |CreatePasteboardItem()| to |
53 // |pboard|. | 53 // |pboard|. |
54 virtual void CopyToPasteboard(NSPasteboard* pboard) = 0; | 54 virtual void CopyToPasteboard(NSPasteboard* pboard) = 0; |
55 | 55 |
56 // Returns true if the Show URL option should be available. | |
57 virtual bool ShouldEnableShowURL() = 0; | |
58 | |
59 // Shows the underlying URL. See OmniboxView::ShowURL(). | |
60 virtual void ShowURL() = 0; | |
61 | |
62 // Returns true if the current clipboard text supports paste and go | 56 // Returns true if the current clipboard text supports paste and go |
63 // (or paste and search). | 57 // (or paste and search). |
64 virtual bool CanPasteAndGo() = 0; | 58 virtual bool CanPasteAndGo() = 0; |
65 | 59 |
66 // Returns the appropriate "Paste and Go" or "Paste and Search" | 60 // Returns the appropriate "Paste and Go" or "Paste and Search" |
67 // context menu string, depending on what is currently in the | 61 // context menu string, depending on what is currently in the |
68 // clipboard. Must not be called unless CanPasteAndGo() returns | 62 // clipboard. Must not be called unless CanPasteAndGo() returns |
69 // true. | 63 // true. |
70 virtual int GetPasteActionStringId() = 0; | 64 virtual int GetPasteActionStringId() = 0; |
71 | 65 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 100 |
107 // Called whenever the autocomplete text field gets focused. | 101 // Called whenever the autocomplete text field gets focused. |
108 virtual void OnSetFocus(bool control_down) = 0; | 102 virtual void OnSetFocus(bool control_down) = 0; |
109 | 103 |
110 // Called whenever the autocomplete text field is losing focus. | 104 // Called whenever the autocomplete text field is losing focus. |
111 virtual void OnKillFocus() = 0; | 105 virtual void OnKillFocus() = 0; |
112 | 106 |
113 // Called before the text field handles a mouse down event. | 107 // Called before the text field handles a mouse down event. |
114 virtual void OnMouseDown(NSInteger button_number) = 0; | 108 virtual void OnMouseDown(NSInteger button_number) = 0; |
115 | 109 |
116 // Returns true if mouse down should select all. | |
117 virtual bool ShouldSelectAllOnMouseDown() = 0; | |
118 | |
119 protected: | 110 protected: |
120 virtual ~AutocompleteTextFieldObserver() {} | 111 virtual ~AutocompleteTextFieldObserver() {} |
121 }; | 112 }; |
122 | 113 |
123 @interface AutocompleteTextField : StyledTextField<NSTextViewDelegate, | 114 @interface AutocompleteTextField : StyledTextField<NSTextViewDelegate, |
124 URLDropTarget, | 115 URLDropTarget, |
125 ThemedWindowDrawing> { | 116 ThemedWindowDrawing> { |
126 @private | 117 @private |
127 // Undo manager for this text field. We use a specific instance rather than | 118 // Undo manager for this text field. We use a specific instance rather than |
128 // the standard undo manager in order to let us clear the undo stack at will. | 119 // the standard undo manager in order to let us clear the undo stack at will. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // Draw gray text suggestion in |controlView|. | 185 // Draw gray text suggestion in |controlView|. |
195 void DrawGrayTextAutocompletion(NSAttributedString* mainText, | 186 void DrawGrayTextAutocompletion(NSAttributedString* mainText, |
196 NSString* suggestText, | 187 NSString* suggestText, |
197 NSColor* suggestColor, | 188 NSColor* suggestColor, |
198 NSView* controlView, | 189 NSView* controlView, |
199 NSRect frame); | 190 NSRect frame); |
200 | 191 |
201 } // namespace autocomplete_text_field | 192 } // namespace autocomplete_text_field |
202 | 193 |
203 #endif // CHROME_BROWSER_UI_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_ | 194 #endif // CHROME_BROWSER_UI_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_ |
OLD | NEW |