OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/omnibox/browser/autocomplete_result.h" | 5 #include "components/omnibox/browser/autocomplete_result.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "components/metrics/proto/omnibox_event.pb.h" | 13 #include "components/metrics/proto/omnibox_event.pb.h" |
14 #include "components/metrics/proto/omnibox_input_type.pb.h" | 14 #include "components/metrics/proto/omnibox_input_type.pb.h" |
15 #include "components/omnibox/browser/autocomplete_input.h" | 15 #include "components/omnibox/browser/autocomplete_input.h" |
16 #include "components/omnibox/browser/autocomplete_match.h" | 16 #include "components/omnibox/browser/autocomplete_match.h" |
17 #include "components/omnibox/browser/autocomplete_provider.h" | 17 #include "components/omnibox/browser/autocomplete_provider.h" |
18 #include "components/omnibox/browser/omnibox_field_trial.h" | 18 #include "components/omnibox/browser/omnibox_field_trial.h" |
19 #include "components/omnibox/browser/omnibox_switches.h" | 19 #include "components/omnibox/browser/omnibox_switches.h" |
20 #include "components/search/search.h" | 20 #include "components/search/search.h" |
21 #include "components/url_fixer/url_fixer.h" | 21 #include "components/url_formatter/url_fixer.h" |
22 | 22 |
23 using metrics::OmniboxEventProto; | 23 using metrics::OmniboxEventProto; |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // This class implements a special version of AutocompleteMatch::MoreRelevant | 27 // This class implements a special version of AutocompleteMatch::MoreRelevant |
28 // that allows matches of particular types to be demoted in AutocompleteResult. | 28 // that allows matches of particular types to be demoted in AutocompleteResult. |
29 class CompareWithDemoteByType { | 29 class CompareWithDemoteByType { |
30 public: | 30 public: |
31 CompareWithDemoteByType( | 31 CompareWithDemoteByType( |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } else { | 243 } else { |
244 DCHECK_NE(metrics::OmniboxInputType::FORCED_QUERY, input.type()) | 244 DCHECK_NE(metrics::OmniboxInputType::FORCED_QUERY, input.type()) |
245 << debug_info; | 245 << debug_info; |
246 // If the user explicitly typed a scheme, the default match should | 246 // If the user explicitly typed a scheme, the default match should |
247 // have the same scheme. | 247 // have the same scheme. |
248 if ((input.type() == metrics::OmniboxInputType::URL) && | 248 if ((input.type() == metrics::OmniboxInputType::URL) && |
249 input.parts().scheme.is_nonempty()) { | 249 input.parts().scheme.is_nonempty()) { |
250 const std::string& in_scheme = base::UTF16ToUTF8(input.scheme()); | 250 const std::string& in_scheme = base::UTF16ToUTF8(input.scheme()); |
251 const std::string& dest_scheme = | 251 const std::string& dest_scheme = |
252 default_match_->destination_url.scheme(); | 252 default_match_->destination_url.scheme(); |
253 DCHECK(url_fixer::IsEquivalentScheme(in_scheme, dest_scheme)) | 253 DCHECK(url_formatter::IsEquivalentScheme(in_scheme, dest_scheme)) |
254 << debug_info; | 254 << debug_info; |
255 } | 255 } |
256 } | 256 } |
257 } | 257 } |
258 } | 258 } |
259 | 259 |
260 // Set the alternate nav URL. | 260 // Set the alternate nav URL. |
261 alternate_nav_url_ = (default_match_ == matches_.end()) ? | 261 alternate_nav_url_ = (default_match_ == matches_.end()) ? |
262 GURL() : ComputeAlternateNavUrl(input, *default_match_); | 262 GURL() : ComputeAlternateNavUrl(input, *default_match_); |
263 } | 263 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 i != old_matches.rend() && delta > 0; ++i) { | 448 i != old_matches.rend() && delta > 0; ++i) { |
449 if (!HasMatchByDestination(*i, new_matches)) { | 449 if (!HasMatchByDestination(*i, new_matches)) { |
450 AutocompleteMatch match = *i; | 450 AutocompleteMatch match = *i; |
451 match.relevance = std::min(max_relevance, match.relevance); | 451 match.relevance = std::min(max_relevance, match.relevance); |
452 match.from_previous = true; | 452 match.from_previous = true; |
453 matches_.push_back(match); | 453 matches_.push_back(match); |
454 delta--; | 454 delta--; |
455 } | 455 } |
456 } | 456 } |
457 } | 457 } |
OLD | NEW |