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

Side by Side Diff: chrome/browser/autocomplete/history_url_provider.cc

Issue 55603002: Move HasHTTPScheme to AutocompleteInput. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
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 "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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 const GURL& url = input.canonicalized_url(); 383 const GURL& url = input.canonicalized_url();
384 if (url.is_valid()) { 384 if (url.is_valid()) {
385 match.destination_url = url; 385 match.destination_url = url;
386 386
387 // Trim off "http://" if the user didn't type it. 387 // Trim off "http://" if the user didn't type it.
388 // NOTE: We use TrimHttpPrefix() here rather than StringForURLDisplay() to 388 // NOTE: We use TrimHttpPrefix() here rather than StringForURLDisplay() to
389 // strip the scheme as we need to know the offset so we can adjust the 389 // strip the scheme as we need to know the offset so we can adjust the
390 // |match_location| below. StringForURLDisplay() and TrimHttpPrefix() have 390 // |match_location| below. StringForURLDisplay() and TrimHttpPrefix() have
391 // slightly different behavior as well (the latter will strip even without 391 // slightly different behavior as well (the latter will strip even without
392 // two slashes after the scheme). 392 // two slashes after the scheme).
393 DCHECK(!trim_http || !HasHTTPScheme(input.text())); 393 DCHECK(!trim_http || !AutocompleteInput::HasHTTPScheme(input.text()));
394 string16 display_string(provider->StringForURLDisplay(url, false, false)); 394 string16 display_string(provider->StringForURLDisplay(url, false, false));
395 const size_t offset = trim_http ? TrimHttpPrefix(&display_string) : 0; 395 const size_t offset = trim_http ? TrimHttpPrefix(&display_string) : 0;
396 match.fill_into_edit = 396 match.fill_into_edit =
397 AutocompleteInput::FormattedStringWithEquivalentMeaning(url, 397 AutocompleteInput::FormattedStringWithEquivalentMeaning(url,
398 display_string); 398 display_string);
399 match.allowed_to_be_default_match = true; 399 match.allowed_to_be_default_match = true;
400 // NOTE: Don't set match.inline_autocompletion to something non-empty here; 400 // NOTE: Don't set match.inline_autocompletion to something non-empty here;
401 // it's surprising and annoying. 401 // it's surprising and annoying.
402 402
403 // Try to highlight "innermost" match location. If we fix up "w" into 403 // Try to highlight "innermost" match location. If we fix up "w" into
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 bool fixup_input_and_run_pass_1) { 666 bool fixup_input_and_run_pass_1) {
667 matches_.clear(); 667 matches_.clear();
668 668
669 if ((input.type() == AutocompleteInput::INVALID) || 669 if ((input.type() == AutocompleteInput::INVALID) ||
670 (input.type() == AutocompleteInput::FORCED_QUERY)) 670 (input.type() == AutocompleteInput::FORCED_QUERY))
671 return; 671 return;
672 672
673 // Create a match for exactly what the user typed. This will only be used as 673 // Create a match for exactly what the user typed. This will only be used as
674 // a fallback in case we can't get the history service or URL DB; otherwise, 674 // a fallback in case we can't get the history service or URL DB; otherwise,
675 // we'll run this again in DoAutocomplete() and use that result instead. 675 // we'll run this again in DoAutocomplete() and use that result instead.
676 const bool trim_http = !HasHTTPScheme(input.text()); 676 const bool trim_http = !AutocompleteInput::HasHTTPScheme(input.text());
677 // Don't do this for queries -- while we can sometimes mark up a match for 677 // Don't do this for queries -- while we can sometimes mark up a match for
678 // this, it's not what the user wants, and just adds noise. 678 // this, it's not what the user wants, and just adds noise.
679 if ((input.type() != AutocompleteInput::QUERY) && 679 if ((input.type() != AutocompleteInput::QUERY) &&
680 input.canonicalized_url().is_valid()) { 680 input.canonicalized_url().is_valid()) {
681 AutocompleteMatch what_you_typed(SuggestExactInput(this, input, trim_http)); 681 AutocompleteMatch what_you_typed(SuggestExactInput(this, input, trim_http));
682 what_you_typed.relevance = CalculateRelevance(WHAT_YOU_TYPED, 0); 682 what_you_typed.relevance = CalculateRelevance(WHAT_YOU_TYPED, 0);
683 matches_.push_back(what_you_typed); 683 matches_.push_back(what_you_typed);
684 } 684 }
685 685
686 // We'll need the history service to run both passes, so try to obtain it. 686 // We'll need the history service to run both passes, so try to obtain it.
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 &match.contents_class); 1087 &match.contents_class);
1088 } 1088 }
1089 match.description = info.title(); 1089 match.description = info.title();
1090 AutocompleteMatch::ClassifyMatchInString(params.input.text(), 1090 AutocompleteMatch::ClassifyMatchInString(params.input.text(),
1091 info.title(), 1091 info.title(),
1092 ACMatchClassification::NONE, 1092 ACMatchClassification::NONE,
1093 &match.description_class); 1093 &match.description_class);
1094 RecordAdditionalInfoFromUrlRow(info, &match); 1094 RecordAdditionalInfoFromUrlRow(info, &match);
1095 return match; 1095 return match;
1096 } 1096 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_provider.cc ('k') | chrome/browser/autocomplete/search_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698