Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: chrome/browser/autocomplete/autocomplete_input.h

Issue 12623029: Upstreaming mechanism to add query refinement to omnibox searches. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applied Peter's comments. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 may generate an image search URL.
61 // Query refinement is only used by mobile ports, so only these set
62 // |current_url| to a non-empty string.
63 //
58 // |prevent_inline_autocomplete| is true if the generated result set should 64 // |prevent_inline_autocomplete| is true if the generated result set should
59 // not require inline autocomplete for the default match. This is difficult 65 // 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 66 // 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 67 // deletes text in the edit, the HistoryURLProvider should make sure not to
62 // promote a match requiring inline autocomplete too highly. 68 // promote a match requiring inline autocomplete too highly.
63 // 69 //
64 // |prefer_keyword| should be true when the keyword UI is onscreen; this will 70 // |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 71 // bias the autocomplete result set toward the keyword provider when the input
66 // string is a bare keyword. 72 // string is a bare keyword.
67 // 73 //
68 // |allow_exact_keyword_match| should be false when triggering keyword mode on 74 // |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 75 // 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 76 // in a page and telling the browser to search for it or navigate to it. This
71 // parameter only applies to substituting keywords. 77 // parameter only applies to substituting keywords.
72 78
73 // If |matches_requested| is BEST_MATCH or SYNCHRONOUS_MATCHES the controller 79 // If |matches_requested| is BEST_MATCH or SYNCHRONOUS_MATCHES the controller
74 // asks the providers to only return matches which are synchronously 80 // asks the providers to only return matches which are synchronously
75 // available, which should mean that all providers will be done immediately. 81 // available, which should mean that all providers will be done immediately.
76 AutocompleteInput(const string16& text, 82 AutocompleteInput(const string16& text,
77 size_t cursor_position, 83 size_t cursor_position,
78 const string16& desired_tld, 84 const string16& desired_tld,
85 const GURL& current_url,
79 bool prevent_inline_autocomplete, 86 bool prevent_inline_autocomplete,
80 bool prefer_keyword, 87 bool prefer_keyword,
81 bool allow_exact_keyword_match, 88 bool allow_exact_keyword_match,
82 MatchesRequested matches_requested); 89 MatchesRequested matches_requested);
83 ~AutocompleteInput(); 90 ~AutocompleteInput();
84 91
85 // If type is |FORCED_QUERY| and |text| starts with '?', it is removed. 92 // If type is |FORCED_QUERY| and |text| starts with '?', it is removed.
86 // Returns number of leading characters removed. 93 // Returns number of leading characters removed.
87 static size_t RemoveForcedQueryStringIfNecessary(Type type, string16* text); 94 static size_t RemoveForcedQueryStringIfNecessary(Type type, string16* text);
88 95
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // used. 135 // used.
129 size_t cursor_position() const { return cursor_position_; } 136 size_t cursor_position() const { return cursor_position_; }
130 137
131 // Use of this setter is risky, since no other internal state is updated 138 // Use of this setter is risky, since no other internal state is updated
132 // besides |text_|, |cursor_position_| and |parts_|. Only callers who know 139 // besides |text_|, |cursor_position_| and |parts_|. Only callers who know
133 // that they're not changing the type/scheme/etc. should use this. 140 // that they're not changing the type/scheme/etc. should use this.
134 void UpdateText(const string16& text, 141 void UpdateText(const string16& text,
135 size_t cursor_position, 142 size_t cursor_position,
136 const url_parse::Parsed& parts); 143 const url_parse::Parsed& parts);
137 144
145 // The current URL, or an invalid GURL if query refinement is not desired.
146 const GURL& current_url() const { return current_url_; }
147
138 // The type of input supplied. 148 // The type of input supplied.
139 Type type() const { return type_; } 149 Type type() const { return type_; }
140 150
141 // Returns parsed URL components. 151 // Returns parsed URL components.
142 const url_parse::Parsed& parts() const { return parts_; } 152 const url_parse::Parsed& parts() const { return parts_; }
143 153
144 // The scheme parsed from the provided text; only meaningful when type_ is 154 // The scheme parsed from the provided text; only meaningful when type_ is
145 // URL. 155 // URL.
146 const string16& scheme() const { return scheme_; } 156 const string16& scheme() const { return scheme_; }
147 157
(...skipping 18 matching lines...) Expand all
166 MatchesRequested matches_requested() const { return matches_requested_; } 176 MatchesRequested matches_requested() const { return matches_requested_; }
167 177
168 // Resets all internal variables to the null-constructed state. 178 // Resets all internal variables to the null-constructed state.
169 void Clear(); 179 void Clear();
170 180
171 private: 181 private:
172 // NOTE: Whenever adding a new field here, please make sure to update Clear() 182 // NOTE: Whenever adding a new field here, please make sure to update Clear()
173 // method. 183 // method.
174 string16 text_; 184 string16 text_;
175 size_t cursor_position_; 185 size_t cursor_position_;
186 GURL current_url_;
176 Type type_; 187 Type type_;
177 url_parse::Parsed parts_; 188 url_parse::Parsed parts_;
178 string16 scheme_; 189 string16 scheme_;
179 GURL canonicalized_url_; 190 GURL canonicalized_url_;
180 bool prevent_inline_autocomplete_; 191 bool prevent_inline_autocomplete_;
181 bool prefer_keyword_; 192 bool prefer_keyword_;
182 bool allow_exact_keyword_match_; 193 bool allow_exact_keyword_match_;
183 MatchesRequested matches_requested_; 194 MatchesRequested matches_requested_;
184 }; 195 };
185 196
186 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_INPUT_H_ 197 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_INPUT_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_classifier.cc ('k') | chrome/browser/autocomplete/autocomplete_input.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698