| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 // The relevance of the top match from this provider. | 27 // The relevance of the top match from this provider. |
| 28 const int kMaxZeroSuggestRelevance = 100; | 28 const int kMaxZeroSuggestRelevance = 100; |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 ZeroSuggestProvider::ZeroSuggestProvider( | 31 ZeroSuggestProvider::ZeroSuggestProvider( |
| 32 AutocompleteProviderListener* listener, | 32 AutocompleteProviderListener* listener, |
| 33 Profile* profile, | 33 Profile* profile, |
| 34 const std::string& url_prefix) | 34 const std::string& url_prefix) |
| 35 : AutocompleteProvider(listener, profile, "ZeroSuggest"), | 35 : AutocompleteProvider(listener, profile, |
| 36 AutocompleteProvider::TYPE_ZERO_SUGGEST), |
| 36 url_prefix_(url_prefix), | 37 url_prefix_(url_prefix), |
| 37 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)) { | 38 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)) { |
| 38 } | 39 } |
| 39 | 40 |
| 40 void ZeroSuggestProvider::Start(const AutocompleteInput& input, | 41 void ZeroSuggestProvider::Start(const AutocompleteInput& input, |
| 41 bool /*minimal_changes*/) { | 42 bool /*minimal_changes*/) { |
| 42 UpdateMatches(input.text()); | 43 UpdateMatches(input.text()); |
| 43 } | 44 } |
| 44 | 45 |
| 45 void ZeroSuggestProvider::StartZeroSuggest(const GURL& url, | 46 void ZeroSuggestProvider::StartZeroSuggest(const GURL& url, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // Style to look like normal search suggestions. | 215 // Style to look like normal search suggestions. |
| 215 match.contents_class.push_back( | 216 match.contents_class.push_back( |
| 216 ACMatchClassification(0, ACMatchClassification::DIM)); | 217 ACMatchClassification(0, ACMatchClassification::DIM)); |
| 217 match.contents_class.push_back( | 218 match.contents_class.push_back( |
| 218 ACMatchClassification(user_text_.length(), ACMatchClassification::NONE)); | 219 ACMatchClassification(user_text_.length(), ACMatchClassification::NONE)); |
| 219 } | 220 } |
| 220 match.transition = content::PAGE_TRANSITION_GENERATED; | 221 match.transition = content::PAGE_TRANSITION_GENERATED; |
| 221 | 222 |
| 222 matches_.push_back(match); | 223 matches_.push_back(match); |
| 223 } | 224 } |
| OLD | NEW |