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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // Destroy popup view before this object in case it tries to call us | 200 // Destroy popup view before this object in case it tries to call us |
201 // back in the destructor. Likewise for destroying the model before | 201 // back in the destructor. Likewise for destroying the model before |
202 // this object. | 202 // this object. |
203 popup_view_.reset(); | 203 popup_view_.reset(); |
204 model_.reset(); | 204 model_.reset(); |
205 | 205 |
206 // Disconnect from |field_|, it outlives this object. | 206 // Disconnect from |field_|, it outlives this object. |
207 [field_ setObserver:NULL]; | 207 [field_ setObserver:NULL]; |
208 } | 208 } |
209 | 209 |
| 210 AutocompleteEditModel* AutocompleteEditViewMac::model() { |
| 211 return model_.get(); |
| 212 } |
| 213 |
| 214 const AutocompleteEditModel* AutocompleteEditViewMac::model() const { |
| 215 return model_.get(); |
| 216 } |
| 217 |
210 void AutocompleteEditViewMac::SaveStateToTab(TabContents* tab) { | 218 void AutocompleteEditViewMac::SaveStateToTab(TabContents* tab) { |
211 DCHECK(tab); | 219 DCHECK(tab); |
212 | 220 |
213 const bool hasFocus = [field_ currentEditor] ? true : false; | 221 const bool hasFocus = [field_ currentEditor] ? true : false; |
214 | 222 |
215 NSRange range; | 223 NSRange range; |
216 if (hasFocus) { | 224 if (hasFocus) { |
217 range = GetSelectedRange(); | 225 range = GetSelectedRange(); |
218 } else { | 226 } else { |
219 // If we are not focussed, there is no selection. Manufacture | 227 // If we are not focussed, there is no selection. Manufacture |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 | 1117 |
1110 void AutocompleteEditViewMac::PlaceCaretAt(NSUInteger pos) { | 1118 void AutocompleteEditViewMac::PlaceCaretAt(NSUInteger pos) { |
1111 DCHECK(pos <= GetTextLength()); | 1119 DCHECK(pos <= GetTextLength()); |
1112 SetSelectedRange(NSMakeRange(pos, pos)); | 1120 SetSelectedRange(NSMakeRange(pos, pos)); |
1113 } | 1121 } |
1114 | 1122 |
1115 bool AutocompleteEditViewMac::IsCaretAtEnd() const { | 1123 bool AutocompleteEditViewMac::IsCaretAtEnd() const { |
1116 const NSRange selection = GetSelectedRange(); | 1124 const NSRange selection = GetSelectedRange(); |
1117 return selection.length == 0 && selection.location == GetTextLength(); | 1125 return selection.length == 0 && selection.location == GetTextLength(); |
1118 } | 1126 } |
OLD | NEW |