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 // This file contains the zero-suggest autocomplete provider. This experimental | 5 // This file contains the zero-suggest autocomplete provider. This experimental |
6 // provider is invoked when the user focuses in the omnibox prior to editing, | 6 // provider is invoked when the user focuses in the omnibox prior to editing, |
7 // and generates search query suggestions based on the current URL. To enable | 7 // and generates search query suggestions based on the current URL. To enable |
8 // this provider, point --experimental-zero-suggest-url-prefix at an | 8 // this provider, point --experimental-zero-suggest-url-prefix at an |
9 // appropriate suggestion service. | 9 // appropriate suggestion service. |
10 // | 10 // |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 int* verbatim_relevance, | 85 int* verbatim_relevance, |
86 SuggestResults* suggest_results, | 86 SuggestResults* suggest_results, |
87 NavigationResults* navigation_results); | 87 NavigationResults* navigation_results); |
88 | 88 |
89 // Creates AutocompleteMatches to search |template_url| for "<suggestion>" for | 89 // Creates AutocompleteMatches to search |template_url| for "<suggestion>" for |
90 // all suggestions in |results|, and adds them to |map|. | 90 // all suggestions in |results|, and adds them to |map|. |
91 void AddSuggestResultsToMap(const SuggestResults& results, | 91 void AddSuggestResultsToMap(const SuggestResults& results, |
92 const TemplateURL* template_url, | 92 const TemplateURL* template_url, |
93 MatchMap* map); | 93 MatchMap* map); |
94 | 94 |
95 // Creates an AutocompleteMatch with the provided |relevance| and |type| to | |
96 // search |template_url| for |query_string|. |accepted_suggestion| will be | |
97 // used to generate Assisted Query Stats. | |
98 // | |
99 // Adds this match to |map|; if such a match already exists, whichever one | |
100 // has lower relevance is eliminated. | |
101 void AddMatchToMap(int relevance, | |
102 AutocompleteMatch::Type type, | |
103 const TemplateURL* template_url, | |
104 const base::string16& query_string, | |
105 int accepted_suggestion, | |
106 MatchMap* map); | |
107 | |
108 // Returns an AutocompleteMatch for a navigational suggestion |navigation|. | 95 // Returns an AutocompleteMatch for a navigational suggestion |navigation|. |
109 AutocompleteMatch NavigationToMatch(const NavigationResult& navigation); | 96 AutocompleteMatch NavigationToMatch(const NavigationResult& navigation); |
110 | 97 |
111 // Fetches zero-suggest suggestions by sending a request using |suggest_url|. | 98 // Fetches zero-suggest suggestions by sending a request using |suggest_url|. |
112 void Run(const GURL& suggest_url); | 99 void Run(const GURL& suggest_url); |
113 | 100 |
114 // Parses results from the zero-suggest server and updates results. | 101 // Parses results from the zero-suggest server and updates results. |
115 void ParseSuggestResults(const base::Value& root_val); | 102 void ParseSuggestResults(const base::Value& root_val); |
116 | 103 |
117 // Converts the parsed results to a set of AutocompleteMatches and adds them | 104 // Converts the parsed results to a set of AutocompleteMatches and adds them |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 145 |
159 history::MostVisitedURLList most_visited_urls_; | 146 history::MostVisitedURLList most_visited_urls_; |
160 | 147 |
161 // For callbacks that may be run after destruction. | 148 // For callbacks that may be run after destruction. |
162 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; | 149 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; |
163 | 150 |
164 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); | 151 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); |
165 }; | 152 }; |
166 | 153 |
167 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ | 154 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ |
OLD | NEW |