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 TemplateURLService* service = | 162 match.GetKeywordUIState(edit_model_->profile(), &keyword, &is_keyword_hint); |
163 TemplateURLServiceFactory::GetForProfile(edit_model_->profile()); | |
164 match.GetKeywordUIState(service, &keyword, &is_keyword_hint); | |
165 | 163 |
166 if (reset_to_default) { | 164 if (reset_to_default) { |
167 edit_model_->OnPopupDataChanged(match.inline_autocompletion, NULL, | 165 edit_model_->OnPopupDataChanged(match.inline_autocompletion, NULL, |
168 keyword, is_keyword_hint); | 166 keyword, is_keyword_hint); |
169 } else { | 167 } else { |
170 edit_model_->OnPopupDataChanged(match.fill_into_edit, ¤t_destination, | 168 edit_model_->OnPopupDataChanged(match.fill_into_edit, ¤t_destination, |
171 keyword, is_keyword_hint); | 169 keyword, is_keyword_hint); |
172 } | 170 } |
173 | 171 |
174 // Repaint old and new selected lines immediately, so that the edit doesn't | 172 // 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... |
237 // before notifying us, reducing flicker. At that point the check for | 235 // before notifying us, reducing flicker. At that point the check for |
238 // deletability can move there too. | 236 // deletability can move there too. |
239 SetSelectedLine(selected_line, false, true); | 237 SetSelectedLine(selected_line, false, true); |
240 } | 238 } |
241 } | 239 } |
242 } | 240 } |
243 | 241 |
244 gfx::Image OmniboxPopupModel::GetIconIfExtensionMatch( | 242 gfx::Image OmniboxPopupModel::GetIconIfExtensionMatch( |
245 const AutocompleteMatch& match) const { | 243 const AutocompleteMatch& match) const { |
246 Profile* profile = edit_model_->profile(); | 244 Profile* profile = edit_model_->profile(); |
247 TemplateURLService* service = | 245 const TemplateURL* template_url = match.GetTemplateURL(profile, false); |
248 TemplateURLServiceFactory::GetForProfile(profile); | |
249 const TemplateURL* template_url = match.GetTemplateURL(service, false); | |
250 if (template_url && | 246 if (template_url && |
251 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { | 247 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { |
252 return extensions::OmniboxAPI::Get(profile)->GetOmniboxPopupIcon( | 248 return extensions::OmniboxAPI::Get(profile)->GetOmniboxPopupIcon( |
253 template_url->GetExtensionId()); | 249 template_url->GetExtensionId()); |
254 } | 250 } |
255 return gfx::Image(); | 251 return gfx::Image(); |
256 } | 252 } |
257 | 253 |
258 void OmniboxPopupModel::OnResultChanged() { | 254 void OmniboxPopupModel::OnResultChanged() { |
259 const AutocompleteResult& result = this->result(); | 255 const AutocompleteResult& result = this->result(); |
(...skipping 18 matching lines...) Expand all Loading... |
278 } | 274 } |
279 } | 275 } |
280 | 276 |
281 void OmniboxPopupModel::AddObserver(OmniboxPopupModelObserver* observer) { | 277 void OmniboxPopupModel::AddObserver(OmniboxPopupModelObserver* observer) { |
282 observers_.AddObserver(observer); | 278 observers_.AddObserver(observer); |
283 } | 279 } |
284 | 280 |
285 void OmniboxPopupModel::RemoveObserver(OmniboxPopupModelObserver* observer) { | 281 void OmniboxPopupModel::RemoveObserver(OmniboxPopupModelObserver* observer) { |
286 observers_.RemoveObserver(observer); | 282 observers_.RemoveObserver(observer); |
287 } | 283 } |
OLD | NEW |