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

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

Issue 273193004: Move some content url constants to /url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing files. Created 6 years, 6 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/base64.h" 10 #include "base/base64.h"
(...skipping 21 matching lines...) Expand all
32 #include "chrome/browser/metrics/variations/variations_http_header_provider.h" 32 #include "chrome/browser/metrics/variations/variations_http_header_provider.h"
33 #include "chrome/browser/omnibox/omnibox_field_trial.h" 33 #include "chrome/browser/omnibox/omnibox_field_trial.h"
34 #include "chrome/browser/profiles/profile.h" 34 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/search/search.h" 35 #include "chrome/browser/search/search.h"
36 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 36 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
37 #include "chrome/browser/search_engines/template_url_service.h" 37 #include "chrome/browser/search_engines/template_url_service.h"
38 #include "chrome/browser/search_engines/template_url_service_factory.h" 38 #include "chrome/browser/search_engines/template_url_service_factory.h"
39 #include "chrome/browser/ui/search/instant_controller.h" 39 #include "chrome/browser/ui/search/instant_controller.h"
40 #include "chrome/common/chrome_switches.h" 40 #include "chrome/common/chrome_switches.h"
41 #include "chrome/common/pref_names.h" 41 #include "chrome/common/pref_names.h"
42 #include "chrome/common/url_constants.h"
43 #include "content/public/browser/user_metrics.h" 42 #include "content/public/browser/user_metrics.h"
44 #include "grit/generated_resources.h" 43 #include "grit/generated_resources.h"
45 #include "net/base/escape.h" 44 #include "net/base/escape.h"
46 #include "net/base/load_flags.h" 45 #include "net/base/load_flags.h"
47 #include "net/base/net_util.h" 46 #include "net/base/net_util.h"
48 #include "net/http/http_request_headers.h" 47 #include "net/http/http_request_headers.h"
49 #include "net/url_request/url_fetcher.h" 48 #include "net/url_request/url_fetcher.h"
50 #include "net/url_request/url_request_status.h" 49 #include "net/url_request/url_request_status.h"
51 #include "ui/base/l10n/l10n_util.h" 50 #include "ui/base/l10n/l10n_util.h"
51 #include "url/url_constants.h"
52 #include "url/url_util.h" 52 #include "url/url_util.h"
53 53
54 // Helpers -------------------------------------------------------------------- 54 // Helpers --------------------------------------------------------------------
55 55
56 namespace { 56 namespace {
57 57
58 // We keep track in a histogram how many suggest requests we send, how 58 // We keep track in a histogram how many suggest requests we send, how
59 // many suggest requests we invalidate (e.g., due to a user typing 59 // many suggest requests we invalidate (e.g., due to a user typing
60 // another character), and how many replies we receive. 60 // another character), and how many replies we receive.
61 // *** ADD NEW ENUMS AFTER ALL PREVIOUSLY DEFINED ONES! *** 61 // *** ADD NEW ENUMS AFTER ALL PREVIOUSLY DEFINED ONES! ***
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 // is both a waste of time and a disclosure of potentially private, local 557 // is both a waste of time and a disclosure of potentially private, local
558 // data. Other "schemes" may actually be usernames, and we don't want to send 558 // data. Other "schemes" may actually be usernames, and we don't want to send
559 // passwords. If the scheme is OK, we still need to check other cases below. 559 // passwords. If the scheme is OK, we still need to check other cases below.
560 // If this is QUERY, then the presence of these schemes means the user 560 // If this is QUERY, then the presence of these schemes means the user
561 // explicitly typed one, and thus this is probably a URL that's being entered 561 // explicitly typed one, and thus this is probably a URL that's being entered
562 // and happens to currently be invalid -- in which case we again want to run 562 // and happens to currently be invalid -- in which case we again want to run
563 // our checks below. Other QUERY cases are less likely to be URLs and thus we 563 // our checks below. Other QUERY cases are less likely to be URLs and thus we
564 // assume we're OK. 564 // assume we're OK.
565 if (!LowerCaseEqualsASCII(input_.scheme(), url::kHttpScheme) && 565 if (!LowerCaseEqualsASCII(input_.scheme(), url::kHttpScheme) &&
566 !LowerCaseEqualsASCII(input_.scheme(), url::kHttpsScheme) && 566 !LowerCaseEqualsASCII(input_.scheme(), url::kHttpsScheme) &&
567 !LowerCaseEqualsASCII(input_.scheme(), content::kFtpScheme)) 567 !LowerCaseEqualsASCII(input_.scheme(), url::kFtpScheme))
568 return (input_.type() == AutocompleteInput::QUERY); 568 return (input_.type() == AutocompleteInput::QUERY);
569 569
570 // Don't send URLs with usernames, queries or refs. Some of these are 570 // Don't send URLs with usernames, queries or refs. Some of these are
571 // private, and the Suggest server is unlikely to have any useful results 571 // private, and the Suggest server is unlikely to have any useful results
572 // for any of them. Also don't send URLs with ports, as we may initially 572 // for any of them. Also don't send URLs with ports, as we may initially
573 // think that a username + password is a host + port (and we don't want to 573 // think that a username + password is a host + port (and we don't want to
574 // send usernames/passwords), and even if the port really is a port, the 574 // send usernames/passwords), and even if the port really is a port, the
575 // server is once again unlikely to have and useful results. 575 // server is once again unlikely to have and useful results.
576 // Note that we only block based on refs if the input is URL-typed, as search 576 // Note that we only block based on refs if the input is URL-typed, as search
577 // queries can legitimately have #s in them which the URL parser 577 // queries can legitimately have #s in them which the URL parser
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 // Make the base64 encoded value URL and filename safe(see RFC 3548). 1154 // Make the base64 encoded value URL and filename safe(see RFC 3548).
1155 std::replace(current_token_.begin(), current_token_.end(), '+', '-'); 1155 std::replace(current_token_.begin(), current_token_.end(), '+', '-');
1156 std::replace(current_token_.begin(), current_token_.end(), '/', '_'); 1156 std::replace(current_token_.begin(), current_token_.end(), '/', '_');
1157 } 1157 }
1158 1158
1159 // Extend expiration time another 60 seconds. 1159 // Extend expiration time another 60 seconds.
1160 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60); 1160 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60);
1161 1161
1162 return current_token_; 1162 return current_token_;
1163 } 1163 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_input.cc ('k') | chrome/browser/browsing_data/browsing_data_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698