| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 9 #include <vector> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // Comparison functions for removing matches with duplicate destinations. | 101 // Comparison functions for removing matches with duplicate destinations. |
| 102 static bool DestinationSortFunc(const AutocompleteMatch& elem1, | 102 static bool DestinationSortFunc(const AutocompleteMatch& elem1, |
| 103 const AutocompleteMatch& elem2); | 103 const AutocompleteMatch& elem2); |
| 104 static bool DestinationsEqual(const AutocompleteMatch& elem1, | 104 static bool DestinationsEqual(const AutocompleteMatch& elem1, |
| 105 const AutocompleteMatch& elem2); | 105 const AutocompleteMatch& elem2); |
| 106 | 106 |
| 107 // Helper functions for classes creating matches: | 107 // Helper functions for classes creating matches: |
| 108 // Fills in the classifications for |text|, using |style| as the base style | 108 // Fills in the classifications for |text|, using |style| as the base style |
| 109 // and marking the first instance of |find_text| as a match. (This match | 109 // and marking the first instance of |find_text| as a match. (This match |
| 110 // will also not be dimmed, if |style| has DIM set.) | 110 // will also not be dimmed, if |style| has DIM set.) |
| 111 static void ClassifyMatchInString(const std::wstring& find_text, | 111 static void ClassifyMatchInString(const string16& find_text, |
| 112 const std::wstring& text, | 112 const string16& text, |
| 113 int style, | 113 int style, |
| 114 ACMatchClassifications* classifications); | 114 ACMatchClassifications* classifications); |
| 115 | 115 |
| 116 // Similar to ClassifyMatchInString(), but for cases where the range to mark | 116 // Similar to ClassifyMatchInString(), but for cases where the range to mark |
| 117 // as matching is already known (avoids calling find()). This can be helpful | 117 // as matching is already known (avoids calling find()). This can be helpful |
| 118 // when find() would be misleading (e.g. you want to mark the second match in | 118 // when find() would be misleading (e.g. you want to mark the second match in |
| 119 // a string instead of the first). | 119 // a string instead of the first). |
| 120 static void ClassifyLocationInString(size_t match_location, | 120 static void ClassifyLocationInString(size_t match_location, |
| 121 size_t match_length, | 121 size_t match_length, |
| 122 size_t overall_length, | 122 size_t overall_length, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 136 // TODO(pkasting): http://b/1111299 This should be calculated algorithmically, | 136 // TODO(pkasting): http://b/1111299 This should be calculated algorithmically, |
| 137 // rather than being a fairly fixed value defined by the table above. | 137 // rather than being a fairly fixed value defined by the table above. |
| 138 int relevance; | 138 int relevance; |
| 139 | 139 |
| 140 // True if the user should be able to delete this match. | 140 // True if the user should be able to delete this match. |
| 141 bool deletable; | 141 bool deletable; |
| 142 | 142 |
| 143 // This string is loaded into the location bar when the item is selected | 143 // This string is loaded into the location bar when the item is selected |
| 144 // by pressing the arrow keys. This may be different than a URL, for example, | 144 // by pressing the arrow keys. This may be different than a URL, for example, |
| 145 // for search suggestions, this would just be the search terms. | 145 // for search suggestions, this would just be the search terms. |
| 146 std::wstring fill_into_edit; | 146 string16 fill_into_edit; |
| 147 | 147 |
| 148 // The position within fill_into_edit from which we'll display the inline | 148 // The position within fill_into_edit from which we'll display the inline |
| 149 // autocomplete string. This will be std::wstring::npos if this match should | 149 // autocomplete string. This will be string16::npos if this match should |
| 150 // not be inline autocompleted. | 150 // not be inline autocompleted. |
| 151 size_t inline_autocomplete_offset; | 151 size_t inline_autocomplete_offset; |
| 152 | 152 |
| 153 // The URL to actually load when the autocomplete item is selected. This URL | 153 // The URL to actually load when the autocomplete item is selected. This URL |
| 154 // should be canonical so we can compare URLs with strcmp to avoid dupes. | 154 // should be canonical so we can compare URLs with strcmp to avoid dupes. |
| 155 // It may be empty if there is no possible navigation. | 155 // It may be empty if there is no possible navigation. |
| 156 GURL destination_url; | 156 GURL destination_url; |
| 157 | 157 |
| 158 // The main text displayed in the address bar dropdown. | 158 // The main text displayed in the address bar dropdown. |
| 159 std::wstring contents; | 159 string16 contents; |
| 160 ACMatchClassifications contents_class; | 160 ACMatchClassifications contents_class; |
| 161 | 161 |
| 162 // Additional helper text for each entry, such as a title or description. | 162 // Additional helper text for each entry, such as a title or description. |
| 163 std::wstring description; | 163 string16 description; |
| 164 ACMatchClassifications description_class; | 164 ACMatchClassifications description_class; |
| 165 | 165 |
| 166 // The transition type to use when the user opens this match. By default | 166 // The transition type to use when the user opens this match. By default |
| 167 // this is TYPED. Providers whose matches do not look like URLs should set | 167 // this is TYPED. Providers whose matches do not look like URLs should set |
| 168 // it to GENERATED. | 168 // it to GENERATED. |
| 169 PageTransition::Type transition; | 169 PageTransition::Type transition; |
| 170 | 170 |
| 171 // True when this match is the "what you typed" match from the history | 171 // True when this match is the "what you typed" match from the history |
| 172 // system. | 172 // system. |
| 173 bool is_history_what_you_typed_match; | 173 bool is_history_what_you_typed_match; |
| 174 | 174 |
| 175 // Type of this match. | 175 // Type of this match. |
| 176 Type type; | 176 Type type; |
| 177 | 177 |
| 178 // If this match corresponds to a keyword, this is the TemplateURL the | 178 // If this match corresponds to a keyword, this is the TemplateURL the |
| 179 // keyword was obtained from. | 179 // keyword was obtained from. |
| 180 const TemplateURL* template_url; | 180 const TemplateURL* template_url; |
| 181 | 181 |
| 182 // True if the user has starred the destination URL. | 182 // True if the user has starred the destination URL. |
| 183 bool starred; | 183 bool starred; |
| 184 | 184 |
| 185 #ifndef NDEBUG | 185 #ifndef NDEBUG |
| 186 // Does a data integrity check on this match. | 186 // Does a data integrity check on this match. |
| 187 void Validate() const; | 187 void Validate() const; |
| 188 | 188 |
| 189 // Checks one text/classifications pair for valid values. | 189 // Checks one text/classifications pair for valid values. |
| 190 void ValidateClassifications( | 190 void ValidateClassifications( |
| 191 const std::wstring& text, | 191 const string16& text, |
| 192 const ACMatchClassifications& classifications) const; | 192 const ACMatchClassifications& classifications) const; |
| 193 #endif | 193 #endif |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 196 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
| 197 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 197 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
| 198 | 198 |
| 199 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 199 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
| OLD | NEW |