OLD | NEW |
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/callback.h" | 10 #include "base/callback.h" |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 // http/https/ftp, we shouldn't send it. Sending things like file: and data: | 724 // http/https/ftp, we shouldn't send it. Sending things like file: and data: |
725 // is both a waste of time and a disclosure of potentially private, local | 725 // is both a waste of time and a disclosure of potentially private, local |
726 // data. Other "schemes" may actually be usernames, and we don't want to send | 726 // data. Other "schemes" may actually be usernames, and we don't want to send |
727 // passwords. If the scheme is OK, we still need to check other cases below. | 727 // passwords. If the scheme is OK, we still need to check other cases below. |
728 // If this is QUERY, then the presence of these schemes means the user | 728 // If this is QUERY, then the presence of these schemes means the user |
729 // explicitly typed one, and thus this is probably a URL that's being entered | 729 // explicitly typed one, and thus this is probably a URL that's being entered |
730 // and happens to currently be invalid -- in which case we again want to run | 730 // and happens to currently be invalid -- in which case we again want to run |
731 // our checks below. Other QUERY cases are less likely to be URLs and thus we | 731 // our checks below. Other QUERY cases are less likely to be URLs and thus we |
732 // assume we're OK. | 732 // assume we're OK. |
733 if (!LowerCaseEqualsASCII(input_.scheme(), chrome::kHttpScheme) && | 733 if (!LowerCaseEqualsASCII(input_.scheme(), chrome::kHttpScheme) && |
734 !LowerCaseEqualsASCII(input_.scheme(), chrome::kHttpsScheme) && | 734 !LowerCaseEqualsASCII(input_.scheme(), content::kHttpsScheme) && |
735 !LowerCaseEqualsASCII(input_.scheme(), chrome::kFtpScheme)) | 735 !LowerCaseEqualsASCII(input_.scheme(), chrome::kFtpScheme)) |
736 return (input_.type() == AutocompleteInput::QUERY); | 736 return (input_.type() == AutocompleteInput::QUERY); |
737 | 737 |
738 // Don't send URLs with usernames, queries or refs. Some of these are | 738 // Don't send URLs with usernames, queries or refs. Some of these are |
739 // private, and the Suggest server is unlikely to have any useful results | 739 // private, and the Suggest server is unlikely to have any useful results |
740 // for any of them. Also don't send URLs with ports, as we may initially | 740 // for any of them. Also don't send URLs with ports, as we may initially |
741 // think that a username + password is a host + port (and we don't want to | 741 // think that a username + password is a host + port (and we don't want to |
742 // send usernames/passwords), and even if the port really is a port, the | 742 // send usernames/passwords), and even if the port really is a port, the |
743 // server is once again unlikely to have and useful results. | 743 // server is once again unlikely to have and useful results. |
744 const url_parse::Parsed& parts = input_.parts(); | 744 const url_parse::Parsed& parts = input_.parts(); |
745 if (parts.username.is_nonempty() || parts.port.is_nonempty() || | 745 if (parts.username.is_nonempty() || parts.port.is_nonempty() || |
746 parts.query.is_nonempty() || parts.ref.is_nonempty()) | 746 parts.query.is_nonempty() || parts.ref.is_nonempty()) |
747 return false; | 747 return false; |
748 | 748 |
749 // Don't send anything for https except the hostname. Hostnames are OK | 749 // Don't send anything for https except the hostname. Hostnames are OK |
750 // because they are visible when the TCP connection is established, but the | 750 // because they are visible when the TCP connection is established, but the |
751 // specific path may reveal private information. | 751 // specific path may reveal private information. |
752 if (LowerCaseEqualsASCII(input_.scheme(), chrome::kHttpsScheme) && | 752 if (LowerCaseEqualsASCII(input_.scheme(), content::kHttpsScheme) && |
753 parts.path.is_nonempty()) | 753 parts.path.is_nonempty()) |
754 return false; | 754 return false; |
755 | 755 |
756 return true; | 756 return true; |
757 } | 757 } |
758 | 758 |
759 void SearchProvider::StopSuggest() { | 759 void SearchProvider::StopSuggest() { |
760 // Increment the appropriate field in the histogram by the number of | 760 // Increment the appropriate field in the histogram by the number of |
761 // pending requests that were invalidated. | 761 // pending requests that were invalidated. |
762 for (int i = 0; i < suggest_results_pending_; i++) | 762 for (int i = 0; i < suggest_results_pending_; i++) |
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 it->set_relevance(max_query_relevance); | 1556 it->set_relevance(max_query_relevance); |
1557 it->set_relevance_from_server(relevance_from_server); | 1557 it->set_relevance_from_server(relevance_from_server); |
1558 } | 1558 } |
1559 } | 1559 } |
1560 | 1560 |
1561 void SearchProvider::UpdateDone() { | 1561 void SearchProvider::UpdateDone() { |
1562 // We're done when the timer isn't running, there are no suggest queries | 1562 // We're done when the timer isn't running, there are no suggest queries |
1563 // pending, and we're not waiting on Instant. | 1563 // pending, and we're not waiting on Instant. |
1564 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); | 1564 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); |
1565 } | 1565 } |
OLD | NEW |