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 "components/omnibox/browser/base_search_provider.h" | 5 #include "components/omnibox/browser/base_search_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 AutocompleteMatch::AddLastClassificationIfNecessary( | 232 AutocompleteMatch::AddLastClassificationIfNecessary( |
233 &match.description_class, 0, ACMatchClassification::NONE); | 233 &match.description_class, 0, ACMatchClassification::NONE); |
234 } | 234 } |
235 | 235 |
236 // suggestion.match_contents() should have already been collapsed. | 236 // suggestion.match_contents() should have already been collapsed. |
237 match.allowed_to_be_default_match = | 237 match.allowed_to_be_default_match = |
238 (!in_keyword_mode || suggestion.from_keyword_provider()) && | 238 (!in_keyword_mode || suggestion.from_keyword_provider()) && |
239 (base::CollapseWhitespace(input.text(), false) == | 239 (base::CollapseWhitespace(input.text(), false) == |
240 suggestion.match_contents()); | 240 suggestion.match_contents()); |
241 | 241 |
242 // When the user forced a query, we need to make sure all the fill_into_edit | |
243 // values preserve that property. Otherwise, if the user starts editing a | |
244 // suggestion, non-Search results will suddenly appear. | |
245 if (input.type() == metrics::OmniboxInputType::FORCED_QUERY) | |
246 match.fill_into_edit.assign(base::ASCIIToUTF16("?")); | |
247 if (suggestion.from_keyword_provider()) | 242 if (suggestion.from_keyword_provider()) |
248 match.fill_into_edit.append(match.keyword + base::char16(' ')); | 243 match.fill_into_edit.append(match.keyword + base::char16(' ')); |
249 // We only allow inlinable navsuggestions that were received before the | 244 // We only allow inlinable navsuggestions that were received before the |
250 // last keystroke because we don't want asynchronous inline autocompletions. | 245 // last keystroke because we don't want asynchronous inline autocompletions. |
251 if (!input.prevent_inline_autocomplete() && | 246 if (!input.prevent_inline_autocomplete() && |
252 !suggestion.received_after_last_keystroke() && | 247 !suggestion.received_after_last_keystroke() && |
253 (!in_keyword_mode || suggestion.from_keyword_provider()) && | 248 (!in_keyword_mode || suggestion.from_keyword_provider()) && |
254 base::StartsWith( | 249 base::StartsWith( |
255 base::i18n::ToLower(suggestion.suggestion()), | 250 base::i18n::ToLower(suggestion.suggestion()), |
256 base::i18n::ToLower(input.text()), base::CompareCase::SENSITIVE)) { | 251 base::i18n::ToLower(input.text()), base::CompareCase::SENSITIVE)) { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 | 476 |
482 void BaseSearchProvider::OnDeletionComplete( | 477 void BaseSearchProvider::OnDeletionComplete( |
483 bool success, SuggestionDeletionHandler* handler) { | 478 bool success, SuggestionDeletionHandler* handler) { |
484 RecordDeletionResult(success); | 479 RecordDeletionResult(success); |
485 deletion_handlers_.erase(std::remove_if( | 480 deletion_handlers_.erase(std::remove_if( |
486 deletion_handlers_.begin(), deletion_handlers_.end(), | 481 deletion_handlers_.begin(), deletion_handlers_.end(), |
487 [handler](const std::unique_ptr<SuggestionDeletionHandler>& elem) { | 482 [handler](const std::unique_ptr<SuggestionDeletionHandler>& elem) { |
488 return elem.get() == handler; | 483 return elem.get() == handler; |
489 })); | 484 })); |
490 } | 485 } |
OLD | NEW |