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