OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 // values preserve that property. Otherwise, if the user starts editing a | 867 // values preserve that property. Otherwise, if the user starts editing a |
868 // suggestion, non-Search results will suddenly appear. | 868 // suggestion, non-Search results will suddenly appear. |
869 size_t search_start = 0; | 869 size_t search_start = 0; |
870 if (input_.type() == AutocompleteInput::FORCED_QUERY) { | 870 if (input_.type() == AutocompleteInput::FORCED_QUERY) { |
871 match.fill_into_edit.assign(ASCIIToUTF16("?")); | 871 match.fill_into_edit.assign(ASCIIToUTF16("?")); |
872 ++search_start; | 872 ++search_start; |
873 } | 873 } |
874 if (is_keyword) { | 874 if (is_keyword) { |
875 match.fill_into_edit.append( | 875 match.fill_into_edit.append( |
876 providers_.keyword_provider().keyword() + char16(' ')); | 876 providers_.keyword_provider().keyword() + char16(' ')); |
877 | 877 search_start += providers_.keyword_provider().keyword().size() + 1; |
878 match.keyword = providers_.keyword_provider().keyword(); | |
879 search_start += match.keyword.size() + 1; | |
880 } | 878 } |
881 match.fill_into_edit.append(query_string); | 879 match.fill_into_edit.append(query_string); |
882 // Not all suggestions start with the original input. | 880 // Not all suggestions start with the original input. |
883 if (!prevent_inline_autocomplete && | 881 if (!prevent_inline_autocomplete && |
884 !match.fill_into_edit.compare(search_start, input_text.length(), | 882 !match.fill_into_edit.compare(search_start, input_text.length(), |
885 input_text)) | 883 input_text)) |
886 match.inline_autocomplete_offset = search_start + input_text.length(); | 884 match.inline_autocomplete_offset = search_start + input_text.length(); |
887 | 885 |
888 const TemplateURLRef* const search_url = provider.url(); | 886 const TemplateURLRef* const search_url = provider.url(); |
889 DCHECK(search_url->SupportsReplacement()); | 887 DCHECK(search_url->SupportsReplacement()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 | 943 |
946 return match; | 944 return match; |
947 } | 945 } |
948 | 946 |
949 void SearchProvider::UpdateDone() { | 947 void SearchProvider::UpdateDone() { |
950 // We're done when there are no more suggest queries pending (this is set to 1 | 948 // We're done when there are no more suggest queries pending (this is set to 1 |
951 // when the timer is started) and we're not waiting on instant. | 949 // when the timer is started) and we're not waiting on instant. |
952 done_ = ((suggest_results_pending_ == 0) && | 950 done_ = ((suggest_results_pending_ == 0) && |
953 (instant_finalized_ || !InstantController::IsEnabled(profile_))); | 951 (instant_finalized_ || !InstantController::IsEnabled(profile_))); |
954 } | 952 } |
OLD | NEW |