Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: components/omnibox/autocomplete_result.cc

Issue 1098843004: Omnibox - Do Not Allow HTTP/HTTPS Equivalence if User Explicitly Entered A Scheme (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no equivalence across schemes if any scheme is present Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/autocomplete_result.h" 5 #include "components/omnibox/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"
11 #include "base/strings/string_split.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "components/metrics/proto/omnibox_event.pb.h" 13 #include "components/metrics/proto/omnibox_event.pb.h"
13 #include "components/metrics/proto/omnibox_input_type.pb.h" 14 #include "components/metrics/proto/omnibox_input_type.pb.h"
14 #include "components/omnibox/autocomplete_input.h" 15 #include "components/omnibox/autocomplete_input.h"
15 #include "components/omnibox/autocomplete_match.h" 16 #include "components/omnibox/autocomplete_match.h"
16 #include "components/omnibox/autocomplete_provider.h" 17 #include "components/omnibox/autocomplete_provider.h"
17 #include "components/omnibox/omnibox_field_trial.h" 18 #include "components/omnibox/omnibox_field_trial.h"
18 #include "components/search/search.h" 19 #include "components/search/search.h"
19 #include "components/url_fixer/url_fixer.h" 20 #include "components/url_fixer/url_fixer.h"
20 21
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 171 }
171 #endif 172 #endif
172 std::copy(matches.begin(), matches.end(), std::back_inserter(matches_)); 173 std::copy(matches.begin(), matches.end(), std::back_inserter(matches_));
173 default_match_ = end(); 174 default_match_ = end();
174 alternate_nav_url_ = GURL(); 175 alternate_nav_url_ = GURL();
175 } 176 }
176 177
177 void AutocompleteResult::SortAndCull( 178 void AutocompleteResult::SortAndCull(
178 const AutocompleteInput& input, 179 const AutocompleteInput& input,
179 TemplateURLService* template_url_service) { 180 TemplateURLService* template_url_service) {
180 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) 181 std::vector<base::string16> words;
181 i->ComputeStrippedDestinationURL(template_url_service); 182 base::SplitString(input.text(), ' ', &words);
183 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) {
Peter Kasting 2015/06/01 21:04:08 Nit: No {}
Mark P 2015/06/04 23:31:31 Done.
184 i->ComputeStrippedDestinationURL(words, template_url_service);
185 }
182 186
183 DedupMatchesByDestination(input.current_page_classification(), true, 187 DedupMatchesByDestination(input.current_page_classification(), true,
184 &matches_); 188 &matches_);
185 189
186 // Sort and trim to the most relevant kMaxMatches matches. 190 // Sort and trim to the most relevant kMaxMatches matches.
187 size_t max_num_matches = std::min(kMaxMatches, matches_.size()); 191 size_t max_num_matches = std::min(kMaxMatches, matches_.size());
188 CompareWithDemoteByType comparing_object(input.current_page_classification()); 192 CompareWithDemoteByType comparing_object(input.current_page_classification());
189 std::sort(matches_.begin(), matches_.end(), comparing_object); 193 std::sort(matches_.begin(), matches_.end(), comparing_object);
190 if (!matches_.empty() && !matches_.begin()->allowed_to_be_default_match) { 194 if (!matches_.empty() && !matches_.begin()->allowed_to_be_default_match) {
191 // Top match is not allowed to be the default match. Find the most 195 // Top match is not allowed to be the default match. Find the most
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 i != old_matches.rend() && delta > 0; ++i) { 444 i != old_matches.rend() && delta > 0; ++i) {
441 if (!HasMatchByDestination(*i, new_matches)) { 445 if (!HasMatchByDestination(*i, new_matches)) {
442 AutocompleteMatch match = *i; 446 AutocompleteMatch match = *i;
443 match.relevance = std::min(max_relevance, match.relevance); 447 match.relevance = std::min(max_relevance, match.relevance);
444 match.from_previous = true; 448 match.from_previous = true;
445 matches_.push_back(match); 449 matches_.push_back(match);
446 delta--; 450 delta--;
447 } 451 }
448 } 452 }
449 } 453 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698