| 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 "unicode/ubidi.h" | 9 #include "unicode/ubidi.h" |
| 10 | 10 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // SetSelectedLine() will clamp to take care of the case where we deleted | 186 // SetSelectedLine() will clamp to take care of the case where we deleted |
| 187 // the last item. | 187 // the last item. |
| 188 // TODO(pkasting): Eventually the controller should take care of this | 188 // TODO(pkasting): Eventually the controller should take care of this |
| 189 // before notifying us, reducing flicker. At that point the check for | 189 // before notifying us, reducing flicker. At that point the check for |
| 190 // deletability can move there too. | 190 // deletability can move there too. |
| 191 SetSelectedLine(selected_line, false, true); | 191 SetSelectedLine(selected_line, false, true); |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 | 195 |
| 196 const SkBitmap* OmniboxPopupModel::GetIconIfExtensionMatch( | 196 gfx::Image OmniboxPopupModel::GetIconIfExtensionMatch( |
| 197 const AutocompleteMatch& match) const { | 197 const AutocompleteMatch& match) const { |
| 198 Profile* profile = edit_model_->profile(); | 198 Profile* profile = edit_model_->profile(); |
| 199 const TemplateURL* template_url = match.GetTemplateURL(profile); | 199 const TemplateURL* template_url = match.GetTemplateURL(profile); |
| 200 return (template_url && template_url->IsExtensionKeyword()) ? | 200 if (template_url && template_url->IsExtensionKeyword()) { |
| 201 &profile->GetExtensionService()->GetOmniboxPopupIcon( | 201 return profile->GetExtensionService()->GetOmniboxPopupIcon( |
| 202 template_url->GetExtensionId()) : NULL; | 202 template_url->GetExtensionId()); |
| 203 } |
| 204 return gfx::Image(); |
| 203 } | 205 } |
| 204 | 206 |
| 205 void OmniboxPopupModel::OnResultChanged() { | 207 void OmniboxPopupModel::OnResultChanged() { |
| 206 const AutocompleteResult& result = this->result(); | 208 const AutocompleteResult& result = this->result(); |
| 207 selected_line_ = result.default_match() == result.end() ? | 209 selected_line_ = result.default_match() == result.end() ? |
| 208 kNoMatch : static_cast<size_t>(result.default_match() - result.begin()); | 210 kNoMatch : static_cast<size_t>(result.default_match() - result.begin()); |
| 209 // There had better not be a nonempty result set with no default match. | 211 // There had better not be a nonempty result set with no default match. |
| 210 CHECK((selected_line_ != kNoMatch) || result.empty()); | 212 CHECK((selected_line_ != kNoMatch) || result.empty()); |
| 211 manually_selected_match_.Clear(); | 213 manually_selected_match_.Clear(); |
| 212 selected_line_state_ = NORMAL; | 214 selected_line_state_ = NORMAL; |
| 213 // If we're going to trim the window size to no longer include the hovered | 215 // If we're going to trim the window size to no longer include the hovered |
| 214 // line, turn hover off. Practically, this shouldn't happen, but it | 216 // line, turn hover off. Practically, this shouldn't happen, but it |
| 215 // doesn't hurt to be defensive. | 217 // doesn't hurt to be defensive. |
| 216 if ((hovered_line_ != kNoMatch) && (result.size() <= hovered_line_)) | 218 if ((hovered_line_ != kNoMatch) && (result.size() <= hovered_line_)) |
| 217 SetHoveredLine(kNoMatch); | 219 SetHoveredLine(kNoMatch); |
| 218 | 220 |
| 219 view_->UpdatePopupAppearance(); | 221 view_->UpdatePopupAppearance(); |
| 220 } | 222 } |
| OLD | NEW |