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 #include "chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h" | 5 #include "chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 return false; | 168 return false; |
169 *is_typed_host = url_db->IsTypedHost(UTF16ToUTF8(host)); | 169 *is_typed_host = url_db->IsTypedHost(UTF16ToUTF8(host)); |
170 return true; | 170 return true; |
171 } | 171 } |
172 | 172 |
173 void OmniboxUIHandler::StartOmniboxQuery(const base::ListValue* input) { | 173 void OmniboxUIHandler::StartOmniboxQuery(const base::ListValue* input) { |
174 DCHECK_EQ(4u, input->GetSize()); | 174 DCHECK_EQ(4u, input->GetSize()); |
175 string16 input_string; | 175 string16 input_string; |
176 bool return_val = input->GetString(0, &input_string); | 176 bool return_val = input->GetString(0, &input_string); |
177 DCHECK(return_val); | 177 DCHECK(return_val); |
178 int cursor_position_int; | 178 int cursor_position; |
179 return_val = input->GetInteger(1, &cursor_position_int); | 179 return_val = input->GetInteger(1, &cursor_position); |
180 DCHECK(return_val); | 180 DCHECK(return_val); |
181 size_t cursor_position = cursor_position_int; | |
182 bool prevent_inline_autocomplete; | 181 bool prevent_inline_autocomplete; |
183 return_val = input->GetBoolean(2, &prevent_inline_autocomplete); | 182 return_val = input->GetBoolean(2, &prevent_inline_autocomplete); |
184 DCHECK(return_val); | 183 DCHECK(return_val); |
185 bool prefer_keyword; | 184 bool prefer_keyword; |
186 return_val = input->GetBoolean(3, &prefer_keyword); | 185 return_val = input->GetBoolean(3, &prefer_keyword); |
187 DCHECK(return_val); | 186 DCHECK(return_val); |
188 string16 empty_string; | |
189 // Reset the controller. If we don't do this, then the | 187 // Reset the controller. If we don't do this, then the |
190 // AutocompleteController might inappropriately set its |minimal_changes| | 188 // AutocompleteController might inappropriately set its |minimal_changes| |
191 // variable (or something else) and some providers will short-circuit | 189 // variable (or something else) and some providers will short-circuit |
192 // important logic and return stale results. In short, we want the | 190 // important logic and return stale results. In short, we want the |
193 // actual results to not depend on the state of the previous request. | 191 // actual results to not depend on the state of the previous request. |
194 ResetController(); | 192 ResetController(); |
195 time_omnibox_started_ = base::Time::Now(); | 193 time_omnibox_started_ = base::Time::Now(); |
196 controller_->Start(AutocompleteInput( | 194 controller_->Start(AutocompleteInput( |
197 input_string, | 195 input_string, |
198 cursor_position, | 196 cursor_position, |
199 empty_string, // user's desired tld (top-level domain) | 197 string16(), // user's desired tld (top-level domain) |
| 198 GURL(), |
200 prevent_inline_autocomplete, | 199 prevent_inline_autocomplete, |
201 prefer_keyword, | 200 prefer_keyword, |
202 true, // allow exact keyword matches | 201 true, // allow exact keyword matches |
203 AutocompleteInput::ALL_MATCHES)); // want all matches | 202 AutocompleteInput::ALL_MATCHES)); // want all matches |
204 } | 203 } |
205 | 204 |
206 void OmniboxUIHandler::ResetController() { | 205 void OmniboxUIHandler::ResetController() { |
207 controller_.reset(new AutocompleteController(profile_, this, | 206 controller_.reset(new AutocompleteController(profile_, this, |
208 chrome::search::IsInstantExtendedAPIEnabled() ? | 207 chrome::search::IsInstantExtendedAPIEnabled() ? |
209 AutocompleteClassifier::kInstantExtendedOmniboxProviders : | 208 AutocompleteClassifier::kInstantExtendedOmniboxProviders : |
210 AutocompleteClassifier::kDefaultOmniboxProviders)); | 209 AutocompleteClassifier::kDefaultOmniboxProviders)); |
211 } | 210 } |
OLD | NEW |