OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/omnibox/omnibox_popup_model.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 view_->InvalidateLine(selected_line_); | 104 view_->InvalidateLine(selected_line_); |
105 | 105 |
106 // Update the edit with the new data for this match. | 106 // Update the edit with the new data for this match. |
107 // TODO(pkasting): If |selected_line_| moves to the controller, this can be | 107 // TODO(pkasting): If |selected_line_| moves to the controller, this can be |
108 // eliminated and just become a call to the observer on the edit. | 108 // eliminated and just become a call to the observer on the edit. |
109 string16 keyword; | 109 string16 keyword; |
110 bool is_keyword_hint; | 110 bool is_keyword_hint; |
111 match.GetKeywordUIState(edit_model_->profile(), &keyword, &is_keyword_hint); | 111 match.GetKeywordUIState(edit_model_->profile(), &keyword, &is_keyword_hint); |
112 | 112 |
113 if (reset_to_default) { | 113 if (reset_to_default) { |
114 string16 inline_autocomplete_text; | 114 edit_model_->OnPopupDataChanged(match.inline_autocompletion, NULL, |
115 if ((match.inline_autocomplete_offset != string16::npos) && | |
116 (match.inline_autocomplete_offset < match.fill_into_edit.length())) { | |
117 inline_autocomplete_text = | |
118 match.fill_into_edit.substr(match.inline_autocomplete_offset); | |
119 } | |
120 edit_model_->OnPopupDataChanged(inline_autocomplete_text, NULL, | |
121 keyword, is_keyword_hint); | 115 keyword, is_keyword_hint); |
122 } else { | 116 } else { |
123 edit_model_->OnPopupDataChanged(match.fill_into_edit, ¤t_destination, | 117 edit_model_->OnPopupDataChanged(match.fill_into_edit, ¤t_destination, |
124 keyword, is_keyword_hint); | 118 keyword, is_keyword_hint); |
125 } | 119 } |
126 | 120 |
127 // Repaint old and new selected lines immediately, so that the edit doesn't | 121 // Repaint old and new selected lines immediately, so that the edit doesn't |
128 // appear to update [much] faster than the popup. | 122 // appear to update [much] faster than the popup. |
129 view_->PaintUpdatesNow(); | 123 view_->PaintUpdatesNow(); |
130 } | 124 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 222 } |
229 } | 223 } |
230 | 224 |
231 void OmniboxPopupModel::AddObserver(OmniboxPopupModelObserver* observer) { | 225 void OmniboxPopupModel::AddObserver(OmniboxPopupModelObserver* observer) { |
232 observers_.AddObserver(observer); | 226 observers_.AddObserver(observer); |
233 } | 227 } |
234 | 228 |
235 void OmniboxPopupModel::RemoveObserver(OmniboxPopupModelObserver* observer) { | 229 void OmniboxPopupModel::RemoveObserver(OmniboxPopupModelObserver* observer) { |
236 observers_.RemoveObserver(observer); | 230 observers_.RemoveObserver(observer); |
237 } | 231 } |
OLD | NEW |