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