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_popup_model.h" | 5 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 8 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
9 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 9 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 268 } |
269 | 269 |
270 void AutocompletePopupModel::Observe(NotificationType type, | 270 void AutocompletePopupModel::Observe(NotificationType type, |
271 const NotificationSource& source, | 271 const NotificationSource& source, |
272 const NotificationDetails& details) { | 272 const NotificationDetails& details) { |
273 DCHECK_EQ(NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED, | 273 DCHECK_EQ(NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED, |
274 type.value); | 274 type.value); |
275 | 275 |
276 const AutocompleteResult* result = | 276 const AutocompleteResult* result = |
277 Details<const AutocompleteResult>(details).ptr(); | 277 Details<const AutocompleteResult>(details).ptr(); |
278 selected_line_ = (result->default_match() == result->end()) ? | 278 selected_line_ = result->default_match() == result->end() ? |
279 kNoMatch : (result->default_match() - result->begin()); | 279 kNoMatch : static_cast<size_t>(result->default_match() - result->begin()); |
280 // There had better not be a nonempty result set with no default match. | 280 // There had better not be a nonempty result set with no default match. |
281 CHECK((selected_line_ != kNoMatch) || result->empty()); | 281 CHECK((selected_line_ != kNoMatch) || result->empty()); |
282 // If we're going to trim the window size to no longer include the hovered | 282 // If we're going to trim the window size to no longer include the hovered |
283 // line, turn hover off. Practically, this shouldn't happen, but it | 283 // line, turn hover off. Practically, this shouldn't happen, but it |
284 // doesn't hurt to be defensive. | 284 // doesn't hurt to be defensive. |
285 if ((hovered_line_ != kNoMatch) && (result->size() <= hovered_line_)) | 285 if ((hovered_line_ != kNoMatch) && (result->size() <= hovered_line_)) |
286 SetHoveredLine(kNoMatch); | 286 SetHoveredLine(kNoMatch); |
287 | 287 |
288 view_->UpdatePopupAppearance(); | 288 view_->UpdatePopupAppearance(); |
289 } | 289 } |
290 | 290 |
291 const SkBitmap* AutocompletePopupModel::GetSpecialIconForMatch( | 291 const SkBitmap* AutocompletePopupModel::GetSpecialIconForMatch( |
292 const AutocompleteMatch& match) const { | 292 const AutocompleteMatch& match) const { |
293 if (!match.template_url || !match.template_url->IsExtensionKeyword()) | 293 if (!match.template_url || !match.template_url->IsExtensionKeyword()) |
294 return NULL; | 294 return NULL; |
295 | 295 |
296 return &profile_->GetExtensionsService()->GetOmniboxIcon( | 296 return &profile_->GetExtensionsService()->GetOmniboxIcon( |
297 match.template_url->GetExtensionId()); | 297 match.template_url->GetExtensionId()); |
298 } | 298 } |
OLD | NEW |