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_INPUT_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_INPUT_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_INPUT_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_INPUT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 // |text| and |cursor_position| represent the input query and location of | 48 // |text| and |cursor_position| represent the input query and location of |
49 // the cursor with the query respectively. |cursor_position| may be set to | 49 // the cursor with the query respectively. |cursor_position| may be set to |
50 // string16::npos if the input |text| doesn't come directly from the user's | 50 // string16::npos if the input |text| doesn't come directly from the user's |
51 // typing. | 51 // typing. |
52 // | 52 // |
53 // |desired_tld| is the user's desired TLD, if one is not already present in | 53 // |desired_tld| is the user's desired TLD, if one is not already present in |
54 // the text to autocomplete. When this is non-empty, it also implies that | 54 // the text to autocomplete. When this is non-empty, it also implies that |
55 // "www." should be prepended to the domain where possible. The |desired_tld| | 55 // "www." should be prepended to the domain where possible. The |desired_tld| |
56 // should not contain a leading '.' (use "com" instead of ".com"). | 56 // should not contain a leading '.' (use "com" instead of ".com"). |
57 // | 57 // |
58 // If |current_url| is set to a valid search result page URL, providers can | |
59 // use it to perform query refinement. For example, if it is set to an image | |
60 // search result page, the search provider will generate an image search URL. | |
Peter Kasting
2013/03/22 20:20:06
Nit: will -> may
I don't see any place in this ch
beaudoin
2013/03/22 23:10:43
Done.
| |
61 // | |
58 // |prevent_inline_autocomplete| is true if the generated result set should | 62 // |prevent_inline_autocomplete| is true if the generated result set should |
59 // not require inline autocomplete for the default match. This is difficult | 63 // not require inline autocomplete for the default match. This is difficult |
60 // to explain in the abstract; the practical use case is that after the user | 64 // to explain in the abstract; the practical use case is that after the user |
61 // deletes text in the edit, the HistoryURLProvider should make sure not to | 65 // deletes text in the edit, the HistoryURLProvider should make sure not to |
62 // promote a match requiring inline autocomplete too highly. | 66 // promote a match requiring inline autocomplete too highly. |
63 // | 67 // |
64 // |prefer_keyword| should be true when the keyword UI is onscreen; this will | 68 // |prefer_keyword| should be true when the keyword UI is onscreen; this will |
65 // bias the autocomplete result set toward the keyword provider when the input | 69 // bias the autocomplete result set toward the keyword provider when the input |
66 // string is a bare keyword. | 70 // string is a bare keyword. |
67 // | 71 // |
68 // |allow_exact_keyword_match| should be false when triggering keyword mode on | 72 // |allow_exact_keyword_match| should be false when triggering keyword mode on |
69 // the input string would be surprising or wrong, e.g. when highlighting text | 73 // the input string would be surprising or wrong, e.g. when highlighting text |
70 // in a page and telling the browser to search for it or navigate to it. This | 74 // in a page and telling the browser to search for it or navigate to it. This |
71 // parameter only applies to substituting keywords. | 75 // parameter only applies to substituting keywords. |
72 | 76 |
73 // If |matches_requested| is BEST_MATCH or SYNCHRONOUS_MATCHES the controller | 77 // If |matches_requested| is BEST_MATCH or SYNCHRONOUS_MATCHES the controller |
74 // asks the providers to only return matches which are synchronously | 78 // asks the providers to only return matches which are synchronously |
75 // available, which should mean that all providers will be done immediately. | 79 // available, which should mean that all providers will be done immediately. |
76 AutocompleteInput(const string16& text, | 80 AutocompleteInput(const string16& text, |
77 size_t cursor_position, | 81 size_t cursor_position, |
78 const string16& desired_tld, | 82 const string16& desired_tld, |
83 const GURL& current_url, | |
79 bool prevent_inline_autocomplete, | 84 bool prevent_inline_autocomplete, |
80 bool prefer_keyword, | 85 bool prefer_keyword, |
81 bool allow_exact_keyword_match, | 86 bool allow_exact_keyword_match, |
82 MatchesRequested matches_requested); | 87 MatchesRequested matches_requested); |
83 ~AutocompleteInput(); | 88 ~AutocompleteInput(); |
84 | 89 |
85 // If type is |FORCED_QUERY| and |text| starts with '?', it is removed. | 90 // If type is |FORCED_QUERY| and |text| starts with '?', it is removed. |
86 // Returns number of leading characters removed. | 91 // Returns number of leading characters removed. |
87 static size_t RemoveForcedQueryStringIfNecessary(Type type, string16* text); | 92 static size_t RemoveForcedQueryStringIfNecessary(Type type, string16* text); |
88 | 93 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 // used. | 133 // used. |
129 size_t cursor_position() const { return cursor_position_; } | 134 size_t cursor_position() const { return cursor_position_; } |
130 | 135 |
131 // Use of this setter is risky, since no other internal state is updated | 136 // Use of this setter is risky, since no other internal state is updated |
132 // besides |text_|, |cursor_position_| and |parts_|. Only callers who know | 137 // besides |text_|, |cursor_position_| and |parts_|. Only callers who know |
133 // that they're not changing the type/scheme/etc. should use this. | 138 // that they're not changing the type/scheme/etc. should use this. |
134 void UpdateText(const string16& text, | 139 void UpdateText(const string16& text, |
135 size_t cursor_position, | 140 size_t cursor_position, |
136 const url_parse::Parsed& parts); | 141 const url_parse::Parsed& parts); |
137 | 142 |
143 // The current URL, or an invalid GURL if query refinement is not desired. | |
144 const GURL& current_url() const { return current_url_; } | |
145 | |
138 // The type of input supplied. | 146 // The type of input supplied. |
139 Type type() const { return type_; } | 147 Type type() const { return type_; } |
140 | 148 |
141 // Returns parsed URL components. | 149 // Returns parsed URL components. |
142 const url_parse::Parsed& parts() const { return parts_; } | 150 const url_parse::Parsed& parts() const { return parts_; } |
143 | 151 |
144 // The scheme parsed from the provided text; only meaningful when type_ is | 152 // The scheme parsed from the provided text; only meaningful when type_ is |
145 // URL. | 153 // URL. |
146 const string16& scheme() const { return scheme_; } | 154 const string16& scheme() const { return scheme_; } |
147 | 155 |
(...skipping 18 matching lines...) Expand all Loading... | |
166 MatchesRequested matches_requested() const { return matches_requested_; } | 174 MatchesRequested matches_requested() const { return matches_requested_; } |
167 | 175 |
168 // Resets all internal variables to the null-constructed state. | 176 // Resets all internal variables to the null-constructed state. |
169 void Clear(); | 177 void Clear(); |
170 | 178 |
171 private: | 179 private: |
172 // NOTE: Whenever adding a new field here, please make sure to update Clear() | 180 // NOTE: Whenever adding a new field here, please make sure to update Clear() |
173 // method. | 181 // method. |
174 string16 text_; | 182 string16 text_; |
175 size_t cursor_position_; | 183 size_t cursor_position_; |
184 GURL current_url_; | |
176 Type type_; | 185 Type type_; |
177 url_parse::Parsed parts_; | 186 url_parse::Parsed parts_; |
178 string16 scheme_; | 187 string16 scheme_; |
179 GURL canonicalized_url_; | 188 GURL canonicalized_url_; |
180 bool prevent_inline_autocomplete_; | 189 bool prevent_inline_autocomplete_; |
181 bool prefer_keyword_; | 190 bool prefer_keyword_; |
182 bool allow_exact_keyword_match_; | 191 bool allow_exact_keyword_match_; |
183 MatchesRequested matches_requested_; | 192 MatchesRequested matches_requested_; |
184 }; | 193 }; |
185 | 194 |
186 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_INPUT_H_ | 195 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_INPUT_H_ |
OLD | NEW |