| 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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // Tells the provider whether to promote the what you typed match, the first | 150 // Tells the provider whether to promote the what you typed match, the first |
| 151 // element of |matches|, or neither as the first AutocompleteMatch. If | 151 // element of |matches|, or neither as the first AutocompleteMatch. If |
| 152 // |exact_suggestion_is_in_history| is true (and thus "the what you typed | 152 // |exact_suggestion_is_in_history| is true (and thus "the what you typed |
| 153 // match" and "the first element of |matches|" represent the same thing), this | 153 // match" and "the first element of |matches|" represent the same thing), this |
| 154 // will be set to WHAT_YOU_TYPED_MATCH. | 154 // will be set to WHAT_YOU_TYPED_MATCH. |
| 155 // | 155 // |
| 156 // NOTE: The second pass of DoAutocomplete() checks what the first pass set | 156 // NOTE: The second pass of DoAutocomplete() checks what the first pass set |
| 157 // this to. See comments in DoAutocomplete(). | 157 // this to. See comments in DoAutocomplete(). |
| 158 PromoteType promote_type; | 158 PromoteType promote_type; |
| 159 | 159 |
| 160 // True if |what_you_typed_match| is eligible for display. If this is true, |
| 161 // PromoteMatchesIfNecessary() may choose to place |what_you_typed_match| on |
| 162 // |matches_| even when |promote_type| is not WHAT_YOU_TYPED_MATCH. |
| 163 bool have_what_you_typed_match; |
| 164 |
| 160 // Languages we should pass to gfx::GetCleanStringFromUrl. | 165 // Languages we should pass to gfx::GetCleanStringFromUrl. |
| 161 std::string languages; | 166 std::string languages; |
| 162 | 167 |
| 163 // The default search provider and search terms data necessary to cull results | 168 // The default search provider and search terms data necessary to cull results |
| 164 // that correspond to searches (on the default engine). These can only be | 169 // that correspond to searches (on the default engine). These can only be |
| 165 // obtained on the UI thread, so we have to copy them into here to pass them | 170 // obtained on the UI thread, so we have to copy them into here to pass them |
| 166 // to the history thread. We use a scoped_ptr<TemplateURL> for the DSP since | 171 // to the history thread. We use a scoped_ptr<TemplateURL> for the DSP since |
| 167 // TemplateURLs can't be copied by value. We use a scoped_ptr<SearchTermsData> | 172 // TemplateURLs can't be copied by value. We use a scoped_ptr<SearchTermsData> |
| 168 // so that we can store a snapshot of the SearchTermsData accessible from the | 173 // so that we can store a snapshot of the SearchTermsData accessible from the |
| 169 // history thread. | 174 // history thread. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 const base::string16& input_text, | 244 const base::string16& input_text, |
| 240 const base::string16& description); | 245 const base::string16& description); |
| 241 | 246 |
| 242 // Actually runs the autocomplete job on the given database, which is | 247 // Actually runs the autocomplete job on the given database, which is |
| 243 // guaranteed not to be NULL. Used by both autocomplete passes, and therefore | 248 // guaranteed not to be NULL. Used by both autocomplete passes, and therefore |
| 244 // called on multiple different threads (though not simultaneously). | 249 // called on multiple different threads (though not simultaneously). |
| 245 void DoAutocomplete(history::HistoryBackend* backend, | 250 void DoAutocomplete(history::HistoryBackend* backend, |
| 246 history::URLDatabase* db, | 251 history::URLDatabase* db, |
| 247 HistoryURLProviderParams* params); | 252 HistoryURLProviderParams* params); |
| 248 | 253 |
| 249 // May promote either the what you typed match or first history match in | 254 // May promote the what you typed match, the first history match in |
| 250 // params->matches to the front of |matches_|, depending on the value of | 255 // params->matches, or both to the front of |matches_|, depending on the |
| 251 // params->promote_type. | 256 // values of params->promote_type, params->have_what_you_typed_match, and |
| 252 void PromoteMatchIfNecessary(const HistoryURLProviderParams& params); | 257 // params->prevent_inline_autocomplete. |
| 258 void PromoteMatchesIfNecessary(const HistoryURLProviderParams& params); |
| 253 | 259 |
| 254 // Dispatches the results to the autocomplete controller. Called on the | 260 // Dispatches the results to the autocomplete controller. Called on the |
| 255 // main thread by ExecuteWithDB when the results are available. | 261 // main thread by ExecuteWithDB when the results are available. |
| 256 // Frees params_gets_deleted on exit. | 262 // Frees params_gets_deleted on exit. |
| 257 void QueryComplete(HistoryURLProviderParams* params_gets_deleted); | 263 void QueryComplete(HistoryURLProviderParams* params_gets_deleted); |
| 258 | 264 |
| 259 // Looks up the info for params->what_you_typed_match in the DB. If found, | 265 // Looks up the info for params->what_you_typed_match in the DB. If found, |
| 260 // fills in the title, promotes the match's priority to that of an inline | 266 // fills in the title, promotes the match's priority to that of an inline |
| 261 // autocomplete match (maybe it should be slightly better?), and places it on | 267 // autocomplete match (maybe it should be slightly better?), and places it on |
| 262 // the front of params->matches (so we pick the right matches to throw away | 268 // the front of params->matches (so we pick the right matches to throw away |
| (...skipping 11 matching lines...) Expand all Loading... |
| 274 // Sees if a shorter version of the best match should be created, and if so | 280 // Sees if a shorter version of the best match should be created, and if so |
| 275 // places it at the front of params->matches. This can suggest history URLs | 281 // places it at the front of params->matches. This can suggest history URLs |
| 276 // that are prefixes of the best match (if they've been visited enough, | 282 // that are prefixes of the best match (if they've been visited enough, |
| 277 // compared to the best match), or create host-only suggestions even when they | 283 // compared to the best match), or create host-only suggestions even when they |
| 278 // haven't been visited before: if the user visited http://example.com/asdf | 284 // haven't been visited before: if the user visited http://example.com/asdf |
| 279 // once, we'll suggest http://example.com/ even if they've never been to it. | 285 // once, we'll suggest http://example.com/ even if they've never been to it. |
| 280 // Returns true if a match was successfully created/promoted that we're | 286 // Returns true if a match was successfully created/promoted that we're |
| 281 // willing to inline autocomplete. | 287 // willing to inline autocomplete. |
| 282 bool PromoteOrCreateShorterSuggestion( | 288 bool PromoteOrCreateShorterSuggestion( |
| 283 history::URLDatabase* db, | 289 history::URLDatabase* db, |
| 284 bool have_what_you_typed_match, | |
| 285 HistoryURLProviderParams* params); | 290 HistoryURLProviderParams* params); |
| 286 | 291 |
| 287 // Removes results that have been rarely typed or visited, and not any time | 292 // Removes results that have been rarely typed or visited, and not any time |
| 288 // recently. The exact parameters for this heuristic can be found in the | 293 // recently. The exact parameters for this heuristic can be found in the |
| 289 // function body. Also culls results corresponding to queries from the default | 294 // function body. Also culls results corresponding to queries from the default |
| 290 // search engine. These are low-quality, difficult-to-understand matches for | 295 // search engine. These are low-quality, difficult-to-understand matches for |
| 291 // users, and the SearchProvider should surface past queries in a better way | 296 // users, and the SearchProvider should surface past queries in a better way |
| 292 // anyway. | 297 // anyway. |
| 293 void CullPoorMatches(HistoryURLProviderParams* params) const; | 298 void CullPoorMatches(HistoryURLProviderParams* params) const; |
| 294 | 299 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 // keep this member is so we can set the cancel bit on it. | 333 // keep this member is so we can set the cancel bit on it. |
| 329 HistoryURLProviderParams* params_; | 334 HistoryURLProviderParams* params_; |
| 330 | 335 |
| 331 // Params controlling experimental behavior of this provider. | 336 // Params controlling experimental behavior of this provider. |
| 332 HUPScoringParams scoring_params_; | 337 HUPScoringParams scoring_params_; |
| 333 | 338 |
| 334 DISALLOW_COPY_AND_ASSIGN(HistoryURLProvider); | 339 DISALLOW_COPY_AND_ASSIGN(HistoryURLProvider); |
| 335 }; | 340 }; |
| 336 | 341 |
| 337 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_ | 342 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_ |
| OLD | NEW |