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 | 336 // Note: It's OK to pass |is_signed_in| false if it's unknown, as it does |
337 // transmission of experiment ids coming from the variations server. | 337 // not affect transmission of experiments coming from the variations server. |
338 bool is_signed_in = false; | 338 bool is_signed_in = false; |
339 variations::AppendVariationHeaders(fetcher_->GetOriginalURL(), | 339 variations::AppendVariationHeaders(fetcher_->GetOriginalURL(), |
340 client()->IsOffTheRecord(), false, | 340 client()->IsOffTheRecord(), false, |
341 is_signed_in, &headers); | 341 is_signed_in, &headers); |
342 fetcher_->SetExtraRequestHeaders(headers.ToString()); | 342 fetcher_->SetExtraRequestHeaders(headers.ToString()); |
343 fetcher_->Start(); | 343 fetcher_->Start(); |
344 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); | 344 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); |
345 } | 345 } |
346 } | 346 } |
347 | 347 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 if (!json_data.empty()) { | 474 if (!json_data.empty()) { |
475 std::unique_ptr<base::Value> data( | 475 std::unique_ptr<base::Value> data( |
476 SearchSuggestionParser::DeserializeJsonData(json_data)); | 476 SearchSuggestionParser::DeserializeJsonData(json_data)); |
477 if (data && ParseSuggestResults( | 477 if (data && ParseSuggestResults( |
478 *data, kDefaultZeroSuggestRelevance, false, &results_)) { | 478 *data, kDefaultZeroSuggestRelevance, false, &results_)) { |
479 ConvertResultsToAutocompleteMatches(); | 479 ConvertResultsToAutocompleteMatches(); |
480 results_from_cache_ = !matches_.empty(); | 480 results_from_cache_ = !matches_.empty(); |
481 } | 481 } |
482 } | 482 } |
483 } | 483 } |
OLD | NEW |