| 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" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // Style to look like normal search suggestions. | 232 // Style to look like normal search suggestions. |
| 239 match.contents_class.push_back( | 233 match.contents_class.push_back( |
| 240 ACMatchClassification(0, ACMatchClassification::DIM)); | 234 ACMatchClassification(0, ACMatchClassification::DIM)); |
| 241 match.contents_class.push_back( | 235 match.contents_class.push_back( |
| 242 ACMatchClassification(user_text_.length(), ACMatchClassification::NONE)); | 236 ACMatchClassification(user_text_.length(), ACMatchClassification::NONE)); |
| 243 } | 237 } |
| 244 match.transition = content::PAGE_TRANSITION_GENERATED; | 238 match.transition = content::PAGE_TRANSITION_GENERATED; |
| 245 | 239 |
| 246 matches_.push_back(match); | 240 matches_.push_back(match); |
| 247 } | 241 } |
| OLD | NEW |