| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/history_url_provider.h" | 5 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/gfx/text_elider.h" | |
| 10 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 11 #include "base/histogram.h" | 10 #include "base/histogram.h" |
| 12 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 13 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 14 #include "chrome/browser/history/history.h" | 13 #include "chrome/browser/history/history.h" |
| 15 #include "chrome/browser/history/history_backend.h" | 14 #include "chrome/browser/history/history_backend.h" |
| 16 #include "chrome/browser/history/history_database.h" | 15 #include "chrome/browser/history/history_database.h" |
| 17 #include "chrome/browser/net/url_fixer_upper.h" | 16 #include "chrome/browser/net/url_fixer_upper.h" |
| 18 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profile.h" |
| 19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 HistoryURLProviderParams* params, | 824 HistoryURLProviderParams* params, |
| 826 const HistoryMatch& history_match, | 825 const HistoryMatch& history_match, |
| 827 MatchType match_type, | 826 MatchType match_type, |
| 828 size_t match_number) { | 827 size_t match_number) { |
| 829 const history::URLRow& info = history_match.url_info; | 828 const history::URLRow& info = history_match.url_info; |
| 830 AutocompleteMatch match(this, | 829 AutocompleteMatch match(this, |
| 831 CalculateRelevance(params->input.type(), match_type, match_number), | 830 CalculateRelevance(params->input.type(), match_type, match_number), |
| 832 !!info.visit_count(), AutocompleteMatch::HISTORY_URL); | 831 !!info.visit_count(), AutocompleteMatch::HISTORY_URL); |
| 833 match.destination_url = info.url(); | 832 match.destination_url = info.url(); |
| 834 DCHECK(match.destination_url.is_valid()); | 833 DCHECK(match.destination_url.is_valid()); |
| 835 match.fill_into_edit = gfx::GetCleanStringFromUrl(info.url(), | 834 match.fill_into_edit = net::FormatUrl(info.url(), |
| 836 match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages, | 835 match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages); |
| 837 NULL, NULL); | |
| 838 if (!params->input.prevent_inline_autocomplete()) { | 836 if (!params->input.prevent_inline_autocomplete()) { |
| 839 match.inline_autocomplete_offset = | 837 match.inline_autocomplete_offset = |
| 840 history_match.input_location + params->input.text().length(); | 838 history_match.input_location + params->input.text().length(); |
| 841 } | 839 } |
| 842 size_t offset = 0; | 840 size_t offset = 0; |
| 843 if (params->trim_http && !history_match.match_in_scheme) { | 841 if (params->trim_http && !history_match.match_in_scheme) { |
| 844 offset = TrimHttpPrefix(&match.fill_into_edit); | 842 offset = TrimHttpPrefix(&match.fill_into_edit); |
| 845 if (match.inline_autocomplete_offset != std::wstring::npos) { | 843 if (match.inline_autocomplete_offset != std::wstring::npos) { |
| 846 DCHECK(match.inline_autocomplete_offset >= offset); | 844 DCHECK(match.inline_autocomplete_offset >= offset); |
| 847 match.inline_autocomplete_offset -= offset; | 845 match.inline_autocomplete_offset -= offset; |
| 848 } | 846 } |
| 849 } | 847 } |
| 850 DCHECK((match.inline_autocomplete_offset == std::wstring::npos) || | 848 DCHECK((match.inline_autocomplete_offset == std::wstring::npos) || |
| 851 (match.inline_autocomplete_offset <= match.fill_into_edit.length())); | 849 (match.inline_autocomplete_offset <= match.fill_into_edit.length())); |
| 852 | 850 |
| 853 match.contents = match.fill_into_edit; | 851 match.contents = match.fill_into_edit; |
| 854 AutocompleteMatch::ClassifyLocationInString( | 852 AutocompleteMatch::ClassifyLocationInString( |
| 855 history_match.input_location - offset, params->input.text().length(), | 853 history_match.input_location - offset, params->input.text().length(), |
| 856 match.contents.length(), ACMatchClassification::URL, | 854 match.contents.length(), ACMatchClassification::URL, |
| 857 &match.contents_class); | 855 &match.contents_class); |
| 858 match.description = info.title(); | 856 match.description = info.title(); |
| 859 AutocompleteMatch::ClassifyMatchInString(params->input.text(), info.title(), | 857 AutocompleteMatch::ClassifyMatchInString(params->input.text(), info.title(), |
| 860 ACMatchClassification::NONE, | 858 ACMatchClassification::NONE, |
| 861 &match.description_class); | 859 &match.description_class); |
| 862 | 860 |
| 863 return match; | 861 return match; |
| 864 } | 862 } |
| OLD | NEW |