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 "chrome/browser/autocomplete/zero_suggest_provider.h" | 5 #include "chrome/browser/autocomplete/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 22 matching lines...) Expand all Loading... |
33 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
34 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
35 #include "content/public/browser/user_metrics.h" | 35 #include "content/public/browser/user_metrics.h" |
36 #include "net/base/escape.h" | 36 #include "net/base/escape.h" |
37 #include "net/base/load_flags.h" | 37 #include "net/base/load_flags.h" |
38 #include "net/base/net_util.h" | 38 #include "net/base/net_util.h" |
39 #include "net/http/http_request_headers.h" | 39 #include "net/http/http_request_headers.h" |
40 #include "net/url_request/url_fetcher.h" | 40 #include "net/url_request/url_fetcher.h" |
41 #include "net/url_request/url_request_status.h" | 41 #include "net/url_request/url_request_status.h" |
42 #include "url/gurl.h" | 42 #include "url/gurl.h" |
| 43 #include "url/url_constants.h" |
43 | 44 |
44 namespace { | 45 namespace { |
45 | 46 |
46 // TODO(hfung): The histogram code was copied and modified from | 47 // TODO(hfung): The histogram code was copied and modified from |
47 // search_provider.cc. Refactor and consolidate the code. | 48 // search_provider.cc. Refactor and consolidate the code. |
48 // We keep track in a histogram how many suggest requests we send, how | 49 // We keep track in a histogram how many suggest requests we send, how |
49 // many suggest requests we invalidate (e.g., due to a user typing | 50 // many suggest requests we invalidate (e.g., due to a user typing |
50 // another character), and how many replies we receive. | 51 // another character), and how many replies we receive. |
51 // *** ADD NEW ENUMS AFTER ALL PREVIOUSLY DEFINED ONES! *** | 52 // *** ADD NEW ENUMS AFTER ALL PREVIOUSLY DEFINED ONES! *** |
52 // (excluding the end-of-list enum value) | 53 // (excluding the end-of-list enum value) |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 // variations can be shown. | 379 // variations can be shown. |
379 if (!OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial() && | 380 if (!OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial() && |
380 !OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial()) | 381 !OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial()) |
381 return false; | 382 return false; |
382 | 383 |
383 // Only show zero suggest for HTTP[S] pages. | 384 // Only show zero suggest for HTTP[S] pages. |
384 // TODO(mariakhomenko): We may be able to expand this set to include pages | 385 // TODO(mariakhomenko): We may be able to expand this set to include pages |
385 // with other schemes (e.g. chrome://). That may require improvements to | 386 // with other schemes (e.g. chrome://). That may require improvements to |
386 // the formatting of the verbatim result returned by MatchForCurrentURL(). | 387 // the formatting of the verbatim result returned by MatchForCurrentURL(). |
387 if (!current_page_url.is_valid() || | 388 if (!current_page_url.is_valid() || |
388 ((current_page_url.scheme() != content::kHttpScheme) && | 389 ((current_page_url.scheme() != url::kHttpScheme) && |
389 (current_page_url.scheme() != content::kHttpsScheme))) | 390 (current_page_url.scheme() != url::kHttpsScheme))) |
390 return false; | 391 return false; |
391 | 392 |
392 return true; | 393 return true; |
393 } | 394 } |
OLD | NEW |