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/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 "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 size_t inline_autocomplete_offset = | 903 size_t inline_autocomplete_offset = |
904 history_match.input_location + params->input.text().length(); | 904 history_match.input_location + params->input.text().length(); |
905 std::string languages = (match_type == WHAT_YOU_TYPED) ? | 905 std::string languages = (match_type == WHAT_YOU_TYPED) ? |
906 std::string() : params->languages; | 906 std::string() : params->languages; |
907 const net::FormatUrlTypes format_types = net::kFormatUrlOmitAll & | 907 const net::FormatUrlTypes format_types = net::kFormatUrlOmitAll & |
908 ~((params->trim_http && !history_match.match_in_scheme) ? | 908 ~((params->trim_http && !history_match.match_in_scheme) ? |
909 0 : net::kFormatUrlOmitHTTP); | 909 0 : net::kFormatUrlOmitHTTP); |
910 match.fill_into_edit = | 910 match.fill_into_edit = |
911 AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(), | 911 AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(), |
912 net::FormatUrl(info.url(), languages, format_types, | 912 net::FormatUrl(info.url(), languages, format_types, |
913 UnescapeRule::SPACES, NULL, NULL, | 913 net::UnescapeRule::SPACES, NULL, NULL, |
914 &inline_autocomplete_offset)); | 914 &inline_autocomplete_offset)); |
915 if (!params->prevent_inline_autocomplete) | 915 if (!params->prevent_inline_autocomplete) |
916 match.inline_autocomplete_offset = inline_autocomplete_offset; | 916 match.inline_autocomplete_offset = inline_autocomplete_offset; |
917 DCHECK((match.inline_autocomplete_offset == string16::npos) || | 917 DCHECK((match.inline_autocomplete_offset == string16::npos) || |
918 (match.inline_autocomplete_offset <= match.fill_into_edit.length())); | 918 (match.inline_autocomplete_offset <= match.fill_into_edit.length())); |
919 | 919 |
920 size_t match_start = history_match.input_location; | 920 size_t match_start = history_match.input_location; |
921 match.contents = net::FormatUrl(info.url(), languages, | 921 match.contents = net::FormatUrl(info.url(), languages, |
922 format_types, UnescapeRule::SPACES, NULL, NULL, &match_start); | 922 format_types, net::UnescapeRule::SPACES, NULL, NULL, &match_start); |
923 if ((match_start != string16::npos) && | 923 if ((match_start != string16::npos) && |
924 (inline_autocomplete_offset != string16::npos) && | 924 (inline_autocomplete_offset != string16::npos) && |
925 (inline_autocomplete_offset != match_start)) { | 925 (inline_autocomplete_offset != match_start)) { |
926 DCHECK(inline_autocomplete_offset > match_start); | 926 DCHECK(inline_autocomplete_offset > match_start); |
927 AutocompleteMatch::ClassifyLocationInString(match_start, | 927 AutocompleteMatch::ClassifyLocationInString(match_start, |
928 inline_autocomplete_offset - match_start, match.contents.length(), | 928 inline_autocomplete_offset - match_start, match.contents.length(), |
929 ACMatchClassification::URL, &match.contents_class); | 929 ACMatchClassification::URL, &match.contents_class); |
930 } else { | 930 } else { |
931 AutocompleteMatch::ClassifyLocationInString(string16::npos, 0, | 931 AutocompleteMatch::ClassifyLocationInString(string16::npos, 0, |
932 match.contents.length(), ACMatchClassification::URL, | 932 match.contents.length(), ACMatchClassification::URL, |
933 &match.contents_class); | 933 &match.contents_class); |
934 } | 934 } |
935 match.description = info.title(); | 935 match.description = info.title(); |
936 AutocompleteMatch::ClassifyMatchInString(params->input.text(), | 936 AutocompleteMatch::ClassifyMatchInString(params->input.text(), |
937 info.title(), | 937 info.title(), |
938 ACMatchClassification::NONE, | 938 ACMatchClassification::NONE, |
939 &match.description_class); | 939 &match.description_class); |
940 | 940 |
941 return match; | 941 return match; |
942 } | 942 } |
OLD | NEW |