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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 selected_line_state_ = NORMAL; | 152 selected_line_state_ = NORMAL; |
153 selected_line_ = line; | 153 selected_line_ = line; |
154 view_->InvalidateLine(prev_selected_line); | 154 view_->InvalidateLine(prev_selected_line); |
155 view_->InvalidateLine(selected_line_); | 155 view_->InvalidateLine(selected_line_); |
156 | 156 |
157 // Update the edit with the new data for this match. | 157 // Update the edit with the new data for this match. |
158 // TODO(pkasting): If |selected_line_| moves to the controller, this can be | 158 // TODO(pkasting): If |selected_line_| moves to the controller, this can be |
159 // eliminated and just become a call to the observer on the edit. | 159 // eliminated and just become a call to the observer on the edit. |
160 base::string16 keyword; | 160 base::string16 keyword; |
161 bool is_keyword_hint; | 161 bool is_keyword_hint; |
162 match.GetKeywordUIState(edit_model_->profile(), &keyword, &is_keyword_hint); | 162 TemplateURLService* service = |
| 163 TemplateURLServiceFactory::GetForProfile(edit_model_->profile()); |
| 164 match.GetKeywordUIState(service, &keyword, &is_keyword_hint); |
163 | 165 |
164 if (reset_to_default) { | 166 if (reset_to_default) { |
165 edit_model_->OnPopupDataChanged(match.inline_autocompletion, NULL, | 167 edit_model_->OnPopupDataChanged(match.inline_autocompletion, NULL, |
166 keyword, is_keyword_hint); | 168 keyword, is_keyword_hint); |
167 } else { | 169 } else { |
168 edit_model_->OnPopupDataChanged(match.fill_into_edit, ¤t_destination, | 170 edit_model_->OnPopupDataChanged(match.fill_into_edit, ¤t_destination, |
169 keyword, is_keyword_hint); | 171 keyword, is_keyword_hint); |
170 } | 172 } |
171 | 173 |
172 // Repaint old and new selected lines immediately, so that the edit doesn't | 174 // Repaint old and new selected lines immediately, so that the edit doesn't |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // before notifying us, reducing flicker. At that point the check for | 237 // before notifying us, reducing flicker. At that point the check for |
236 // deletability can move there too. | 238 // deletability can move there too. |
237 SetSelectedLine(selected_line, false, true); | 239 SetSelectedLine(selected_line, false, true); |
238 } | 240 } |
239 } | 241 } |
240 } | 242 } |
241 | 243 |
242 gfx::Image OmniboxPopupModel::GetIconIfExtensionMatch( | 244 gfx::Image OmniboxPopupModel::GetIconIfExtensionMatch( |
243 const AutocompleteMatch& match) const { | 245 const AutocompleteMatch& match) const { |
244 Profile* profile = edit_model_->profile(); | 246 Profile* profile = edit_model_->profile(); |
245 const TemplateURL* template_url = match.GetTemplateURL(profile, false); | 247 TemplateURLService* service = |
| 248 TemplateURLServiceFactory::GetForProfile(profile); |
| 249 const TemplateURL* template_url = match.GetTemplateURL(service, false); |
246 if (template_url && | 250 if (template_url && |
247 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { | 251 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { |
248 return extensions::OmniboxAPI::Get(profile)->GetOmniboxPopupIcon( | 252 return extensions::OmniboxAPI::Get(profile)->GetOmniboxPopupIcon( |
249 template_url->GetExtensionId()); | 253 template_url->GetExtensionId()); |
250 } | 254 } |
251 return gfx::Image(); | 255 return gfx::Image(); |
252 } | 256 } |
253 | 257 |
254 void OmniboxPopupModel::OnResultChanged() { | 258 void OmniboxPopupModel::OnResultChanged() { |
255 const AutocompleteResult& result = this->result(); | 259 const AutocompleteResult& result = this->result(); |
(...skipping 18 matching lines...) Expand all Loading... |
274 } | 278 } |
275 } | 279 } |
276 | 280 |
277 void OmniboxPopupModel::AddObserver(OmniboxPopupModelObserver* observer) { | 281 void OmniboxPopupModel::AddObserver(OmniboxPopupModelObserver* observer) { |
278 observers_.AddObserver(observer); | 282 observers_.AddObserver(observer); |
279 } | 283 } |
280 | 284 |
281 void OmniboxPopupModel::RemoveObserver(OmniboxPopupModelObserver* observer) { | 285 void OmniboxPopupModel::RemoveObserver(OmniboxPopupModelObserver* observer) { |
282 observers_.RemoveObserver(observer); | 286 observers_.RemoveObserver(observer); |
283 } | 287 } |
OLD | NEW |