OLD | NEW |
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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 results_.navigation_results); | 416 results_.navigation_results); |
417 for (SearchSuggestionParser::NavigationResults::const_iterator it( | 417 for (SearchSuggestionParser::NavigationResults::const_iterator it( |
418 nav_results.begin()); it != nav_results.end(); ++it) | 418 nav_results.begin()); it != nav_results.end(); ++it) |
419 matches_.push_back(NavigationToMatch(*it)); | 419 matches_.push_back(NavigationToMatch(*it)); |
420 } | 420 } |
421 | 421 |
422 AutocompleteMatch ZeroSuggestProvider::MatchForCurrentURL() { | 422 AutocompleteMatch ZeroSuggestProvider::MatchForCurrentURL() { |
423 AutocompleteMatch match; | 423 AutocompleteMatch match; |
424 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify( | 424 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify( |
425 permanent_text_, false, true, current_page_classification_, &match, NULL); | 425 permanent_text_, false, true, current_page_classification_, &match, NULL); |
426 match.is_history_what_you_typed_match = false; | |
427 match.allowed_to_be_default_match = true; | 426 match.allowed_to_be_default_match = true; |
428 | 427 |
429 // The placeholder suggestion for the current URL has high relevance so | 428 // The placeholder suggestion for the current URL has high relevance so |
430 // that it is in the first suggestion slot and inline autocompleted. It | 429 // that it is in the first suggestion slot and inline autocompleted. It |
431 // gets dropped as soon as the user types something. | 430 // gets dropped as soon as the user types something. |
432 match.relevance = GetVerbatimRelevance(); | 431 match.relevance = GetVerbatimRelevance(); |
433 | 432 |
434 return match; | 433 return match; |
435 } | 434 } |
436 | 435 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 if (!json_data.empty()) { | 480 if (!json_data.empty()) { |
482 scoped_ptr<base::Value> data( | 481 scoped_ptr<base::Value> data( |
483 SearchSuggestionParser::DeserializeJsonData(json_data)); | 482 SearchSuggestionParser::DeserializeJsonData(json_data)); |
484 if (data && ParseSuggestResults( | 483 if (data && ParseSuggestResults( |
485 *data, kDefaultZeroSuggestRelevance, false, &results_)) { | 484 *data, kDefaultZeroSuggestRelevance, false, &results_)) { |
486 ConvertResultsToAutocompleteMatches(); | 485 ConvertResultsToAutocompleteMatches(); |
487 results_from_cache_ = !matches_.empty(); | 486 results_from_cache_ = !matches_.empty(); |
488 } | 487 } |
489 } | 488 } |
490 } | 489 } |
OLD | NEW |