Chromium Code Reviews| 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 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 865 // values preserve that property. Otherwise, if the user starts editing a | 865 // values preserve that property. Otherwise, if the user starts editing a |
| 866 // suggestion, non-Search results will suddenly appear. | 866 // suggestion, non-Search results will suddenly appear. |
| 867 size_t search_start = 0; | 867 size_t search_start = 0; |
| 868 if (input_.type() == AutocompleteInput::FORCED_QUERY) { | 868 if (input_.type() == AutocompleteInput::FORCED_QUERY) { |
| 869 match.fill_into_edit.assign(ASCIIToUTF16("?")); | 869 match.fill_into_edit.assign(ASCIIToUTF16("?")); |
| 870 ++search_start; | 870 ++search_start; |
| 871 } | 871 } |
| 872 if (is_keyword) { | 872 if (is_keyword) { |
| 873 match.fill_into_edit.append( | 873 match.fill_into_edit.append( |
| 874 providers_.keyword_provider().keyword() + char16(' ')); | 874 providers_.keyword_provider().keyword() + char16(' ')); |
| 875 search_start += providers_.keyword_provider().keyword().size() + 1; | 875 |
| 876 match.template_url = &providers_.keyword_provider(); | |
|
Peter Kasting
2011/07/27 20:18:25
This line isn't necessary (line 823 already does t
| |
| 877 match.keyword = providers_.keyword_provider().keyword(); | |
| 878 search_start += match.keyword.size() + 1; | |
| 876 } | 879 } |
| 877 match.fill_into_edit.append(query_string); | 880 match.fill_into_edit.append(query_string); |
| 878 // Not all suggestions start with the original input. | 881 // Not all suggestions start with the original input. |
| 879 if (!prevent_inline_autocomplete && | 882 if (!prevent_inline_autocomplete && |
| 880 !match.fill_into_edit.compare(search_start, input_text.length(), | 883 !match.fill_into_edit.compare(search_start, input_text.length(), |
| 881 input_text)) | 884 input_text)) |
| 882 match.inline_autocomplete_offset = search_start + input_text.length(); | 885 match.inline_autocomplete_offset = search_start + input_text.length(); |
| 883 | 886 |
| 884 const TemplateURLRef* const search_url = provider.url(); | 887 const TemplateURLRef* const search_url = provider.url(); |
| 885 DCHECK(search_url->SupportsReplacement()); | 888 DCHECK(search_url->SupportsReplacement()); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 915 const NavigationResult& navigation, | 918 const NavigationResult& navigation, |
| 916 int relevance, | 919 int relevance, |
| 917 bool is_keyword) { | 920 bool is_keyword) { |
| 918 const string16& input_text = | 921 const string16& input_text = |
| 919 is_keyword ? keyword_input_text_ : input_.text(); | 922 is_keyword ? keyword_input_text_ : input_.text(); |
| 920 AutocompleteMatch match(this, relevance, false, | 923 AutocompleteMatch match(this, relevance, false, |
| 921 AutocompleteMatch::NAVSUGGEST); | 924 AutocompleteMatch::NAVSUGGEST); |
| 922 match.destination_url = navigation.url; | 925 match.destination_url = navigation.url; |
| 923 match.contents = | 926 match.contents = |
| 924 StringForURLDisplay(navigation.url, true, !HasHTTPScheme(input_text)); | 927 StringForURLDisplay(navigation.url, true, !HasHTTPScheme(input_text)); |
| 925 match.template_url = is_keyword ? &providers_.keyword_provider() : | 928 match.template_url = is_keyword ? &providers_.keyword_provider() : |
|
Peter Kasting
2011/07/29 21:08:44
I don't think it's safe to remove this since AddMa
| |
| 926 &providers_.default_provider(); | 929 &providers_.default_provider(); |
| 927 AutocompleteMatch::ClassifyMatchInString(input_text, match.contents, | 930 AutocompleteMatch::ClassifyMatchInString(input_text, match.contents, |
| 928 ACMatchClassification::URL, | 931 ACMatchClassification::URL, |
| 929 &match.contents_class); | 932 &match.contents_class); |
| 930 | 933 |
| 931 match.description = navigation.site_name; | 934 match.description = navigation.site_name; |
| 932 AutocompleteMatch::ClassifyMatchInString(input_text, navigation.site_name, | 935 AutocompleteMatch::ClassifyMatchInString(input_text, navigation.site_name, |
| 933 ACMatchClassification::NONE, | 936 ACMatchClassification::NONE, |
| 934 &match.description_class); | 937 &match.description_class); |
| 935 | 938 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 946 | 949 |
| 947 return match; | 950 return match; |
| 948 } | 951 } |
| 949 | 952 |
| 950 void SearchProvider::UpdateDone() { | 953 void SearchProvider::UpdateDone() { |
| 951 // We're done when there are no more suggest queries pending (this is set to 1 | 954 // We're done when there are no more suggest queries pending (this is set to 1 |
| 952 // when the timer is started) and we're not waiting on instant. | 955 // when the timer is started) and we're not waiting on instant. |
| 953 done_ = ((suggest_results_pending_ == 0) && | 956 done_ = ((suggest_results_pending_ == 0) && |
| 954 (instant_finalized_ || !InstantController::IsEnabled(profile_))); | 957 (instant_finalized_ || !InstantController::IsEnabled(profile_))); |
| 955 } | 958 } |
| OLD | NEW |