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

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

Issue 207047: [Mac] Convert Omnibox paste-and-go to use AutocompleteTextFieldObserver. (Closed)
Patch Set: Oops - remove test before its time. 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 #include "chrome/browser/cocoa/autocomplete_text_field.h" 5 #include "chrome/browser/cocoa/autocomplete_text_field.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/cocoa/autocomplete_text_field_cell.h" 8 #include "chrome/browser/cocoa/autocomplete_text_field_cell.h"
9 9
10 @implementation AutocompleteTextField 10 @implementation AutocompleteTextField
11 11
12 @synthesize observer = observer_; 12 @synthesize observer = observer_;
13 13
14 + (Class)cellClass { 14 + (Class)cellClass {
15 return [AutocompleteTextFieldCell class]; 15 return [AutocompleteTextFieldCell class];
16 } 16 }
17 17
18 - (void)awakeFromNib { 18 - (void)awakeFromNib {
19 DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]); 19 DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]);
20 } 20 }
21 21
22 - (NSString*)textPasteActionString:(NSText*)fieldEditor {
23 id delegate = [self delegate];
24 if ([delegate respondsToSelector:@selector(control:textPasteActionString:)]) {
25 return [delegate control:self textPasteActionString:fieldEditor];
26 }
27 return nil;
28 }
29
30 - (void)textDidPasteAndGo:(NSText*)fieldEditor {
31 id delegate = [self delegate];
32 if ([delegate respondsToSelector:@selector(control:textDidPasteAndGo:)]) {
33 [delegate control:self textDidPasteAndGo:fieldEditor];
34 }
35 }
36
37 - (void)flagsChanged:(NSEvent*)theEvent { 22 - (void)flagsChanged:(NSEvent*)theEvent {
38 bool controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; 23 bool controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0;
39 observer_->OnControlKeyChanged(controlFlag); 24 observer_->OnControlKeyChanged(controlFlag);
40 } 25 }
41 26
42 - (AutocompleteTextFieldCell*)autocompleteTextFieldCell { 27 - (AutocompleteTextFieldCell*)autocompleteTextFieldCell {
43 DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]); 28 DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]);
44 return static_cast<AutocompleteTextFieldCell*>([self cell]); 29 return static_cast<AutocompleteTextFieldCell*>([self cell]);
45 } 30 }
46 31
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // field editor to the end of the content so that the selection 136 // field editor to the end of the content so that the selection
152 // doesn't initiate from somewhere in the middle of the text. 137 // doesn't initiate from somewhere in the middle of the text.
153 if (location.x > NSMaxX(textFrame)) { 138 if (location.x > NSMaxX(textFrame)) {
154 [editor scrollRangeToVisible:NSMakeRange([[self stringValue] length], 0)]; 139 [editor scrollRangeToVisible:NSMakeRange([[self stringValue] length], 0)];
155 } 140 }
156 141
157 [editor mouseDown:theEvent]; 142 [editor mouseDown:theEvent];
158 } 143 }
159 144
160 @end 145 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/autocomplete_text_field.h ('k') | chrome/browser/cocoa/autocomplete_text_field_editor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698