OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/autocomplete/base_search_provider.h" | 5 #include "chrome/browser/autocomplete/base_search_provider.h" |
6 | 6 |
7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "base/prefs/pref_registry_simple.h" | 8 #include "base/prefs/pref_registry_simple.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 (base::CollapseWhitespace(input.text(), false) == | 248 (base::CollapseWhitespace(input.text(), false) == |
249 suggestion.match_contents()); | 249 suggestion.match_contents()); |
250 | 250 |
251 // When the user forced a query, we need to make sure all the fill_into_edit | 251 // When the user forced a query, we need to make sure all the fill_into_edit |
252 // values preserve that property. Otherwise, if the user starts editing a | 252 // values preserve that property. Otherwise, if the user starts editing a |
253 // suggestion, non-Search results will suddenly appear. | 253 // suggestion, non-Search results will suddenly appear. |
254 if (input.type() == metrics::OmniboxInputType::FORCED_QUERY) | 254 if (input.type() == metrics::OmniboxInputType::FORCED_QUERY) |
255 match.fill_into_edit.assign(base::ASCIIToUTF16("?")); | 255 match.fill_into_edit.assign(base::ASCIIToUTF16("?")); |
256 if (suggestion.from_keyword_provider()) | 256 if (suggestion.from_keyword_provider()) |
257 match.fill_into_edit.append(match.keyword + base::char16(' ')); | 257 match.fill_into_edit.append(match.keyword + base::char16(' ')); |
258 // We only allow inlinable navsuggestions that were received before the | |
msw
2014/08/15 21:27:59
Do we actually want to check received_after_last_k
Mark P
2014/08/15 22:09:22
Line 246 is fine. Verbatim matches are always all
msw
2014/08/15 23:31:10
Ah, I get it now, I mistakenly thought that markin
| |
259 // last keystroke because we don't want asynchronous inline autocompletions. | |
258 if (!input.prevent_inline_autocomplete() && | 260 if (!input.prevent_inline_autocomplete() && |
261 !suggestion.received_after_last_keystroke() && | |
259 (!in_keyword_mode || suggestion.from_keyword_provider()) && | 262 (!in_keyword_mode || suggestion.from_keyword_provider()) && |
260 StartsWith(suggestion.suggestion(), input.text(), false)) { | 263 StartsWith(suggestion.suggestion(), input.text(), false)) { |
261 match.inline_autocompletion = | 264 match.inline_autocompletion = |
262 suggestion.suggestion().substr(input.text().length()); | 265 suggestion.suggestion().substr(input.text().length()); |
263 match.allowed_to_be_default_match = true; | 266 match.allowed_to_be_default_match = true; |
264 } | 267 } |
265 match.fill_into_edit.append(suggestion.suggestion()); | 268 match.fill_into_edit.append(suggestion.suggestion()); |
266 | 269 |
267 const TemplateURLRef& search_url = template_url->url_ref(); | 270 const TemplateURLRef& search_url = template_url->url_ref(); |
268 DCHECK(search_url.SupportsReplacement(search_terms_data)); | 271 DCHECK(search_url.SupportsReplacement(search_terms_data)); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 } | 497 } |
495 | 498 |
496 void BaseSearchProvider::OnDeletionComplete( | 499 void BaseSearchProvider::OnDeletionComplete( |
497 bool success, SuggestionDeletionHandler* handler) { | 500 bool success, SuggestionDeletionHandler* handler) { |
498 RecordDeletionResult(success); | 501 RecordDeletionResult(success); |
499 SuggestionDeletionHandlers::iterator it = std::find( | 502 SuggestionDeletionHandlers::iterator it = std::find( |
500 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 503 deletion_handlers_.begin(), deletion_handlers_.end(), handler); |
501 DCHECK(it != deletion_handlers_.end()); | 504 DCHECK(it != deletion_handlers_.end()); |
502 deletion_handlers_.erase(it); | 505 deletion_handlers_.erase(it); |
503 } | 506 } |
OLD | NEW |