Chromium Code Reviews| 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_AUTOCOMPLETE_MATCH_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | |
| 9 #include <string> | 10 #include <string> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/search_engines/template_url.h" | 14 #include "chrome/browser/search_engines/template_url.h" |
| 14 #include "content/public/common/page_transition_types.h" | 15 #include "content/public/common/page_transition_types.h" |
| 15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 16 | 17 |
| 17 class AutocompleteProvider; | 18 class AutocompleteProvider; |
| 18 class Profile; | 19 class Profile; |
| 19 class TemplateURL; | 20 class TemplateURL; |
| 20 | 21 |
| 22 namespace base { | |
| 23 class Time; | |
| 24 } // namespace base | |
| 25 | |
| 21 // AutocompleteMatch ---------------------------------------------------------- | 26 // AutocompleteMatch ---------------------------------------------------------- |
| 22 | 27 |
| 23 // A single result line with classified spans. The autocomplete popup displays | 28 // A single result line with classified spans. The autocomplete popup displays |
| 24 // the 'contents' and the 'description' (the description is optional) in the | 29 // the 'contents' and the 'description' (the description is optional) in the |
| 25 // autocomplete dropdown, and fills in 'fill_into_edit' into the textbox when | 30 // autocomplete dropdown, and fills in 'fill_into_edit' into the textbox when |
| 26 // that line is selected. fill_into_edit may be the same as 'description' for | 31 // that line is selected. fill_into_edit may be the same as 'description' for |
| 27 // things like URLs, but may be different for searches or other providers. For | 32 // things like URLs, but may be different for searches or other providers. For |
| 28 // example, a search result may say "Search for asdf" as the description, but | 33 // example, a search result may say "Search for asdf" as the description, but |
| 29 // "asdf" should appear in the box. | 34 // "asdf" should appear in the box. |
| 30 struct AutocompleteMatch { | 35 struct AutocompleteMatch { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 // invoke its keyword), this returns the empty string. The result is that | 188 // invoke its keyword), this returns the empty string. The result is that |
| 184 // this function returns a non-empty string in the same cases as when the UI | 189 // this function returns a non-empty string in the same cases as when the UI |
| 185 // should show up as being "in keyword mode". | 190 // should show up as being "in keyword mode". |
| 186 string16 GetSubstitutingExplicitlyInvokedKeyword(Profile* profile) const; | 191 string16 GetSubstitutingExplicitlyInvokedKeyword(Profile* profile) const; |
| 187 | 192 |
| 188 // Returns the TemplateURL associated with this match. This may be NULL if | 193 // Returns the TemplateURL associated with this match. This may be NULL if |
| 189 // the match has no keyword OR if the keyword no longer corresponds to a valid | 194 // the match has no keyword OR if the keyword no longer corresponds to a valid |
| 190 // TemplateURL. See comments on |keyword| below. | 195 // TemplateURL. See comments on |keyword| below. |
| 191 TemplateURL* GetTemplateURL(Profile* profile) const; | 196 TemplateURL* GetTemplateURL(Profile* profile) const; |
| 192 | 197 |
| 198 // Adds logging information to the logging dictionary |info_log|. | |
|
Mark P
2012/07/10 14:51:34
Please don't call this type of information (displa
mrossetti
2012/07/10 17:57:08
Excellent suggestion! I want with forms of the wor
| |
| 199 void LogInfo(const std::string& title, const std::string& value); | |
|
Mark P
2012/07/10 14:51:34
Title feels to me a bit odd. Consider something e
mrossetti
2012/07/10 17:57:08
In this case, I went with 'property'.
| |
| 200 void LogInfo(const std::string& title, int value); | |
| 201 void LogInfo(const std::string& title, const base::Time& value); | |
| 202 | |
| 193 // The provider of this match, used to remember which provider the user had | 203 // The provider of this match, used to remember which provider the user had |
| 194 // selected when the input changes. This may be NULL, in which case there is | 204 // selected when the input changes. This may be NULL, in which case there is |
| 195 // no provider (or memory of the user's selection). | 205 // no provider (or memory of the user's selection). |
| 196 AutocompleteProvider* provider; | 206 AutocompleteProvider* provider; |
| 197 | 207 |
| 198 // The relevance of this match. See table in autocomplete.h for scores | 208 // The relevance of this match. See table in autocomplete.h for scores |
| 199 // returned by various providers. This is used to rank matches among all | 209 // returned by various providers. This is used to rank matches among all |
| 200 // responding providers, so different providers must be carefully tuned to | 210 // responding providers, so different providers must be carefully tuned to |
| 201 // supply matches with appropriate relevance. | 211 // supply matches with appropriate relevance. |
| 202 // | 212 // |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 | 287 |
| 278 // Optional search terms args. If present, | 288 // Optional search terms args. If present, |
| 279 // AutocompleteController::UpdateAssistedQueryStats() will incorporate this | 289 // AutocompleteController::UpdateAssistedQueryStats() will incorporate this |
| 280 // data with additional data it calculates and pass the completed struct to | 290 // data with additional data it calculates and pass the completed struct to |
| 281 // TemplateURLRef::ReplaceSearchTerms() to reset the match's |destination_url| | 291 // TemplateURLRef::ReplaceSearchTerms() to reset the match's |destination_url| |
| 282 // after the complete set of matches in the AutocompleteResult has been chosen | 292 // after the complete set of matches in the AutocompleteResult has been chosen |
| 283 // and sorted. Most providers will leave this as NULL, which will cause the | 293 // and sorted. Most providers will leave this as NULL, which will cause the |
| 284 // AutocompleteController to do no additional transformations. | 294 // AutocompleteController to do no additional transformations. |
| 285 scoped_ptr<TemplateURLRef::SearchTermsArgs> search_terms_args; | 295 scoped_ptr<TemplateURLRef::SearchTermsArgs> search_terms_args; |
| 286 | 296 |
| 297 // Logging information dictionary into which each provider can optionally | |
| 298 // include a title as key and associated data. | |
| 299 std::map<std::string, std::string> info_log; | |
| 300 | |
| 287 #ifndef NDEBUG | 301 #ifndef NDEBUG |
| 288 // Does a data integrity check on this match. | 302 // Does a data integrity check on this match. |
| 289 void Validate() const; | 303 void Validate() const; |
| 290 | 304 |
| 291 // Checks one text/classifications pair for valid values. | 305 // Checks one text/classifications pair for valid values. |
| 292 void ValidateClassifications( | 306 void ValidateClassifications( |
| 293 const string16& text, | 307 const string16& text, |
| 294 const ACMatchClassifications& classifications) const; | 308 const ACMatchClassifications& classifications) const; |
| 295 #endif | 309 #endif |
| 296 }; | 310 }; |
| 297 | 311 |
| 298 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 312 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
| 299 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 313 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
| 300 typedef std::vector<AutocompleteMatch> ACMatches; | 314 typedef std::vector<AutocompleteMatch> ACMatches; |
| 301 | 315 |
| 302 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 316 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
| OLD | NEW |