Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Side by Side Diff: components/omnibox/browser/zero_suggest_provider.cc

Issue 1530133005: Refactor VariationsHttpHeaderProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing include to srt_fetcher_win.cc. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/omnibox/browser/search_provider.cc ('k') | components/suggestions.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "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 12 matching lines...) Expand all
23 #include "components/omnibox/browser/autocomplete_match.h" 23 #include "components/omnibox/browser/autocomplete_match.h"
24 #include "components/omnibox/browser/autocomplete_provider_listener.h" 24 #include "components/omnibox/browser/autocomplete_provider_listener.h"
25 #include "components/omnibox/browser/history_url_provider.h" 25 #include "components/omnibox/browser/history_url_provider.h"
26 #include "components/omnibox/browser/omnibox_field_trial.h" 26 #include "components/omnibox/browser/omnibox_field_trial.h"
27 #include "components/omnibox/browser/omnibox_pref_names.h" 27 #include "components/omnibox/browser/omnibox_pref_names.h"
28 #include "components/omnibox/browser/search_provider.h" 28 #include "components/omnibox/browser/search_provider.h"
29 #include "components/omnibox/browser/verbatim_match.h" 29 #include "components/omnibox/browser/verbatim_match.h"
30 #include "components/pref_registry/pref_registry_syncable.h" 30 #include "components/pref_registry/pref_registry_syncable.h"
31 #include "components/search_engines/template_url_service.h" 31 #include "components/search_engines/template_url_service.h"
32 #include "components/url_formatter/url_formatter.h" 32 #include "components/url_formatter/url_formatter.h"
33 #include "components/variations/net/variations_http_header_provider.h" 33 #include "components/variations/net/variations_http_headers.h"
34 #include "net/base/escape.h" 34 #include "net/base/escape.h"
35 #include "net/base/load_flags.h" 35 #include "net/base/load_flags.h"
36 #include "net/http/http_request_headers.h" 36 #include "net/http/http_request_headers.h"
37 #include "net/url_request/url_fetcher.h" 37 #include "net/url_request/url_fetcher.h"
38 #include "net/url_request/url_request_status.h" 38 #include "net/url_request/url_request_status.h"
39 #include "url/gurl.h" 39 #include "url/gurl.h"
40 40
41 namespace { 41 namespace {
42 42
43 // TODO(hfung): The histogram code was copied and modified from 43 // TODO(hfung): The histogram code was copied and modified from
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } else { 319 } else {
320 const int kFetcherID = 1; 320 const int kFetcherID = 1;
321 fetcher_ = net::URLFetcher::Create(kFetcherID, suggest_url, 321 fetcher_ = net::URLFetcher::Create(kFetcherID, suggest_url,
322 net::URLFetcher::GET, this); 322 net::URLFetcher::GET, this);
323 data_use_measurement::DataUseUserData::AttachToFetcher( 323 data_use_measurement::DataUseUserData::AttachToFetcher(
324 fetcher_.get(), data_use_measurement::DataUseUserData::OMNIBOX); 324 fetcher_.get(), data_use_measurement::DataUseUserData::OMNIBOX);
325 fetcher_->SetRequestContext(client()->GetRequestContext()); 325 fetcher_->SetRequestContext(client()->GetRequestContext());
326 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 326 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
327 // Add Chrome experiment state to the request headers. 327 // Add Chrome experiment state to the request headers.
328 net::HttpRequestHeaders headers; 328 net::HttpRequestHeaders headers;
329 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders( 329 variations::AppendVariationHeaders(fetcher_->GetOriginalURL(),
330 fetcher_->GetOriginalURL(), client()->IsOffTheRecord(), false, 330 client()->IsOffTheRecord(), false,
331 &headers); 331 &headers);
332 fetcher_->SetExtraRequestHeaders(headers.ToString()); 332 fetcher_->SetExtraRequestHeaders(headers.ToString());
333 fetcher_->Start(); 333 fetcher_->Start();
334 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); 334 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT);
335 } 335 }
336 } 336 }
337 337
338 void ZeroSuggestProvider::OnMostVisitedUrlsAvailable( 338 void ZeroSuggestProvider::OnMostVisitedUrlsAvailable(
339 const history::MostVisitedURLList& urls) { 339 const history::MostVisitedURLList& urls) {
340 if (!waiting_for_most_visited_urls_request_) return; 340 if (!waiting_for_most_visited_urls_request_) return;
341 most_visited_urls_ = urls; 341 most_visited_urls_ = urls;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 if (!json_data.empty()) { 463 if (!json_data.empty()) {
464 scoped_ptr<base::Value> data( 464 scoped_ptr<base::Value> data(
465 SearchSuggestionParser::DeserializeJsonData(json_data)); 465 SearchSuggestionParser::DeserializeJsonData(json_data));
466 if (data && ParseSuggestResults( 466 if (data && ParseSuggestResults(
467 *data, kDefaultZeroSuggestRelevance, false, &results_)) { 467 *data, kDefaultZeroSuggestRelevance, false, &results_)) {
468 ConvertResultsToAutocompleteMatches(); 468 ConvertResultsToAutocompleteMatches();
469 results_from_cache_ = !matches_.empty(); 469 results_from_cache_ = !matches_.empty();
470 } 470 }
471 } 471 }
472 } 472 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/search_provider.cc ('k') | components/suggestions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698