| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/autocomplete.h" | 5 #include "chrome/browser/autocomplete/autocomplete.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/i18n/number_formatting.h" |
| 11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 12 #include "chrome/browser/autocomplete/history_url_provider.h" | 13 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 13 #include "chrome/browser/autocomplete/history_contents_provider.h" | 14 #include "chrome/browser/autocomplete/history_contents_provider.h" |
| 14 #include "chrome/browser/autocomplete/keyword_provider.h" | 15 #include "chrome/browser/autocomplete/keyword_provider.h" |
| 15 #include "chrome/browser/autocomplete/search_provider.h" | 16 #include "chrome/browser/autocomplete/search_provider.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_model.h" | 17 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 17 #include "chrome/browser/dom_ui/history_ui.h" | 18 #include "chrome/browser/dom_ui/history_ui.h" |
| 18 #include "chrome/browser/external_protocol_handler.h" | 19 #include "chrome/browser/external_protocol_handler.h" |
| 19 #include "chrome/browser/net/url_fixer_upper.h" | 20 #include "chrome/browser/net/url_fixer_upper.h" |
| 20 #include "chrome/browser/profile.h" | 21 #include "chrome/browser/profile.h" |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 size_t keyword_offset = std::wstring::npos; // Offset into match.contents. | 873 size_t keyword_offset = std::wstring::npos; // Offset into match.contents. |
| 873 if (history_contents_provider_->db_match_count() == | 874 if (history_contents_provider_->db_match_count() == |
| 874 history_contents_provider_->kMaxMatchCount) { | 875 history_contents_provider_->kMaxMatchCount) { |
| 875 // History contents searcher has maxed out. | 876 // History contents searcher has maxed out. |
| 876 match.contents = l10n_util::GetStringF(IDS_OMNIBOX_RECENT_HISTORY_MANY, | 877 match.contents = l10n_util::GetStringF(IDS_OMNIBOX_RECENT_HISTORY_MANY, |
| 877 input_.text(), | 878 input_.text(), |
| 878 &keyword_offset); | 879 &keyword_offset); |
| 879 } else { | 880 } else { |
| 880 // We can report exact matches when there aren't too many. | 881 // We can report exact matches when there aren't too many. |
| 881 std::vector<size_t> content_param_offsets; | 882 std::vector<size_t> content_param_offsets; |
| 882 match.contents = | 883 match.contents = l10n_util::GetStringF( |
| 883 l10n_util::GetStringF(IDS_OMNIBOX_RECENT_HISTORY, | 884 IDS_OMNIBOX_RECENT_HISTORY, |
| 884 FormatNumber(history_contents_provider_-> | 885 UTF16ToWide(base::FormatNumber(history_contents_provider_-> |
| 885 db_match_count()), | 886 db_match_count())), |
| 886 input_.text(), | 887 input_.text(), |
| 887 &content_param_offsets); | 888 &content_param_offsets); |
| 888 | 889 |
| 889 // content_param_offsets is ordered based on supplied params, we expect | 890 // content_param_offsets is ordered based on supplied params, we expect |
| 890 // that the second one contains the query (first is the number). | 891 // that the second one contains the query (first is the number). |
| 891 if (content_param_offsets.size() == 2) { | 892 if (content_param_offsets.size() == 2) { |
| 892 keyword_offset = content_param_offsets[1]; | 893 keyword_offset = content_param_offsets[1]; |
| 893 } else { | 894 } else { |
| 894 // See comments on an identical NOTREACHED() in search_provider.cc. | 895 // See comments on an identical NOTREACHED() in search_provider.cc. |
| 895 NOTREACHED(); | 896 NOTREACHED(); |
| 896 } | 897 } |
| 897 } | 898 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 918 void AutocompleteController::CheckIfDone() { | 919 void AutocompleteController::CheckIfDone() { |
| 919 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end(); | 920 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end(); |
| 920 ++i) { | 921 ++i) { |
| 921 if (!(*i)->done()) { | 922 if (!(*i)->done()) { |
| 922 done_ = false; | 923 done_ = false; |
| 923 return; | 924 return; |
| 924 } | 925 } |
| 925 } | 926 } |
| 926 done_ = true; | 927 done_ = true; |
| 927 } | 928 } |
| OLD | NEW |