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

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

Issue 471673002: Omnibox: Prevent Asynchronous Suggestions from Changing Default Match (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better resolve rebase Created 6 years, 4 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/zero_suggest_provider.h" 5 #include "chrome/browser/autocomplete/zero_suggest_provider.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/i18n/case_conversion.h" 8 #include "base/i18n/case_conversion.h"
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 if (results_from_cache_) 266 if (results_from_cache_)
267 done_ = true; 267 done_ = true;
268 268
269 return results_from_cache_; 269 return results_from_cache_;
270 } 270 }
271 271
272 void ZeroSuggestProvider::AddSuggestResultsToMap( 272 void ZeroSuggestProvider::AddSuggestResultsToMap(
273 const SearchSuggestionParser::SuggestResults& results, 273 const SearchSuggestionParser::SuggestResults& results,
274 MatchMap* map) { 274 MatchMap* map) {
275 for (size_t i = 0; i < results.size(); ++i) 275 for (size_t i = 0; i < results.size(); ++i)
276 AddMatchToMap(results[i], std::string(), i, false, map); 276 AddMatchToMap(results[i], std::string(), i, false, false, map);
277 } 277 }
278 278
279 AutocompleteMatch ZeroSuggestProvider::NavigationToMatch( 279 AutocompleteMatch ZeroSuggestProvider::NavigationToMatch(
280 const SearchSuggestionParser::NavigationResult& navigation) { 280 const SearchSuggestionParser::NavigationResult& navigation) {
281 AutocompleteMatch match(this, navigation.relevance(), false, 281 AutocompleteMatch match(this, navigation.relevance(), false,
282 navigation.type()); 282 navigation.type());
283 match.destination_url = navigation.url(); 283 match.destination_url = navigation.url();
284 284
285 // Zero suggest results should always omit protocols and never appear bold. 285 // Zero suggest results should always omit protocols and never appear bold.
286 const std::string languages( 286 const std::string languages(
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 if (!json_data.empty()) { 455 if (!json_data.empty()) {
456 scoped_ptr<base::Value> data( 456 scoped_ptr<base::Value> data(
457 SearchSuggestionParser::DeserializeJsonData(json_data)); 457 SearchSuggestionParser::DeserializeJsonData(json_data));
458 if (data && ParseSuggestResults( 458 if (data && ParseSuggestResults(
459 *data, kDefaultZeroSuggestRelevance, false, &results_)) { 459 *data, kDefaultZeroSuggestRelevance, false, &results_)) {
460 ConvertResultsToAutocompleteMatches(); 460 ConvertResultsToAutocompleteMatches();
461 results_from_cache_ = !matches_.empty(); 461 results_from_cache_ = !matches_.empty();
462 } 462 }
463 } 463 }
464 } 464 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698