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