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/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/autocomplete/autocomplete_input.h" | 13 #include "chrome/browser/autocomplete/autocomplete_input.h" |
14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 14 #include "chrome/browser/autocomplete/autocomplete_match.h" |
15 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 15 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
samarth
2012/09/20 21:09:29
nit: Do you still need this include?
kuan
2012/09/20 21:13:41
yeah, i tried removing it, but it's needed @38 "pr
| |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/search_engines/template_url_service.h" | 18 #include "chrome/browser/search_engines/template_url_service.h" |
19 #include "chrome/browser/search_engines/template_url_service_factory.h" | 19 #include "chrome/browser/search_engines/template_url_service_factory.h" |
20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
22 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
23 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
24 #include "net/http/http_response_headers.h" | 24 #include "net/http/http_response_headers.h" |
25 #include "net/url_request/url_fetcher.h" | 25 #include "net/url_request/url_fetcher.h" |
26 #include "net/url_request/url_request_status.h" | 26 #include "net/url_request/url_request_status.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
46 ZeroSuggestProvider::ZeroSuggestProvider( | 46 ZeroSuggestProvider::ZeroSuggestProvider( |
47 AutocompleteProviderListener* listener, | 47 AutocompleteProviderListener* listener, |
48 Profile* profile, | 48 Profile* profile, |
49 const std::string& url_prefix) | 49 const std::string& url_prefix) |
50 : AutocompleteProvider(listener, profile, | 50 : AutocompleteProvider(listener, profile, |
51 AutocompleteProvider::TYPE_ZERO_SUGGEST), | 51 AutocompleteProvider::TYPE_ZERO_SUGGEST), |
52 url_prefix_(url_prefix), | 52 url_prefix_(url_prefix), |
53 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)) { | 53 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)) { |
54 } | 54 } |
55 | 55 |
56 // static | |
57 void ZeroSuggestProvider::RegisterUserPrefs(PrefService* user_prefs) { | |
58 user_prefs->RegisterStringPref(prefs::kExperimentalZeroSuggestUrlPrefix, "", | |
59 PrefService::UNSYNCABLE_PREF); | |
60 } | |
61 | |
62 void ZeroSuggestProvider::Start(const AutocompleteInput& input, | 56 void ZeroSuggestProvider::Start(const AutocompleteInput& input, |
63 bool /*minimal_changes*/) { | 57 bool /*minimal_changes*/) { |
64 UpdateMatches(input.text()); | 58 UpdateMatches(input.text()); |
65 } | 59 } |
66 | 60 |
67 void ZeroSuggestProvider::StartZeroSuggest(const GURL& url, | 61 void ZeroSuggestProvider::StartZeroSuggest(const GURL& url, |
68 const string16& user_text) { | 62 const string16& user_text) { |
69 DCHECK(url.is_valid()); | 63 DCHECK(url.is_valid()); |
70 // Do not query non-http URLs. There will be no useful suggestions for https | 64 // Do not query non-http URLs. There will be no useful suggestions for https |
71 // or chrome URLs. | 65 // or chrome URLs. |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 // Style to look like normal search suggestions. | 230 // Style to look like normal search suggestions. |
237 match.contents_class.push_back( | 231 match.contents_class.push_back( |
238 ACMatchClassification(0, ACMatchClassification::DIM)); | 232 ACMatchClassification(0, ACMatchClassification::DIM)); |
239 match.contents_class.push_back( | 233 match.contents_class.push_back( |
240 ACMatchClassification(user_text_.length(), ACMatchClassification::NONE)); | 234 ACMatchClassification(user_text_.length(), ACMatchClassification::NONE)); |
241 } | 235 } |
242 match.transition = content::PAGE_TRANSITION_GENERATED; | 236 match.transition = content::PAGE_TRANSITION_GENERATED; |
243 | 237 |
244 matches_.push_back(match); | 238 matches_.push_back(match); |
245 } | 239 } |
OLD | NEW |