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/base_search_provider.h" | 5 #include "components/omnibox/base_search_provider.h" |
6 | 6 |
7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/metrics/proto/omnibox_event.pb.h" | 10 #include "components/metrics/proto/omnibox_event.pb.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // suggestion, non-Search results will suddenly appear. | 236 // suggestion, non-Search results will suddenly appear. |
237 if (input.type() == metrics::OmniboxInputType::FORCED_QUERY) | 237 if (input.type() == metrics::OmniboxInputType::FORCED_QUERY) |
238 match.fill_into_edit.assign(base::ASCIIToUTF16("?")); | 238 match.fill_into_edit.assign(base::ASCIIToUTF16("?")); |
239 if (suggestion.from_keyword_provider()) | 239 if (suggestion.from_keyword_provider()) |
240 match.fill_into_edit.append(match.keyword + base::char16(' ')); | 240 match.fill_into_edit.append(match.keyword + base::char16(' ')); |
241 // We only allow inlinable navsuggestions that were received before the | 241 // We only allow inlinable navsuggestions that were received before the |
242 // last keystroke because we don't want asynchronous inline autocompletions. | 242 // last keystroke because we don't want asynchronous inline autocompletions. |
243 if (!input.prevent_inline_autocomplete() && | 243 if (!input.prevent_inline_autocomplete() && |
244 !suggestion.received_after_last_keystroke() && | 244 !suggestion.received_after_last_keystroke() && |
245 (!in_keyword_mode || suggestion.from_keyword_provider()) && | 245 (!in_keyword_mode || suggestion.from_keyword_provider()) && |
246 base::StartsWith(suggestion.suggestion(), input.text(), false)) { | 246 base::StartsWith( |
| 247 base::i18n::ToLower(suggestion.suggestion()), |
| 248 base::i18n::ToLower(input.text()), base::CompareCase::SENSITIVE)) { |
247 match.inline_autocompletion = | 249 match.inline_autocompletion = |
248 suggestion.suggestion().substr(input.text().length()); | 250 suggestion.suggestion().substr(input.text().length()); |
249 match.allowed_to_be_default_match = true; | 251 match.allowed_to_be_default_match = true; |
250 } | 252 } |
251 match.fill_into_edit.append(suggestion.suggestion()); | 253 match.fill_into_edit.append(suggestion.suggestion()); |
252 | 254 |
253 const TemplateURLRef& search_url = template_url->url_ref(); | 255 const TemplateURLRef& search_url = template_url->url_ref(); |
254 DCHECK(search_url.SupportsReplacement(search_terms_data)); | 256 DCHECK(search_url.SupportsReplacement(search_terms_data)); |
255 match.search_terms_args.reset( | 257 match.search_terms_args.reset( |
256 new TemplateURLRef::SearchTermsArgs(suggestion.suggestion())); | 258 new TemplateURLRef::SearchTermsArgs(suggestion.suggestion())); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 } | 476 } |
475 | 477 |
476 void BaseSearchProvider::OnDeletionComplete( | 478 void BaseSearchProvider::OnDeletionComplete( |
477 bool success, SuggestionDeletionHandler* handler) { | 479 bool success, SuggestionDeletionHandler* handler) { |
478 RecordDeletionResult(success); | 480 RecordDeletionResult(success); |
479 SuggestionDeletionHandlers::iterator it = std::find( | 481 SuggestionDeletionHandlers::iterator it = std::find( |
480 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 482 deletion_handlers_.begin(), deletion_handlers_.end(), handler); |
481 DCHECK(it != deletion_handlers_.end()); | 483 DCHECK(it != deletion_handlers_.end()); |
482 deletion_handlers_.erase(it); | 484 deletion_handlers_.erase(it); |
483 } | 485 } |
OLD | NEW |