| 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 fetcher_->SetExtraRequestHeaders(headers.ToString()); | 361 fetcher_->SetExtraRequestHeaders(headers.ToString()); |
| 362 | 362 |
| 363 fetcher_->Start(); | 363 fetcher_->Start(); |
| 364 | 364 |
| 365 if (OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial()) { | 365 if (OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial()) { |
| 366 most_visited_urls_.clear(); | 366 most_visited_urls_.clear(); |
| 367 history::TopSites* ts = profile_->GetTopSites(); | 367 history::TopSites* ts = profile_->GetTopSites(); |
| 368 if (ts) { | 368 if (ts) { |
| 369 ts->GetMostVisitedURLs( | 369 ts->GetMostVisitedURLs( |
| 370 base::Bind(&ZeroSuggestProvider::OnMostVisitedUrlsAvailable, | 370 base::Bind(&ZeroSuggestProvider::OnMostVisitedUrlsAvailable, |
| 371 weak_ptr_factory_.GetWeakPtr())); | 371 weak_ptr_factory_.GetWeakPtr()), false); |
| 372 } | 372 } |
| 373 } | 373 } |
| 374 have_pending_request_ = true; | 374 have_pending_request_ = true; |
| 375 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); | 375 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void ZeroSuggestProvider::ParseSuggestResults(const Value& root_val) { | 378 void ZeroSuggestProvider::ParseSuggestResults(const Value& root_val) { |
| 379 SearchProvider::SuggestResults suggest_results; | 379 SearchProvider::SuggestResults suggest_results; |
| 380 FillResults(root_val, &verbatim_relevance_, | 380 FillResults(root_val, &verbatim_relevance_, |
| 381 &suggest_results, &navigation_results_); | 381 &suggest_results, &navigation_results_); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 match.is_history_what_you_typed_match = false; | 455 match.is_history_what_you_typed_match = false; |
| 456 match.allowed_to_be_default_match = true; | 456 match.allowed_to_be_default_match = true; |
| 457 | 457 |
| 458 // The placeholder suggestion for the current URL has high relevance so | 458 // The placeholder suggestion for the current URL has high relevance so |
| 459 // that it is in the first suggestion slot and inline autocompleted. It | 459 // that it is in the first suggestion slot and inline autocompleted. It |
| 460 // gets dropped as soon as the user types something. | 460 // gets dropped as soon as the user types something. |
| 461 match.relevance = verbatim_relevance_; | 461 match.relevance = verbatim_relevance_; |
| 462 | 462 |
| 463 return match; | 463 return match; |
| 464 } | 464 } |
| OLD | NEW |