OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 359 |
360 // If the input type might be a URL, we take extra care so that private data | 360 // If the input type might be a URL, we take extra care so that private data |
361 // isn't sent to the server. | 361 // isn't sent to the server. |
362 | 362 |
363 // FORCED_QUERY means the user is explicitly asking us to search for this, so | 363 // FORCED_QUERY means the user is explicitly asking us to search for this, so |
364 // we assume it isn't a URL and/or there isn't private data. | 364 // we assume it isn't a URL and/or there isn't private data. |
365 if (input_.type() == AutocompleteInput::FORCED_QUERY) | 365 if (input_.type() == AutocompleteInput::FORCED_QUERY) |
366 return true; | 366 return true; |
367 | 367 |
368 // Next we check the scheme. If this is UNKNOWN/REQUESTED_URL/URL with a | 368 // Next we check the scheme. If this is UNKNOWN/REQUESTED_URL/URL with a |
369 // scheme that isn't http/https/ftp, we shouldn't send it. Sending things | 369 // scheme that isn't http/https/httpsv/ftp, we shouldn't send it. Sending |
370 // like file: and data: is both a waste of time and a disclosure of | 370 // things like file: and data: is both a waste of time and a disclosure of |
371 // potentially private, local data. Other "schemes" may actually be | 371 // potentially private, local data. Other "schemes" may actually be |
372 // usernames, and we don't want to send passwords. If the scheme is OK, we | 372 // usernames, and we don't want to send passwords. If the scheme is OK, we |
373 // still need to check other cases below. If this is QUERY, then the presence | 373 // still need to check other cases below. If this is QUERY, then the |
374 // of these schemes means the user explicitly typed one, and thus this is | 374 // presence of these schemes means the user explicitly typed one, and thus |
375 // probably a URL that's being entered and happens to currently be invalid -- | 375 // this is probably a URL that's being entered and happens to currently be |
376 // in which case we again want to run our checks below. Other QUERY cases are | 376 // invalid -- in which case we again want to run our checks below. Other |
377 // less likely to be URLs and thus we assume we're OK. | 377 // QUERY cases are less likely to be URLs and thus we assume we're OK. |
378 if (!LowerCaseEqualsASCII(input_.scheme(), chrome::kHttpScheme) && | 378 if (!LowerCaseEqualsASCII(input_.scheme(), chrome::kHttpScheme) && |
379 !LowerCaseEqualsASCII(input_.scheme(), chrome::kHttpsScheme) && | 379 !LowerCaseEqualsASCII(input_.scheme(), chrome::kHttpsScheme) && |
| 380 !LowerCaseEqualsASCII(input_.scheme(), chrome::kHttpsvScheme) && |
380 !LowerCaseEqualsASCII(input_.scheme(), chrome::kFtpScheme)) | 381 !LowerCaseEqualsASCII(input_.scheme(), chrome::kFtpScheme)) |
381 return (input_.type() == AutocompleteInput::QUERY); | 382 return (input_.type() == AutocompleteInput::QUERY); |
382 | 383 |
383 // Don't send URLs with usernames, queries or refs. Some of these are | 384 // Don't send URLs with usernames, queries or refs. Some of these are |
384 // private, and the Suggest server is unlikely to have any useful results | 385 // private, and the Suggest server is unlikely to have any useful results |
385 // for any of them. Also don't send URLs with ports, as we may initially | 386 // for any of them. Also don't send URLs with ports, as we may initially |
386 // think that a username + password is a host + port (and we don't want to | 387 // think that a username + password is a host + port (and we don't want to |
387 // send usernames/passwords), and even if the port really is a port, the | 388 // send usernames/passwords), and even if the port really is a port, the |
388 // server is once again unlikely to have and useful results. | 389 // server is once again unlikely to have and useful results. |
389 const url_parse::Parsed& parts = input_.parts(); | 390 const url_parse::Parsed& parts = input_.parts(); |
390 if (parts.username.is_nonempty() || parts.port.is_nonempty() || | 391 if (parts.username.is_nonempty() || parts.port.is_nonempty() || |
391 parts.query.is_nonempty() || parts.ref.is_nonempty()) | 392 parts.query.is_nonempty() || parts.ref.is_nonempty()) |
392 return false; | 393 return false; |
393 | 394 |
394 // Don't send anything for https except the hostname. Hostnames are OK | 395 // Don't send anything for https(v) except the hostname. Hostnames are OK |
395 // because they are visible when the TCP connection is established, but the | 396 // because they are visible when the TCP connection is established, but the |
396 // specific path may reveal private information. | 397 // specific path may reveal private information. |
397 if (LowerCaseEqualsASCII(input_.scheme(), chrome::kHttpsScheme) && | 398 if ((LowerCaseEqualsASCII(input_.scheme(), chrome::kHttpsScheme) || |
| 399 LowerCaseEqualsASCII(input_.scheme(), chrome::kHttpsvScheme)) && |
398 parts.path.is_nonempty()) | 400 parts.path.is_nonempty()) |
399 return false; | 401 return false; |
400 | 402 |
401 return true; | 403 return true; |
402 } | 404 } |
403 | 405 |
404 void SearchProvider::StopSuggest() { | 406 void SearchProvider::StopSuggest() { |
405 suggest_results_pending_ = 0; | 407 suggest_results_pending_ = 0; |
406 timer_.Stop(); | 408 timer_.Stop(); |
407 // Stop any in-progress URL fetches. | 409 // Stop any in-progress URL fetches. |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 match.description_class.push_back( | 882 match.description_class.push_back( |
881 ACMatchClassification(0, ACMatchClassification::DIM)); | 883 ACMatchClassification(0, ACMatchClassification::DIM)); |
882 // Only the first search match gets a description. | 884 // Only the first search match gets a description. |
883 return; | 885 return; |
884 | 886 |
885 default: | 887 default: |
886 break; | 888 break; |
887 } | 889 } |
888 } | 890 } |
889 } | 891 } |
OLD | NEW |