Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1263)

Side by Side Diff: components/omnibox/browser/history_url_provider.cc

Issue 2940973002: Omnibox UI Experiments: Implement scheme-trimming for suggested URLs. (Closed)
Patch Set: fix Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/omnibox/browser/history_url_provider.h" 5 #include "components/omnibox/browser/history_url_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 564
565 AutocompleteMatch match(this, 0, false, 565 AutocompleteMatch match(this, 0, false,
566 AutocompleteMatchType::URL_WHAT_YOU_TYPED); 566 AutocompleteMatchType::URL_WHAT_YOU_TYPED);
567 567
568 if (destination_url.is_valid()) { 568 if (destination_url.is_valid()) {
569 match.destination_url = destination_url; 569 match.destination_url = destination_url;
570 570
571 // Trim off "http://" if the user didn't type it. 571 // Trim off "http://" if the user didn't type it.
572 DCHECK(!trim_http || 572 DCHECK(!trim_http ||
573 !AutocompleteInput::HasHTTPScheme(input.text())); 573 !AutocompleteInput::HasHTTPScheme(input.text()));
574 base::string16 display_string(url_formatter::FormatUrl( 574 base::string16 display_string(
575 destination_url, 575 AutocompleteMatch::FormatUrlForSuggestionDisplay(
576 url_formatter::kFormatUrlOmitAll & ~url_formatter::kFormatUrlOmitHTTP, 576 destination_url, false /* trim_scheme */, nullptr));
577 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr));
578 const size_t offset = trim_http ? TrimHttpPrefix(&display_string) : 0; 577 const size_t offset = trim_http ? TrimHttpPrefix(&display_string) : 0;
579 match.fill_into_edit = 578 match.fill_into_edit =
580 AutocompleteInput::FormattedStringWithEquivalentMeaning( 579 AutocompleteInput::FormattedStringWithEquivalentMeaning(
581 destination_url, display_string, client()->GetSchemeClassifier()); 580 destination_url, display_string, client()->GetSchemeClassifier());
582 // The what-you-typed match is generally only allowed to be default for 581 // The what-you-typed match is generally only allowed to be default for
583 // URL inputs or when there is no default search provider. (It's also 582 // URL inputs or when there is no default search provider. (It's also
584 // allowed to be default for UNKNOWN inputs where the destination is a known 583 // allowed to be default for UNKNOWN inputs where the destination is a known
585 // intranet site. In this case, |allowed_to_be_default_match| is revised in 584 // intranet site. In this case, |allowed_to_be_default_match| is revised in
586 // FixupExactSuggestion().) 585 // FixupExactSuggestion().)
587 const bool has_default_search_provider = 586 const bool has_default_search_provider =
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 match.inline_autocompletion = 1166 match.inline_autocompletion =
1168 match.fill_into_edit.substr(inline_autocomplete_offset); 1167 match.fill_into_edit.substr(inline_autocomplete_offset);
1169 } 1168 }
1170 // The latter part of the test effectively asks "is the inline completion 1169 // The latter part of the test effectively asks "is the inline completion
1171 // empty?" (i.e., is this match effectively the what-you-typed match?). 1170 // empty?" (i.e., is this match effectively the what-you-typed match?).
1172 match.allowed_to_be_default_match = autocomplete_offset_valid && 1171 match.allowed_to_be_default_match = autocomplete_offset_valid &&
1173 (!params.prevent_inline_autocomplete || 1172 (!params.prevent_inline_autocomplete ||
1174 (inline_autocomplete_offset >= match.fill_into_edit.length())); 1173 (inline_autocomplete_offset >= match.fill_into_edit.length()));
1175 1174
1176 size_t match_start = history_match.input_location; 1175 size_t match_start = history_match.input_location;
1177 match.contents = url_formatter::FormatUrl(info.url(), format_types, 1176 match.contents = AutocompleteMatch::FormatUrlForSuggestionDisplay(
1178 net::UnescapeRule::SPACES, nullptr, 1177 info.url(), params.trim_http && !history_match.match_in_scheme,
1179 nullptr, &match_start); 1178 &match_start);
1180 if ((match_start != base::string16::npos) && autocomplete_offset_valid && 1179 if ((match_start != base::string16::npos) && autocomplete_offset_valid &&
1181 (inline_autocomplete_offset != match_start)) { 1180 (inline_autocomplete_offset != match_start)) {
1182 DCHECK(inline_autocomplete_offset > match_start); 1181 DCHECK(inline_autocomplete_offset > match_start);
1183 AutocompleteMatch::ClassifyLocationInString(match_start, 1182 AutocompleteMatch::ClassifyLocationInString(match_start,
1184 inline_autocomplete_offset - match_start, match.contents.length(), 1183 inline_autocomplete_offset - match_start, match.contents.length(),
1185 ACMatchClassification::URL, &match.contents_class); 1184 ACMatchClassification::URL, &match.contents_class);
1186 } else { 1185 } else {
1187 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, 1186 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0,
1188 match.contents.length(), ACMatchClassification::URL, 1187 match.contents.length(), ACMatchClassification::URL,
1189 &match.contents_class); 1188 &match.contents_class);
1190 } 1189 }
1191 match.description = info.title(); 1190 match.description = info.title();
1192 match.description_class = 1191 match.description_class =
1193 ClassifyDescription(params.input.text(), match.description); 1192 ClassifyDescription(params.input.text(), match.description);
1194 RecordAdditionalInfoFromUrlRow(info, &match); 1193 RecordAdditionalInfoFromUrlRow(info, &match);
1195 return match; 1194 return match;
1196 } 1195 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/history_quick_provider.cc ('k') | components/omnibox/browser/titled_url_match_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698