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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_result.cc

Issue 353223002: Omnibox: Fix URL-What-You-Typed Allowed-To-Be-Default-Match Issues (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove some test cases; add dcheck Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
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/i18n/case_conversion.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/autocomplete/autocomplete_match.h" 14 #include "chrome/browser/autocomplete/autocomplete_match.h"
14 #include "chrome/browser/autocomplete/autocomplete_provider.h" 15 #include "chrome/browser/autocomplete/autocomplete_provider.h"
15 #include "chrome/browser/omnibox/omnibox_field_trial.h" 16 #include "chrome/browser/omnibox/omnibox_field_trial.h"
16 #include "chrome/browser/search/search.h" 17 #include "chrome/browser/search/search.h"
17 #include "chrome/common/autocomplete_match_type.h" 18 #include "chrome/common/autocomplete_match_type.h"
18 #include "components/autocomplete/autocomplete_input.h" 19 #include "components/autocomplete/autocomplete_input.h"
19 #include "components/metrics/proto/omnibox_event.pb.h" 20 #include "components/metrics/proto/omnibox_event.pb.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // sure the type of destination is what the user would expect given the 258 // sure the type of destination is what the user would expect given the
258 // input. 259 // input.
259 if (default_match_->destination_url.is_valid()) { 260 if (default_match_->destination_url.is_valid()) {
260 // We shouldn't get query matches for URL inputs, or non-query matches 261 // We shouldn't get query matches for URL inputs, or non-query matches
261 // for query inputs. 262 // for query inputs.
262 if (AutocompleteMatch::IsSearchType(default_match_->type)) { 263 if (AutocompleteMatch::IsSearchType(default_match_->type)) {
263 DCHECK_NE(metrics::OmniboxInputType::URL, input.type()) << debug_info; 264 DCHECK_NE(metrics::OmniboxInputType::URL, input.type()) << debug_info;
264 } else { 265 } else {
265 DCHECK_NE(metrics::OmniboxInputType::FORCED_QUERY, input.type()) 266 DCHECK_NE(metrics::OmniboxInputType::FORCED_QUERY, input.type())
266 << debug_info; 267 << debug_info;
268 // If the user explicitly typed a scheme, the default match should
269 // have the same scheme.
270 if ((input.type() == metrics::OmniboxInputType::URL) &&
271 input.parts().scheme.is_nonempty()) {
272 DCHECK_EQ(base::UTF16ToUTF8(base::i18n::ToLower(input.scheme())),
Peter Kasting 2014/07/09 22:36:00 This isn't already lowercased for us?
Mark P 2014/07/09 23:12:23 Right you are. Done.
273 default_match_->destination_url.scheme());
274 }
267 } 275 }
268 } 276 }
269 } 277 }
270 278
271 // Set the alternate nav URL. 279 // Set the alternate nav URL.
272 alternate_nav_url_ = (default_match_ == matches_.end()) ? 280 alternate_nav_url_ = (default_match_ == matches_.end()) ?
273 GURL() : ComputeAlternateNavUrl(input, *default_match_); 281 GURL() : ComputeAlternateNavUrl(input, *default_match_);
274 } 282 }
275 283
276 bool AutocompleteResult::HasCopiedMatches() const { 284 bool AutocompleteResult::HasCopiedMatches() const {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 i != old_matches.rend() && delta > 0; ++i) { 455 i != old_matches.rend() && delta > 0; ++i) {
448 if (!HasMatchByDestination(*i, new_matches)) { 456 if (!HasMatchByDestination(*i, new_matches)) {
449 AutocompleteMatch match = *i; 457 AutocompleteMatch match = *i;
450 match.relevance = std::min(max_relevance, match.relevance); 458 match.relevance = std::min(max_relevance, match.relevance);
451 match.from_previous = true; 459 match.from_previous = true;
452 matches_.push_back(match); 460 matches_.push_back(match);
453 delta--; 461 delta--;
454 } 462 }
455 } 463 }
456 } 464 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698