OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/app_list/search/common/webservice_search_provider.h" | 5 #include "chrome/browser/ui/app_list/search/common/webservice_search_provider.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 return false; | 64 return false; |
65 | 65 |
66 // The input can be interpreted as a URL. Check to see if it is potentially | 66 // The input can be interpreted as a URL. Check to see if it is potentially |
67 // sensitive. (Code shamelessly copied from search_provider.cc's | 67 // sensitive. (Code shamelessly copied from search_provider.cc's |
68 // IsQuerySuitableForSuggest function.) | 68 // IsQuerySuitableForSuggest function.) |
69 | 69 |
70 // First we check the scheme: if this looks like a URL with a scheme that is | 70 // First we check the scheme: if this looks like a URL with a scheme that is |
71 // file, we shouldn't send it. Sending such things is a waste of time and a | 71 // file, we shouldn't send it. Sending such things is a waste of time and a |
72 // disclosure of potentially private, local data. If the scheme is OK, we | 72 // disclosure of potentially private, local data. If the scheme is OK, we |
73 // still need to check other cases below. | 73 // still need to check other cases below. |
74 if (LowerCaseEqualsASCII(query_as_url.scheme(), url::kFileScheme)) | 74 if (base::LowerCaseEqualsASCII(query_as_url.scheme(), url::kFileScheme)) |
75 return true; | 75 return true; |
76 | 76 |
77 // Don't send URLs with usernames, queries or refs. Some of these are | 77 // Don't send URLs with usernames, queries or refs. Some of these are |
78 // private, and the Suggest server is unlikely to have any useful results | 78 // private, and the Suggest server is unlikely to have any useful results |
79 // for any of them. Also don't send URLs with ports, as we may initially | 79 // for any of them. Also don't send URLs with ports, as we may initially |
80 // think that a username + password is a host + port (and we don't want to | 80 // think that a username + password is a host + port (and we don't want to |
81 // send usernames/passwords), and even if the port really is a port, the | 81 // send usernames/passwords), and even if the port really is a port, the |
82 // server is once again unlikely to have and useful results. | 82 // server is once again unlikely to have and useful results. |
83 if (!query_as_url.username().empty() || | 83 if (!query_as_url.username().empty() || |
84 !query_as_url.port().empty() || | 84 !query_as_url.port().empty() || |
85 !query_as_url.query().empty() || | 85 !query_as_url.query().empty() || |
86 !query_as_url.ref().empty()) { | 86 !query_as_url.ref().empty()) { |
87 return true; | 87 return true; |
88 } | 88 } |
89 | 89 |
90 // Don't send anything for https except the hostname. Hostnames are OK | 90 // Don't send anything for https except the hostname. Hostnames are OK |
91 // because they are visible when the TCP connection is established, but the | 91 // because they are visible when the TCP connection is established, but the |
92 // specific path may reveal private information. | 92 // specific path may reveal private information. |
93 if (LowerCaseEqualsASCII(query_as_url.scheme(), url::kHttpsScheme) && | 93 if (base::LowerCaseEqualsASCII(query_as_url.scheme(), url::kHttpsScheme) && |
94 !query_as_url.path().empty() && query_as_url.path() != "/") { | 94 !query_as_url.path().empty() && query_as_url.path() != "/") { |
95 return true; | 95 return true; |
96 } | 96 } |
97 | 97 |
98 return false; | 98 return false; |
99 } | 99 } |
100 | 100 |
101 } // namespace app_list | 101 } // namespace app_list |
OLD | NEW |