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

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

Issue 254763005: Move some content url constants to /url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initial patches. Created 6 years, 8 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
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/callback.h" 10 #include "base/callback.h"
(...skipping 23 matching lines...) Expand all
34 #include "chrome/browser/search_engines/template_url_service.h" 34 #include "chrome/browser/search_engines/template_url_service.h"
35 #include "chrome/browser/search_engines/template_url_service_factory.h" 35 #include "chrome/browser/search_engines/template_url_service_factory.h"
36 #include "chrome/browser/ui/search/instant_controller.h" 36 #include "chrome/browser/ui/search/instant_controller.h"
37 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
38 #include "chrome/common/url_constants.h" 38 #include "chrome/common/url_constants.h"
39 #include "content/public/browser/user_metrics.h" 39 #include "content/public/browser/user_metrics.h"
40 #include "grit/generated_resources.h" 40 #include "grit/generated_resources.h"
41 #include "net/base/escape.h" 41 #include "net/base/escape.h"
42 #include "net/base/load_flags.h" 42 #include "net/base/load_flags.h"
43 #include "net/base/net_util.h" 43 #include "net/base/net_util.h"
44 #include "net/base/url_constants.h"
44 #include "net/http/http_request_headers.h" 45 #include "net/http/http_request_headers.h"
45 #include "net/url_request/url_fetcher.h" 46 #include "net/url_request/url_fetcher.h"
46 #include "net/url_request/url_request_status.h" 47 #include "net/url_request/url_request_status.h"
47 #include "ui/base/l10n/l10n_util.h" 48 #include "ui/base/l10n/l10n_util.h"
48 #include "url/url_util.h" 49 #include "url/url_util.h"
49 50
50 51
51 // Helpers -------------------------------------------------------------------- 52 // Helpers --------------------------------------------------------------------
52 53
53 namespace { 54 namespace {
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 // Next we check the scheme. If this is UNKNOWN/URL with a scheme that isn't 553 // Next we check the scheme. If this is UNKNOWN/URL with a scheme that isn't
553 // http/https/ftp, we shouldn't send it. Sending things like file: and data: 554 // http/https/ftp, we shouldn't send it. Sending things like file: and data:
554 // is both a waste of time and a disclosure of potentially private, local 555 // is both a waste of time and a disclosure of potentially private, local
555 // data. Other "schemes" may actually be usernames, and we don't want to send 556 // data. Other "schemes" may actually be usernames, and we don't want to send
556 // passwords. If the scheme is OK, we still need to check other cases below. 557 // passwords. If the scheme is OK, we still need to check other cases below.
557 // If this is QUERY, then the presence of these schemes means the user 558 // If this is QUERY, then the presence of these schemes means the user
558 // explicitly typed one, and thus this is probably a URL that's being entered 559 // explicitly typed one, and thus this is probably a URL that's being entered
559 // and happens to currently be invalid -- in which case we again want to run 560 // and happens to currently be invalid -- in which case we again want to run
560 // our checks below. Other QUERY cases are less likely to be URLs and thus we 561 // our checks below. Other QUERY cases are less likely to be URLs and thus we
561 // assume we're OK. 562 // assume we're OK.
562 if (!LowerCaseEqualsASCII(input_.scheme(), content::kHttpScheme) && 563 if (!LowerCaseEqualsASCII(input_.scheme(), net::kHttpScheme) &&
563 !LowerCaseEqualsASCII(input_.scheme(), content::kHttpsScheme) && 564 !LowerCaseEqualsASCII(input_.scheme(), net::kHttpsScheme) &&
564 !LowerCaseEqualsASCII(input_.scheme(), content::kFtpScheme)) 565 !LowerCaseEqualsASCII(input_.scheme(), content::kFtpScheme))
565 return (input_.type() == AutocompleteInput::QUERY); 566 return (input_.type() == AutocompleteInput::QUERY);
566 567
567 // Don't send URLs with usernames, queries or refs. Some of these are 568 // Don't send URLs with usernames, queries or refs. Some of these are
568 // private, and the Suggest server is unlikely to have any useful results 569 // private, and the Suggest server is unlikely to have any useful results
569 // for any of them. Also don't send URLs with ports, as we may initially 570 // for any of them. Also don't send URLs with ports, as we may initially
570 // think that a username + password is a host + port (and we don't want to 571 // think that a username + password is a host + port (and we don't want to
571 // send usernames/passwords), and even if the port really is a port, the 572 // send usernames/passwords), and even if the port really is a port, the
572 // server is once again unlikely to have and useful results. 573 // server is once again unlikely to have and useful results.
573 // Note that we only block based on refs if the input is URL-typed, as search 574 // Note that we only block based on refs if the input is URL-typed, as search
574 // queries can legitimately have #s in them which the URL parser 575 // queries can legitimately have #s in them which the URL parser
575 // overaggressively categorizes as a url with a ref. 576 // overaggressively categorizes as a url with a ref.
576 const url_parse::Parsed& parts = input_.parts(); 577 const url_parse::Parsed& parts = input_.parts();
577 if (parts.username.is_nonempty() || parts.port.is_nonempty() || 578 if (parts.username.is_nonempty() || parts.port.is_nonempty() ||
578 parts.query.is_nonempty() || 579 parts.query.is_nonempty() ||
579 (parts.ref.is_nonempty() && (input_.type() == AutocompleteInput::URL))) 580 (parts.ref.is_nonempty() && (input_.type() == AutocompleteInput::URL)))
580 return false; 581 return false;
581 582
582 // Don't send anything for https except the hostname. Hostnames are OK 583 // Don't send anything for https except the hostname. Hostnames are OK
583 // because they are visible when the TCP connection is established, but the 584 // because they are visible when the TCP connection is established, but the
584 // specific path may reveal private information. 585 // specific path may reveal private information.
585 if (LowerCaseEqualsASCII(input_.scheme(), content::kHttpsScheme) && 586 if (LowerCaseEqualsASCII(input_.scheme(), net::kHttpsScheme) &&
586 parts.path.is_nonempty()) 587 parts.path.is_nonempty())
587 return false; 588 return false;
588 589
589 return true; 590 return true;
590 } 591 }
591 592
592 void SearchProvider::RemoveAllStaleResults() { 593 void SearchProvider::RemoveAllStaleResults() {
593 if (keyword_input_.text().empty()) { 594 if (keyword_input_.text().empty()) {
594 // User is either in keyword mode with a blank input or out of 595 // User is either in keyword mode with a blank input or out of
595 // keyword mode entirely. 596 // keyword mode entirely.
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 match.RecordAdditionalInfo(kShouldPrefetchKey, kFalse); 1125 match.RecordAdditionalInfo(kShouldPrefetchKey, kFalse);
1125 1126
1126 return match; 1127 return match;
1127 } 1128 }
1128 1129
1129 void SearchProvider::UpdateDone() { 1130 void SearchProvider::UpdateDone() {
1130 // We're done when the timer isn't running, there are no suggest queries 1131 // We're done when the timer isn't running, there are no suggest queries
1131 // pending, and we're not waiting on Instant. 1132 // pending, and we're not waiting on Instant.
1132 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); 1133 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0);
1133 } 1134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698