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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 AutocompleteMatch::AddLastClassificationIfNecessary( | 231 AutocompleteMatch::AddLastClassificationIfNecessary( |
232 &match.description_class, 0, ACMatchClassification::NONE); | 232 &match.description_class, 0, ACMatchClassification::NONE); |
233 } | 233 } |
234 | 234 |
235 // suggestion.match_contents() should have already been collapsed. | 235 // suggestion.match_contents() should have already been collapsed. |
236 match.allowed_to_be_default_match = | 236 match.allowed_to_be_default_match = |
237 (!in_keyword_mode || suggestion.from_keyword_provider()) && | 237 (!in_keyword_mode || suggestion.from_keyword_provider()) && |
238 (base::CollapseWhitespace(input.text(), false) == | 238 (base::CollapseWhitespace(input.text(), false) == |
239 suggestion.match_contents()); | 239 suggestion.match_contents()); |
240 | 240 |
241 // When the user forced a query, we need to make sure all the fill_into_edit | |
242 // values preserve that property. Otherwise, if the user starts editing a | |
243 // suggestion, non-Search results will suddenly appear. | |
244 if (input.type() == metrics::OmniboxInputType::FORCED_QUERY) | |
245 match.fill_into_edit.assign(base::ASCIIToUTF16("?")); | |
246 if (suggestion.from_keyword_provider()) | 241 if (suggestion.from_keyword_provider()) |
247 match.fill_into_edit.append(match.keyword + base::char16(' ')); | 242 match.fill_into_edit.append(match.keyword + base::char16(' ')); |
248 // We only allow inlinable navsuggestions that were received before the | 243 // We only allow inlinable navsuggestions that were received before the |
249 // last keystroke because we don't want asynchronous inline autocompletions. | 244 // last keystroke because we don't want asynchronous inline autocompletions. |
250 if (!input.prevent_inline_autocomplete() && | 245 if (!input.prevent_inline_autocomplete() && |
251 !suggestion.received_after_last_keystroke() && | 246 !suggestion.received_after_last_keystroke() && |
252 (!in_keyword_mode || suggestion.from_keyword_provider()) && | 247 (!in_keyword_mode || suggestion.from_keyword_provider()) && |
253 base::StartsWith( | 248 base::StartsWith( |
254 base::i18n::ToLower(suggestion.suggestion()), | 249 base::i18n::ToLower(suggestion.suggestion()), |
255 base::i18n::ToLower(input.text()), base::CompareCase::SENSITIVE)) { | 250 base::i18n::ToLower(input.text()), base::CompareCase::SENSITIVE)) { |
(...skipping 225 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 scoped_ptr<SuggestionDeletionHandler>& elem) { | 482 [handler](const scoped_ptr<SuggestionDeletionHandler>& elem) { |
488 return elem.get() == handler; | 483 return elem.get() == handler; |
489 })); | 484 })); |
490 } | 485 } |
OLD | NEW |