OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/net/dns_global.h" | 10 #include "chrome/browser/net/dns_global.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 if (!is_disabling && (hovered_line_ != selected_line_)) | 88 if (!is_disabling && (hovered_line_ != selected_line_)) |
89 view_->InvalidateLine(hovered_line_); | 89 view_->InvalidateLine(hovered_line_); |
90 | 90 |
91 if (is_enabling || is_disabling) | 91 if (is_enabling || is_disabling) |
92 view_->OnHoverEnabledOrDisabled(is_disabling); | 92 view_->OnHoverEnabledOrDisabled(is_disabling); |
93 } | 93 } |
94 | 94 |
95 void AutocompletePopupModel::SetSelectedLine(size_t line, | 95 void AutocompletePopupModel::SetSelectedLine(size_t line, |
96 bool reset_to_default) { | 96 bool reset_to_default) { |
97 const AutocompleteResult& result = controller_->result(); | 97 const AutocompleteResult& result = controller_->result(); |
98 DCHECK(line < result.size()); | 98 CHECK(line < result.size()); |
99 if (result.empty()) | 99 if (result.empty()) |
100 return; | 100 return; |
101 | 101 |
102 // Cancel the query so the matches don't change on the user. | 102 // Cancel the query so the matches don't change on the user. |
103 controller_->Stop(false); | 103 controller_->Stop(false); |
104 | 104 |
105 const AutocompleteMatch& match = result.match_at(line); | 105 const AutocompleteMatch& match = result.match_at(line); |
106 if (reset_to_default) { | 106 if (reset_to_default) { |
107 manually_selected_match_.Clear(); | 107 manually_selected_match_.Clear(); |
108 } else { | 108 } else { |
(...skipping 26 matching lines...) Expand all Loading... |
135 // selected line. | 135 // selected line. |
136 CHECK(selected_line_ != kNoMatch); | 136 CHECK(selected_line_ != kNoMatch); |
137 view_->InvalidateLine(selected_line_); | 137 view_->InvalidateLine(selected_line_); |
138 selected_line_ = line; | 138 selected_line_ = line; |
139 view_->InvalidateLine(selected_line_); | 139 view_->InvalidateLine(selected_line_); |
140 view_->PaintUpdatesNow(); | 140 view_->PaintUpdatesNow(); |
141 } | 141 } |
142 | 142 |
143 void AutocompletePopupModel::ResetToDefaultMatch() { | 143 void AutocompletePopupModel::ResetToDefaultMatch() { |
144 const AutocompleteResult& result = controller_->result(); | 144 const AutocompleteResult& result = controller_->result(); |
145 DCHECK(!result.empty()); | 145 CHECK(!result.empty()); |
146 SetSelectedLine(result.default_match() - result.begin(), true); | 146 SetSelectedLine(result.default_match() - result.begin(), true); |
147 } | 147 } |
148 | 148 |
149 GURL AutocompletePopupModel::URLsForCurrentSelection( | 149 GURL AutocompletePopupModel::URLsForCurrentSelection( |
150 PageTransition::Type* transition, | 150 PageTransition::Type* transition, |
151 bool* is_history_what_you_typed_match, | 151 bool* is_history_what_you_typed_match, |
152 GURL* alternate_nav_url) const { | 152 GURL* alternate_nav_url) const { |
153 const AutocompleteResult* result; | 153 const AutocompleteResult* result; |
154 AutocompleteResult::const_iterator match; | 154 AutocompleteResult::const_iterator match; |
155 if (!controller_->done()) { | 155 if (!controller_->done()) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 } | 354 } |
355 edit_model_->OnPopupDataChanged(inline_autocomplete_text, false, keyword, | 355 edit_model_->OnPopupDataChanged(inline_autocomplete_text, false, keyword, |
356 is_keyword_hint, type); | 356 is_keyword_hint, type); |
357 return; | 357 return; |
358 } | 358 } |
359 | 359 |
360 default: | 360 default: |
361 NOTREACHED(); | 361 NOTREACHED(); |
362 } | 362 } |
363 } | 363 } |
OLD | NEW |