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

Side by Side Diff: trunk/src/chrome/browser/autocomplete/search_provider.cc

Issue 474483002: Revert 289312 "Move StringToUpperASCII and LowerCaseEqualsASCII ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 // Next we check the scheme. If this is UNKNOWN/URL with a scheme that isn't 581 // Next we check the scheme. If this is UNKNOWN/URL with a scheme that isn't
582 // http/https/ftp, we shouldn't send it. Sending things like file: and data: 582 // http/https/ftp, we shouldn't send it. Sending things like file: and data:
583 // is both a waste of time and a disclosure of potentially private, local 583 // is both a waste of time and a disclosure of potentially private, local
584 // data. Other "schemes" may actually be usernames, and we don't want to send 584 // data. Other "schemes" may actually be usernames, and we don't want to send
585 // passwords. If the scheme is OK, we still need to check other cases below. 585 // passwords. If the scheme is OK, we still need to check other cases below.
586 // If this is QUERY, then the presence of these schemes means the user 586 // If this is QUERY, then the presence of these schemes means the user
587 // explicitly typed one, and thus this is probably a URL that's being entered 587 // explicitly typed one, and thus this is probably a URL that's being entered
588 // and happens to currently be invalid -- in which case we again want to run 588 // and happens to currently be invalid -- in which case we again want to run
589 // our checks below. Other QUERY cases are less likely to be URLs and thus we 589 // our checks below. Other QUERY cases are less likely to be URLs and thus we
590 // assume we're OK. 590 // assume we're OK.
591 if (!base::LowerCaseEqualsASCII(input_.scheme(), url::kHttpScheme) && 591 if (!LowerCaseEqualsASCII(input_.scheme(), url::kHttpScheme) &&
592 !base::LowerCaseEqualsASCII(input_.scheme(), url::kHttpsScheme) && 592 !LowerCaseEqualsASCII(input_.scheme(), url::kHttpsScheme) &&
593 !base::LowerCaseEqualsASCII(input_.scheme(), url::kFtpScheme)) 593 !LowerCaseEqualsASCII(input_.scheme(), url::kFtpScheme))
594 return (input_.type() == metrics::OmniboxInputType::QUERY); 594 return (input_.type() == metrics::OmniboxInputType::QUERY);
595 595
596 // Don't send URLs with usernames, queries or refs. Some of these are 596 // Don't send URLs with usernames, queries or refs. Some of these are
597 // private, and the Suggest server is unlikely to have any useful results 597 // private, and the Suggest server is unlikely to have any useful results
598 // for any of them. Also don't send URLs with ports, as we may initially 598 // for any of them. Also don't send URLs with ports, as we may initially
599 // think that a username + password is a host + port (and we don't want to 599 // think that a username + password is a host + port (and we don't want to
600 // send usernames/passwords), and even if the port really is a port, the 600 // send usernames/passwords), and even if the port really is a port, the
601 // server is once again unlikely to have and useful results. 601 // server is once again unlikely to have and useful results.
602 // Note that we only block based on refs if the input is URL-typed, as search 602 // Note that we only block based on refs if the input is URL-typed, as search
603 // queries can legitimately have #s in them which the URL parser 603 // queries can legitimately have #s in them which the URL parser
604 // overaggressively categorizes as a url with a ref. 604 // overaggressively categorizes as a url with a ref.
605 const url::Parsed& parts = input_.parts(); 605 const url::Parsed& parts = input_.parts();
606 if (parts.username.is_nonempty() || parts.port.is_nonempty() || 606 if (parts.username.is_nonempty() || parts.port.is_nonempty() ||
607 parts.query.is_nonempty() || 607 parts.query.is_nonempty() ||
608 (parts.ref.is_nonempty() && 608 (parts.ref.is_nonempty() &&
609 (input_.type() == metrics::OmniboxInputType::URL))) 609 (input_.type() == metrics::OmniboxInputType::URL)))
610 return false; 610 return false;
611 611
612 // Don't send anything for https except the hostname. Hostnames are OK 612 // Don't send anything for https except the hostname. Hostnames are OK
613 // because they are visible when the TCP connection is established, but the 613 // because they are visible when the TCP connection is established, but the
614 // specific path may reveal private information. 614 // specific path may reveal private information.
615 if (base::LowerCaseEqualsASCII(input_.scheme(), url::kHttpsScheme) && 615 if (LowerCaseEqualsASCII(input_.scheme(), url::kHttpsScheme) &&
616 parts.path.is_nonempty()) 616 parts.path.is_nonempty())
617 return false; 617 return false;
618 618
619 return true; 619 return true;
620 } 620 }
621 621
622 void SearchProvider::RemoveAllStaleResults() { 622 void SearchProvider::RemoveAllStaleResults() {
623 if (keyword_input_.text().empty()) { 623 if (keyword_input_.text().empty()) {
624 // User is either in keyword mode with a blank input or out of 624 // User is either in keyword mode with a blank input or out of
625 // keyword mode entirely. 625 // keyword mode entirely.
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 last_answer_seen_.query_type = match->answer_type; 1262 last_answer_seen_.query_type = match->answer_type;
1263 } 1263 }
1264 1264
1265 void SearchProvider::DoAnswersQuery(const AutocompleteInput& input) { 1265 void SearchProvider::DoAnswersQuery(const AutocompleteInput& input) {
1266 // If the query text starts with trimmed input, this is valid prefetch data. 1266 // If the query text starts with trimmed input, this is valid prefetch data.
1267 prefetch_data_ = StartsWith(last_answer_seen_.full_query_text, 1267 prefetch_data_ = StartsWith(last_answer_seen_.full_query_text,
1268 base::CollapseWhitespace(input.text(), false), 1268 base::CollapseWhitespace(input.text(), false),
1269 false) ? 1269 false) ?
1270 last_answer_seen_ : AnswersQueryData(); 1270 last_answer_seen_ : AnswersQueryData();
1271 } 1271 }
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/autocomplete/history_url_provider.cc ('k') | trunk/src/chrome/browser/browser_about_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698