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

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

Issue 1171333003: Move net::FormatUrl and friends outside of //net and into //components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again now that CQ is fixed Created 5 years, 4 months 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/url_index_private_data.cc ('k') | components/password_manager.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"
11 #include "base/metrics/user_metrics.h" 11 #include "base/metrics/user_metrics.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "components/history/core/browser/history_types.h" 17 #include "components/history/core/browser/history_types.h"
18 #include "components/history/core/browser/top_sites.h" 18 #include "components/history/core/browser/top_sites.h"
19 #include "components/metrics/proto/omnibox_input_type.pb.h" 19 #include "components/metrics/proto/omnibox_input_type.pb.h"
20 #include "components/omnibox/browser/autocomplete_classifier.h" 20 #include "components/omnibox/browser/autocomplete_classifier.h"
21 #include "components/omnibox/browser/autocomplete_input.h" 21 #include "components/omnibox/browser/autocomplete_input.h"
22 #include "components/omnibox/browser/autocomplete_match.h" 22 #include "components/omnibox/browser/autocomplete_match.h"
23 #include "components/omnibox/browser/autocomplete_provider_listener.h" 23 #include "components/omnibox/browser/autocomplete_provider_listener.h"
24 #include "components/omnibox/browser/history_url_provider.h" 24 #include "components/omnibox/browser/history_url_provider.h"
25 #include "components/omnibox/browser/omnibox_field_trial.h" 25 #include "components/omnibox/browser/omnibox_field_trial.h"
26 #include "components/omnibox/browser/omnibox_pref_names.h" 26 #include "components/omnibox/browser/omnibox_pref_names.h"
27 #include "components/omnibox/browser/search_provider.h" 27 #include "components/omnibox/browser/search_provider.h"
28 #include "components/pref_registry/pref_registry_syncable.h" 28 #include "components/pref_registry/pref_registry_syncable.h"
29 #include "components/search_engines/template_url_service.h" 29 #include "components/search_engines/template_url_service.h"
30 #include "components/url_formatter/url_formatter.h"
30 #include "components/variations/net/variations_http_header_provider.h" 31 #include "components/variations/net/variations_http_header_provider.h"
31 #include "net/base/escape.h" 32 #include "net/base/escape.h"
32 #include "net/base/load_flags.h" 33 #include "net/base/load_flags.h"
33 #include "net/base/net_util.h"
34 #include "net/http/http_request_headers.h" 34 #include "net/http/http_request_headers.h"
35 #include "net/url_request/url_fetcher.h" 35 #include "net/url_request/url_fetcher.h"
36 #include "net/url_request/url_request_status.h" 36 #include "net/url_request/url_request_status.h"
37 #include "url/gurl.h" 37 #include "url/gurl.h"
38 38
39 namespace { 39 namespace {
40 40
41 // TODO(hfung): The histogram code was copied and modified from 41 // TODO(hfung): The histogram code was copied and modified from
42 // search_provider.cc. Refactor and consolidate the code. 42 // search_provider.cc. Refactor and consolidate the code.
43 // We keep track in a histogram how many suggest requests we send, how 43 // We keep track in a histogram how many suggest requests we send, how
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } 281 }
282 282
283 AutocompleteMatch ZeroSuggestProvider::NavigationToMatch( 283 AutocompleteMatch ZeroSuggestProvider::NavigationToMatch(
284 const SearchSuggestionParser::NavigationResult& navigation) { 284 const SearchSuggestionParser::NavigationResult& navigation) {
285 AutocompleteMatch match(this, navigation.relevance(), false, 285 AutocompleteMatch match(this, navigation.relevance(), false,
286 navigation.type()); 286 navigation.type());
287 match.destination_url = navigation.url(); 287 match.destination_url = navigation.url();
288 288
289 // Zero suggest results should always omit protocols and never appear bold. 289 // Zero suggest results should always omit protocols and never appear bold.
290 const std::string languages(client()->GetAcceptLanguages()); 290 const std::string languages(client()->GetAcceptLanguages());
291 match.contents = net::FormatUrl(navigation.url(), languages, 291 match.contents = url_formatter::FormatUrl(
292 net::kFormatUrlOmitAll, net::UnescapeRule::SPACES, NULL, NULL, NULL); 292 navigation.url(), languages, url_formatter::kFormatUrlOmitAll,
293 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr);
293 match.fill_into_edit += 294 match.fill_into_edit +=
294 AutocompleteInput::FormattedStringWithEquivalentMeaning( 295 AutocompleteInput::FormattedStringWithEquivalentMeaning(
295 navigation.url(), match.contents, client()->GetSchemeClassifier()); 296 navigation.url(), match.contents, client()->GetSchemeClassifier());
296 297
297 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, 298 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0,
298 match.contents.length(), ACMatchClassification::URL, 299 match.contents.length(), ACMatchClassification::URL,
299 &match.contents_class); 300 &match.contents_class);
300 301
301 match.description = 302 match.description =
302 AutocompleteMatch::SanitizeString(navigation.description()); 303 AutocompleteMatch::SanitizeString(navigation.description());
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 if (!json_data.empty()) { 472 if (!json_data.empty()) {
472 scoped_ptr<base::Value> data( 473 scoped_ptr<base::Value> data(
473 SearchSuggestionParser::DeserializeJsonData(json_data)); 474 SearchSuggestionParser::DeserializeJsonData(json_data));
474 if (data && ParseSuggestResults( 475 if (data && ParseSuggestResults(
475 *data, kDefaultZeroSuggestRelevance, false, &results_)) { 476 *data, kDefaultZeroSuggestRelevance, false, &results_)) {
476 ConvertResultsToAutocompleteMatches(); 477 ConvertResultsToAutocompleteMatches();
477 results_from_cache_ = !matches_.empty(); 478 results_from_cache_ = !matches_.empty();
478 } 479 }
479 } 480 }
480 } 481 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/url_index_private_data.cc ('k') | components/password_manager.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698