| OLD | NEW |
| 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 #import "chrome/browser/cocoa/styled_text_field.h" |
| 9 | 10 |
| 10 #include "base/scoped_nsobject.h" | 11 #include "base/scoped_nsobject.h" |
| 11 #import "chrome/browser/cocoa/styled_text_field.h" | |
| 12 #import "chrome/browser/cocoa/url_drop_target.h" | |
| 13 | 12 |
| 14 @class AutocompleteTextFieldCell; | 13 @class AutocompleteTextFieldCell; |
| 15 | 14 |
| 16 // AutocompleteTextField intercepts UI actions for forwarding to | 15 // AutocompleteTextField intercepts UI actions for forwarding to |
| 17 // AutocompleteEditViewMac (*), and provides a custom look. It works | 16 // AutocompleteEditViewMac (*), and provides a custom look. It works |
| 18 // together with AutocompleteTextFieldEditor (mostly for intercepting | 17 // together with AutocompleteTextFieldEditor (mostly for intercepting |
| 19 // user actions) and AutocompleteTextFieldCell (mostly for custom | 18 // user actions) and AutocompleteTextFieldCell (mostly for custom |
| 20 // drawing). | 19 // drawing). |
| 21 // | 20 // |
| 22 // For historical reasons, chrome/browser/autocomplete is the core | 21 // For historical reasons, chrome/browser/autocomplete is the core |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // return true if |cmd| is handled, false if the caller should | 68 // return true if |cmd| is handled, false if the caller should |
| 70 // handle it. | 69 // handle it. |
| 71 // TODO(shess): For now, I think having the code which makes these | 70 // TODO(shess): For now, I think having the code which makes these |
| 72 // decisions closer to the other autocomplete code is worthwhile, | 71 // decisions closer to the other autocomplete code is worthwhile, |
| 73 // since it calls a wide variety of methods which otherwise aren't | 72 // since it calls a wide variety of methods which otherwise aren't |
| 74 // clearly relevent to expose here. But consider pulling more of | 73 // clearly relevent to expose here. But consider pulling more of |
| 75 // the AutocompleteEditViewMac calls up to here. | 74 // the AutocompleteEditViewMac calls up to here. |
| 76 virtual bool OnDoCommandBySelector(SEL cmd) = 0; | 75 virtual bool OnDoCommandBySelector(SEL cmd) = 0; |
| 77 }; | 76 }; |
| 78 | 77 |
| 79 @interface AutocompleteTextField : StyledTextField<URLDropTarget> { | 78 @interface AutocompleteTextField : StyledTextField { |
| 80 @private | 79 @private |
| 81 // Undo manager for this text field. We use a specific instance rather than | 80 // Undo manager for this text field. We use a specific instance rather than |
| 82 // the standard undo manager in order to let us clear the undo stack at will. | 81 // the standard undo manager in order to let us clear the undo stack at will. |
| 83 scoped_nsobject<NSUndoManager> undoManager_; | 82 scoped_nsobject<NSUndoManager> undoManager_; |
| 84 | 83 |
| 85 AutocompleteTextFieldObserver* observer_; // weak, owned by location bar. | 84 AutocompleteTextFieldObserver* observer_; // weak, owned by location bar. |
| 86 | |
| 87 // Handles being a drag-and-drop target. | |
| 88 scoped_nsobject<URLDropTargetHandler> dropHandler_; | |
| 89 } | 85 } |
| 90 | 86 |
| 91 @property AutocompleteTextFieldObserver* observer; | 87 @property AutocompleteTextFieldObserver* observer; |
| 92 | 88 |
| 93 // Convenience method to return the cell, casted appropriately. | 89 // Convenience method to return the cell, casted appropriately. |
| 94 - (AutocompleteTextFieldCell*)autocompleteTextFieldCell; | 90 - (AutocompleteTextFieldCell*)autocompleteTextFieldCell; |
| 95 | 91 |
| 96 // Superclass aborts editing before changing the string, which causes | 92 // Superclass aborts editing before changing the string, which causes |
| 97 // problems for undo. This version modifies the field editor's | 93 // problems for undo. This version modifies the field editor's |
| 98 // contents if the control is already being edited. | 94 // contents if the control is already being edited. |
| 99 - (void)setAttributedStringValue:(NSAttributedString*)aString; | 95 - (void)setAttributedStringValue:(NSAttributedString*)aString; |
| 100 | 96 |
| 101 // Clears the undo chain for this text field. | 97 // Clears the undo chain for this text field. |
| 102 - (void)clearUndoChain; | 98 - (void)clearUndoChain; |
| 103 | 99 |
| 104 @end | 100 @end |
| 105 | 101 |
| 106 #endif // CHROME_BROWSER_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_ | 102 #endif // CHROME_BROWSER_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_ |
| OLD | NEW |