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

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

Issue 69703002: Modified GetMatchToPrefetch() to return a valid match for prefetching even when hide_verbatim flag i (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comment Created 7 years 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/logging.h" 10 #include "base/logging.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 return matches_[index]; 252 return matches_[index];
253 } 253 }
254 254
255 AutocompleteMatch* AutocompleteResult::match_at(size_t index) { 255 AutocompleteMatch* AutocompleteResult::match_at(size_t index) {
256 DCHECK_LT(index, matches_.size()); 256 DCHECK_LT(index, matches_.size());
257 return &matches_[index]; 257 return &matches_[index];
258 } 258 }
259 259
260 bool AutocompleteResult::ShouldHideTopMatch() const { 260 bool AutocompleteResult::ShouldHideTopMatch() const {
261 // Gate on our field trial flag. 261 // Gate on our field trial flag.
262 if (!chrome::ShouldHideTopVerbatimMatch()) 262 return chrome::ShouldHideTopVerbatimMatch() &&
263 return false; 263 TopMatchIsVerbatimAndHasNoConsecutiveVerbatimMatches();
264 }
264 265
265 // If we don't have a verbatim first match, show everything. 266 bool AutocompleteResult::TopMatchIsVerbatimAndHasNoConsecutiveVerbatimMatches()
267 const {
266 if (empty() || !match_at(0).IsVerbatimType()) 268 if (empty() || !match_at(0).IsVerbatimType())
267 return false; 269 return false;
268 270
269 // If the verbatim first match is followed by another verbatim match, don't 271 // If the verbatim first match is followed by another verbatim match, return
270 // hide anything, lest we cause user confusion. 272 // false to avoid user confusion.
Mark P 2013/12/12 23:13:07 This user confusion comment doesn't make sense any
kmadhusu 2013/12/13 01:00:29 Done. Removed the comment.
271 if ((size() > 1) && match_at(1).IsVerbatimType()) 273 return !(size() > 1) || !match_at(1).IsVerbatimType();
272 return false;
273
274 // Otherwise, it's safe to hide the verbatim first match.
275 return true;
276 } 274 }
277 275
278 void AutocompleteResult::Reset() { 276 void AutocompleteResult::Reset() {
279 matches_.clear(); 277 matches_.clear();
280 default_match_ = end(); 278 default_match_ = end();
281 } 279 }
282 280
283 void AutocompleteResult::Swap(AutocompleteResult* other) { 281 void AutocompleteResult::Swap(AutocompleteResult* other) {
284 const size_t default_match_offset = default_match_ - begin(); 282 const size_t default_match_offset = default_match_ - begin();
285 const size_t other_default_match_offset = 283 const size_t other_default_match_offset =
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 i != old_matches.rend() && delta > 0; ++i) { 374 i != old_matches.rend() && delta > 0; ++i) {
377 if (!HasMatchByDestination(*i, new_matches)) { 375 if (!HasMatchByDestination(*i, new_matches)) {
378 AutocompleteMatch match = *i; 376 AutocompleteMatch match = *i;
379 match.relevance = std::min(max_relevance, match.relevance); 377 match.relevance = std::min(max_relevance, match.relevance);
380 match.from_previous = true; 378 match.from_previous = true;
381 AddMatch(page_classification, match); 379 AddMatch(page_classification, match);
382 delta--; 380 delta--;
383 } 381 }
384 } 382 }
385 } 383 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698