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/history_url_provider.h" | 5 #include "chrome/browser/autocomplete/history_url_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 size_t num_results) { | 239 size_t num_results) { |
240 AutocompleteInput input(text, desired_tld, prevent_inline_autocomplete, | 240 AutocompleteInput input(text, desired_tld, prevent_inline_autocomplete, |
241 false, true, AutocompleteInput::ALL_MATCHES); | 241 false, true, AutocompleteInput::ALL_MATCHES); |
242 autocomplete_->Start(input, false); | 242 autocomplete_->Start(input, false); |
243 if (!autocomplete_->done()) | 243 if (!autocomplete_->done()) |
244 MessageLoop::current()->Run(); | 244 MessageLoop::current()->Run(); |
245 | 245 |
246 matches_ = autocomplete_->matches(); | 246 matches_ = autocomplete_->matches(); |
247 if (sort_matches_) { | 247 if (sort_matches_) { |
248 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) | 248 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) |
249 i->ComputeStrippedDestinationURL(); | 249 i->ComputeStrippedDestinationURL(profile_.get()); |
250 std::sort(matches_.begin(), matches_.end(), | 250 std::sort(matches_.begin(), matches_.end(), |
251 &AutocompleteMatch::DestinationSortFunc); | 251 &AutocompleteMatch::DestinationSortFunc); |
252 matches_.erase(std::unique(matches_.begin(), matches_.end(), | 252 matches_.erase(std::unique(matches_.begin(), matches_.end(), |
253 &AutocompleteMatch::DestinationsEqual), | 253 &AutocompleteMatch::DestinationsEqual), |
254 matches_.end()); | 254 matches_.end()); |
255 std::sort(matches_.begin(), matches_.end(), | 255 std::sort(matches_.begin(), matches_.end(), |
256 &AutocompleteMatch::MoreRelevant); | 256 &AutocompleteMatch::MoreRelevant); |
257 } | 257 } |
258 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text | 258 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text |
259 << "\nTLD: \"" << desired_tld << "\""; | 259 << "\nTLD: \"" << desired_tld << "\""; |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 "\\@st" | 703 "\\@st" |
704 }; | 704 }; |
705 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 705 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
706 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16(), false, | 706 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16(), false, |
707 false, true, AutocompleteInput::ALL_MATCHES); | 707 false, true, AutocompleteInput::ALL_MATCHES); |
708 autocomplete_->Start(input, false); | 708 autocomplete_->Start(input, false); |
709 if (!autocomplete_->done()) | 709 if (!autocomplete_->done()) |
710 MessageLoop::current()->Run(); | 710 MessageLoop::current()->Run(); |
711 } | 711 } |
712 } | 712 } |
OLD | NEW |