| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } else { | 326 } else { |
| 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 // Note: It's fine to pass in |is_signed_in| false, which does not affect | |
| 337 // transmission of experiment ids coming from the variations server. | |
| 338 bool is_signed_in = false; | |
| 339 variations::AppendVariationHeaders(fetcher_->GetOriginalURL(), | 336 variations::AppendVariationHeaders(fetcher_->GetOriginalURL(), |
| 340 client()->IsOffTheRecord(), false, | 337 client()->IsOffTheRecord(), false, |
| 341 is_signed_in, &headers); | 338 &headers); |
| 342 fetcher_->SetExtraRequestHeaders(headers.ToString()); | 339 fetcher_->SetExtraRequestHeaders(headers.ToString()); |
| 343 fetcher_->Start(); | 340 fetcher_->Start(); |
| 344 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); | 341 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); |
| 345 } | 342 } |
| 346 } | 343 } |
| 347 | 344 |
| 348 void ZeroSuggestProvider::OnMostVisitedUrlsAvailable( | 345 void ZeroSuggestProvider::OnMostVisitedUrlsAvailable( |
| 349 const history::MostVisitedURLList& urls) { | 346 const history::MostVisitedURLList& urls) { |
| 350 if (!waiting_for_most_visited_urls_request_) return; | 347 if (!waiting_for_most_visited_urls_request_) return; |
| 351 most_visited_urls_ = urls; | 348 most_visited_urls_ = urls; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 if (!json_data.empty()) { | 471 if (!json_data.empty()) { |
| 475 std::unique_ptr<base::Value> data( | 472 std::unique_ptr<base::Value> data( |
| 476 SearchSuggestionParser::DeserializeJsonData(json_data)); | 473 SearchSuggestionParser::DeserializeJsonData(json_data)); |
| 477 if (data && ParseSuggestResults( | 474 if (data && ParseSuggestResults( |
| 478 *data, kDefaultZeroSuggestRelevance, false, &results_)) { | 475 *data, kDefaultZeroSuggestRelevance, false, &results_)) { |
| 479 ConvertResultsToAutocompleteMatches(); | 476 ConvertResultsToAutocompleteMatches(); |
| 480 results_from_cache_ = !matches_.empty(); | 477 results_from_cache_ = !matches_.empty(); |
| 481 } | 478 } |
| 482 } | 479 } |
| 483 } | 480 } |
| OLD | NEW |