| 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 "components/omnibox/browser/zero_suggest_provider.h" | 5 #include "components/omnibox/browser/zero_suggest_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 const int kFetcherID = 1; | 327 const int kFetcherID = 1; |
| 328 fetcher_ = net::URLFetcher::Create(kFetcherID, suggest_url, | 328 fetcher_ = net::URLFetcher::Create(kFetcherID, suggest_url, |
| 329 net::URLFetcher::GET, this); | 329 net::URLFetcher::GET, this); |
| 330 data_use_measurement::DataUseUserData::AttachToFetcher( | 330 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 331 fetcher_.get(), data_use_measurement::DataUseUserData::OMNIBOX); | 331 fetcher_.get(), data_use_measurement::DataUseUserData::OMNIBOX); |
| 332 fetcher_->SetRequestContext(client()->GetRequestContext()); | 332 fetcher_->SetRequestContext(client()->GetRequestContext()); |
| 333 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); | 333 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); |
| 334 // Add Chrome experiment state to the request headers. | 334 // Add Chrome experiment state to the request headers. |
| 335 net::HttpRequestHeaders headers; | 335 net::HttpRequestHeaders headers; |
| 336 variations::AppendVariationHeaders(fetcher_->GetOriginalURL(), | 336 variations::AppendVariationHeaders(fetcher_->GetOriginalURL(), |
| 337 client()->IsOffTheRecord(), false, | 337 client()->IsOffTheRecord(), false, false, |
| 338 &headers); | 338 &headers); |
| 339 fetcher_->SetExtraRequestHeaders(headers.ToString()); | 339 fetcher_->SetExtraRequestHeaders(headers.ToString()); |
| 340 fetcher_->Start(); | 340 fetcher_->Start(); |
| 341 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); | 341 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 | 344 |
| 345 void ZeroSuggestProvider::OnMostVisitedUrlsAvailable( | 345 void ZeroSuggestProvider::OnMostVisitedUrlsAvailable( |
| 346 const history::MostVisitedURLList& urls) { | 346 const history::MostVisitedURLList& urls) { |
| 347 if (!waiting_for_most_visited_urls_request_) return; | 347 if (!waiting_for_most_visited_urls_request_) return; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 if (!json_data.empty()) { | 471 if (!json_data.empty()) { |
| 472 std::unique_ptr<base::Value> data( | 472 std::unique_ptr<base::Value> data( |
| 473 SearchSuggestionParser::DeserializeJsonData(json_data)); | 473 SearchSuggestionParser::DeserializeJsonData(json_data)); |
| 474 if (data && ParseSuggestResults( | 474 if (data && ParseSuggestResults( |
| 475 *data, kDefaultZeroSuggestRelevance, false, &results_)) { | 475 *data, kDefaultZeroSuggestRelevance, false, &results_)) { |
| 476 ConvertResultsToAutocompleteMatches(); | 476 ConvertResultsToAutocompleteMatches(); |
| 477 results_from_cache_ = !matches_.empty(); | 477 results_from_cache_ = !matches_.empty(); |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 } | 480 } |
| OLD | NEW |