| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 154 } |
| 155 | 155 |
| 156 providers_.Set(default_provider, keyword_provider); | 156 providers_.Set(default_provider, keyword_provider); |
| 157 | 157 |
| 158 if (input.text().empty()) { | 158 if (input.text().empty()) { |
| 159 // User typed "?" alone. Give them a placeholder result indicating what | 159 // User typed "?" alone. Give them a placeholder result indicating what |
| 160 // this syntax does. | 160 // this syntax does. |
| 161 if (default_provider) { | 161 if (default_provider) { |
| 162 AutocompleteMatch match; | 162 AutocompleteMatch match; |
| 163 match.provider = this; | 163 match.provider = this; |
| 164 match.contents.assign(l10n_util::GetString(IDS_EMPTY_KEYWORD_VALUE)); | 164 match.contents.assign(UTF16ToWideHack( |
| 165 l10n_util::GetStringUTF16(IDS_EMPTY_KEYWORD_VALUE))); |
| 165 match.contents_class.push_back( | 166 match.contents_class.push_back( |
| 166 ACMatchClassification(0, ACMatchClassification::NONE)); | 167 ACMatchClassification(0, ACMatchClassification::NONE)); |
| 167 match.description.assign(l10n_util::GetStringF( | 168 match.description.assign(UTF16ToWideHack(l10n_util::GetStringFUTF16( |
| 168 IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION, | 169 IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION, |
| 169 default_provider->AdjustedShortNameForLocaleDirection())); | 170 WideToUTF16Hack( |
| 171 default_provider->AdjustedShortNameForLocaleDirection())))); |
| 170 match.description_class.push_back( | 172 match.description_class.push_back( |
| 171 ACMatchClassification(0, ACMatchClassification::DIM)); | 173 ACMatchClassification(0, ACMatchClassification::DIM)); |
| 172 matches_.push_back(match); | 174 matches_.push_back(match); |
| 173 } | 175 } |
| 174 Stop(); | 176 Stop(); |
| 175 return; | 177 return; |
| 176 } | 178 } |
| 177 | 179 |
| 178 input_ = input; | 180 input_ = input; |
| 179 | 181 |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 ACMatchClassification(next_fragment_position, | 724 ACMatchClassification(next_fragment_position, |
| 723 ACMatchClassification::NONE)); | 725 ACMatchClassification::NONE)); |
| 724 } | 726 } |
| 725 } | 727 } |
| 726 } else { | 728 } else { |
| 727 // Otherwise, we're dealing with the "default search" result which has no | 729 // Otherwise, we're dealing with the "default search" result which has no |
| 728 // completion, but has the search provider name as the description. | 730 // completion, but has the search provider name as the description. |
| 729 match.contents.assign(query_string); | 731 match.contents.assign(query_string); |
| 730 match.contents_class.push_back( | 732 match.contents_class.push_back( |
| 731 ACMatchClassification(0, ACMatchClassification::NONE)); | 733 ACMatchClassification(0, ACMatchClassification::NONE)); |
| 732 match.description.assign(l10n_util::GetStringF( | 734 match.description.assign(UTF16ToWideHack(l10n_util::GetStringFUTF16( |
| 733 IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION, | 735 IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION, |
| 734 provider.AdjustedShortNameForLocaleDirection())); | 736 WideToUTF16Hack(provider.AdjustedShortNameForLocaleDirection())))); |
| 735 match.description_class.push_back( | 737 match.description_class.push_back( |
| 736 ACMatchClassification(0, ACMatchClassification::DIM)); | 738 ACMatchClassification(0, ACMatchClassification::DIM)); |
| 737 } | 739 } |
| 738 | 740 |
| 739 // When the user forced a query, we need to make sure all the fill_into_edit | 741 // When the user forced a query, we need to make sure all the fill_into_edit |
| 740 // values preserve that property. Otherwise, if the user starts editing a | 742 // values preserve that property. Otherwise, if the user starts editing a |
| 741 // suggestion, non-Search results will suddenly appear. | 743 // suggestion, non-Search results will suddenly appear. |
| 742 size_t search_start = 0; | 744 size_t search_start = 0; |
| 743 if (input_.type() == AutocompleteInput::FORCED_QUERY) { | 745 if (input_.type() == AutocompleteInput::FORCED_QUERY) { |
| 744 match.fill_into_edit.assign(L"?"); | 746 match.fill_into_edit.assign(L"?"); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 | 820 |
| 819 return match; | 821 return match; |
| 820 } | 822 } |
| 821 | 823 |
| 822 void SearchProvider::UpdateDone() { | 824 void SearchProvider::UpdateDone() { |
| 823 // We're done when there are no more suggest queries pending (this is set to 1 | 825 // We're done when there are no more suggest queries pending (this is set to 1 |
| 824 // when the timer is started) and we're not waiting on instant. | 826 // when the timer is started) and we're not waiting on instant. |
| 825 done_ = ((suggest_results_pending_ == 0) && | 827 done_ = ((suggest_results_pending_ == 0) && |
| 826 (instant_finalized_ || !InstantController::IsEnabled(profile_))); | 828 (instant_finalized_ || !InstantController::IsEnabled(profile_))); |
| 827 } | 829 } |
| OLD | NEW |