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/autocomplete/autocomplete_result.h" | 5 #include "chrome/browser/autocomplete/autocomplete_result.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // score of 0. | 187 // score of 0. |
188 size_t num_matches; | 188 size_t num_matches; |
189 for (num_matches = 0u; (num_matches < max_num_matches) && | 189 for (num_matches = 0u; (num_matches < max_num_matches) && |
190 (comparing_object.GetDemotedRelevance(*match_at(num_matches)) > 0); | 190 (comparing_object.GetDemotedRelevance(*match_at(num_matches)) > 0); |
191 ++num_matches) {} | 191 ++num_matches) {} |
192 matches_.resize(num_matches); | 192 matches_.resize(num_matches); |
193 | 193 |
194 default_match_ = matches_.begin(); | 194 default_match_ = matches_.begin(); |
195 | 195 |
196 if (default_match_ != matches_.end()) { | 196 if (default_match_ != matches_.end()) { |
197 const base::string16 debug_info = ASCIIToUTF16("fill_into_edit=") + | 197 const base::string16 debug_info = |
198 default_match_->fill_into_edit + ASCIIToUTF16(", provider=") + | 198 base::ASCIIToUTF16("fill_into_edit=") + |
199 ((default_match_->provider != NULL) ? | 199 default_match_->fill_into_edit + |
200 ASCIIToUTF16(default_match_->provider->GetName()) : base::string16()) + | 200 base::ASCIIToUTF16(", provider=") + |
201 ASCIIToUTF16(", input=") + input.text(); | 201 ((default_match_->provider != NULL) |
| 202 ? base::ASCIIToUTF16(default_match_->provider->GetName()) |
| 203 : base::string16()) + |
| 204 base::ASCIIToUTF16(", input=") + |
| 205 input.text(); |
202 DCHECK(default_match_->allowed_to_be_default_match) << debug_info; | 206 DCHECK(default_match_->allowed_to_be_default_match) << debug_info; |
203 // We shouldn't get query matches for URL inputs, or non-query matches | 207 // We shouldn't get query matches for URL inputs, or non-query matches |
204 // for query inputs. | 208 // for query inputs. |
205 if (AutocompleteMatch::IsSearchType(default_match_->type)) { | 209 if (AutocompleteMatch::IsSearchType(default_match_->type)) { |
206 DCHECK_NE(AutocompleteInput::URL, input.type()) << debug_info; | 210 DCHECK_NE(AutocompleteInput::URL, input.type()) << debug_info; |
207 } else { | 211 } else { |
208 DCHECK_NE(AutocompleteInput::FORCED_QUERY, input.type()) << debug_info; | 212 DCHECK_NE(AutocompleteInput::FORCED_QUERY, input.type()) << debug_info; |
209 } | 213 } |
210 } | 214 } |
211 | 215 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 i != old_matches.rend() && delta > 0; ++i) { | 372 i != old_matches.rend() && delta > 0; ++i) { |
369 if (!HasMatchByDestination(*i, new_matches)) { | 373 if (!HasMatchByDestination(*i, new_matches)) { |
370 AutocompleteMatch match = *i; | 374 AutocompleteMatch match = *i; |
371 match.relevance = std::min(max_relevance, match.relevance); | 375 match.relevance = std::min(max_relevance, match.relevance); |
372 match.from_previous = true; | 376 match.from_previous = true; |
373 AddMatch(page_classification, match); | 377 AddMatch(page_classification, match); |
374 delta--; | 378 delta--; |
375 } | 379 } |
376 } | 380 } |
377 } | 381 } |
OLD | NEW |