| 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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 metrics::OmniboxEventProto::INVALID_SPEC, | 285 metrics::OmniboxEventProto::INVALID_SPEC, |
| 286 prevent_inline_autocomplete, false, true, true, | 286 prevent_inline_autocomplete, false, true, true, |
| 287 profile_.get()); | 287 profile_.get()); |
| 288 *identified_input_type = input.type(); | 288 *identified_input_type = input.type(); |
| 289 autocomplete_->Start(input, false); | 289 autocomplete_->Start(input, false); |
| 290 if (!autocomplete_->done()) | 290 if (!autocomplete_->done()) |
| 291 base::MessageLoop::current()->Run(); | 291 base::MessageLoop::current()->Run(); |
| 292 | 292 |
| 293 matches_ = autocomplete_->matches(); | 293 matches_ = autocomplete_->matches(); |
| 294 if (sort_matches_) { | 294 if (sort_matches_) { |
| 295 TemplateURLService* service = |
| 296 TemplateURLServiceFactory::GetForProfile(profile_.get()); |
| 295 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) | 297 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) |
| 296 i->ComputeStrippedDestinationURL(profile_.get()); | 298 i->ComputeStrippedDestinationURL(service); |
| 297 AutocompleteResult::DedupMatchesByDestination( | 299 AutocompleteResult::DedupMatchesByDestination( |
| 298 input.current_page_classification(), false, &matches_); | 300 input.current_page_classification(), false, &matches_); |
| 299 std::sort(matches_.begin(), matches_.end(), | 301 std::sort(matches_.begin(), matches_.end(), |
| 300 &AutocompleteMatch::MoreRelevant); | 302 &AutocompleteMatch::MoreRelevant); |
| 301 } | 303 } |
| 302 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text | 304 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text |
| 303 << "\nTLD: \"" << desired_tld << "\""; | 305 << "\nTLD: \"" << desired_tld << "\""; |
| 304 for (size_t i = 0; i < num_results; ++i) { | 306 for (size_t i = 0; i < num_results; ++i) { |
| 305 EXPECT_EQ(expected_urls[i].url, matches_[i].destination_url.spec()); | 307 EXPECT_EQ(expected_urls[i].url, matches_[i].destination_url.spec()); |
| 306 EXPECT_EQ(expected_urls[i].allowed_to_be_default_match, | 308 EXPECT_EQ(expected_urls[i].allowed_to_be_default_match, |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 autocomplete_->scoring_params_.experimental_scoring_enabled = true; | 1016 autocomplete_->scoring_params_.experimental_scoring_enabled = true; |
| 1015 ASSERT_NO_FATAL_FAILURE( | 1017 ASSERT_NO_FATAL_FAILURE( |
| 1016 RunTest(ASCIIToUTF16(test_cases[i].input), | 1018 RunTest(ASCIIToUTF16(test_cases[i].input), |
| 1017 base::string16(), false, output, max_matches)); | 1019 base::string16(), false, output, max_matches)); |
| 1018 for (int j = 0; j < max_matches; ++j) { | 1020 for (int j = 0; j < max_matches; ++j) { |
| 1019 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, | 1021 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, |
| 1020 matches_[j].relevance); | 1022 matches_[j].relevance); |
| 1021 } | 1023 } |
| 1022 } | 1024 } |
| 1023 } | 1025 } |
| OLD | NEW |