OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/autocomplete/autocomplete_edit_view_mac.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" |
6 | 6 |
7 #include <Carbon/Carbon.h> // kVK_Return | 7 #include <Carbon/Carbon.h> // kVK_Return |
8 | 8 |
9 #include "app/mac/nsimage_cache.h" | 9 #include "app/mac/nsimage_cache.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // Destroy popup view before this object in case it tries to call us | 199 // Destroy popup view before this object in case it tries to call us |
200 // back in the destructor. Likewise for destroying the model before | 200 // back in the destructor. Likewise for destroying the model before |
201 // this object. | 201 // this object. |
202 popup_view_.reset(); | 202 popup_view_.reset(); |
203 model_.reset(); | 203 model_.reset(); |
204 | 204 |
205 // Disconnect from |field_|, it outlives this object. | 205 // Disconnect from |field_|, it outlives this object. |
206 [field_ setObserver:NULL]; | 206 [field_ setObserver:NULL]; |
207 } | 207 } |
208 | 208 |
| 209 AutocompleteEditModel* AutocompleteEditViewMac::model() { |
| 210 return model_.get(); |
| 211 } |
| 212 |
| 213 const AutocompleteEditModel* AutocompleteEditViewMac::model() const { |
| 214 return model_.get(); |
| 215 } |
| 216 |
209 void AutocompleteEditViewMac::SaveStateToTab(TabContents* tab) { | 217 void AutocompleteEditViewMac::SaveStateToTab(TabContents* tab) { |
210 DCHECK(tab); | 218 DCHECK(tab); |
211 | 219 |
212 const bool hasFocus = [field_ currentEditor] ? true : false; | 220 const bool hasFocus = [field_ currentEditor] ? true : false; |
213 | 221 |
214 NSRange range; | 222 NSRange range; |
215 if (hasFocus) { | 223 if (hasFocus) { |
216 range = GetSelectedRange(); | 224 range = GetSelectedRange(); |
217 } else { | 225 } else { |
218 // If we are not focussed, there is no selection. Manufacture | 226 // If we are not focussed, there is no selection. Manufacture |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 | 1108 |
1101 void AutocompleteEditViewMac::PlaceCaretAt(NSUInteger pos) { | 1109 void AutocompleteEditViewMac::PlaceCaretAt(NSUInteger pos) { |
1102 DCHECK(pos <= GetTextLength()); | 1110 DCHECK(pos <= GetTextLength()); |
1103 SetSelectedRange(NSMakeRange(pos, pos)); | 1111 SetSelectedRange(NSMakeRange(pos, pos)); |
1104 } | 1112 } |
1105 | 1113 |
1106 bool AutocompleteEditViewMac::IsCaretAtEnd() const { | 1114 bool AutocompleteEditViewMac::IsCaretAtEnd() const { |
1107 const NSRange selection = GetSelectedRange(); | 1115 const NSRange selection = GetSelectedRange(); |
1108 return selection.length == 0 && selection.location == GetTextLength(); | 1116 return selection.length == 0 && selection.location == GetTextLength(); |
1109 } | 1117 } |
OLD | NEW |