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

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

Issue 254763005: Move some content url constants to /url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update url/BUILD.gn and address some style nits. Created 6 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/history_url_provider.h" 5 #include "chrome/browser/autocomplete/history_url_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/search_engines/template_url_service.h" 31 #include "chrome/browser/search_engines/template_url_service.h"
32 #include "chrome/browser/search_engines/template_url_service_factory.h" 32 #include "chrome/browser/search_engines/template_url_service_factory.h"
33 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
34 #include "chrome/common/net/url_fixer_upper.h" 34 #include "chrome/common/net/url_fixer_upper.h"
35 #include "chrome/common/pref_names.h" 35 #include "chrome/common/pref_names.h"
36 #include "chrome/common/url_constants.h" 36 #include "chrome/common/url_constants.h"
37 #include "net/base/net_util.h" 37 #include "net/base/net_util.h"
38 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 38 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
39 #include "url/gurl.h" 39 #include "url/gurl.h"
40 #include "url/url_constants.h"
40 #include "url/url_parse.h" 41 #include "url/url_parse.h"
41 #include "url/url_util.h" 42 #include "url/url_util.h"
42 43
43 namespace { 44 namespace {
44 45
45 // If |create_if_necessary| is true, ensures that |matches| contains an 46 // If |create_if_necessary| is true, ensures that |matches| contains an
46 // entry for |info|, creating a new such entry if necessary (using 47 // entry for |info|, creating a new such entry if necessary (using
47 // |input_location| and |match_in_scheme|). 48 // |input_location| and |match_in_scheme|).
48 // 49 //
49 // If |promote| is true, this also ensures the entry is the first element in 50 // If |promote| is true, this also ensures the entry is the first element in
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 } 856 }
856 857
857 bool HistoryURLProvider::CanFindIntranetURL( 858 bool HistoryURLProvider::CanFindIntranetURL(
858 history::URLDatabase* db, 859 history::URLDatabase* db,
859 const AutocompleteInput& input) const { 860 const AutocompleteInput& input) const {
860 // Normally passing the first two conditions below ought to guarantee the 861 // Normally passing the first two conditions below ought to guarantee the
861 // third condition, but because FixupUserInput() can run and modify the 862 // third condition, but because FixupUserInput() can run and modify the
862 // input's text and parts between Parse() and here, it seems better to be 863 // input's text and parts between Parse() and here, it seems better to be
863 // paranoid and check. 864 // paranoid and check.
864 if ((input.type() != AutocompleteInput::UNKNOWN) || 865 if ((input.type() != AutocompleteInput::UNKNOWN) ||
865 !LowerCaseEqualsASCII(input.scheme(), content::kHttpScheme) || 866 !LowerCaseEqualsASCII(input.scheme(), url::kHttpScheme) ||
866 !input.parts().host.is_nonempty()) 867 !input.parts().host.is_nonempty())
867 return false; 868 return false;
868 const std::string host(base::UTF16ToUTF8( 869 const std::string host(base::UTF16ToUTF8(
869 input.text().substr(input.parts().host.begin, input.parts().host.len))); 870 input.text().substr(input.parts().host.begin, input.parts().host.len)));
870 const size_t registry_length = 871 const size_t registry_length =
871 net::registry_controlled_domains::GetRegistryLength( 872 net::registry_controlled_domains::GetRegistryLength(
872 host, 873 host,
873 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, 874 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
874 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); 875 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
875 return registry_length == 0 && db->IsTypedHost(host); 876 return registry_length == 0 && db->IsTypedHost(host);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 // If HistoryURL retrieves any matches (and hence we reach this code), we 1159 // If HistoryURL retrieves any matches (and hence we reach this code), we
1159 // are guaranteed that the beginning of input_text must be a word break. 1160 // are guaranteed that the beginning of input_text must be a word break.
1160 history::WordStarts offsets(1, 0u); 1161 history::WordStarts offsets(1, 0u);
1161 description_matches = 1162 description_matches =
1162 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts( 1163 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts(
1163 description_matches, offsets, description_word_starts, 0, 1164 description_matches, offsets, description_word_starts, 0,
1164 std::string::npos); 1165 std::string::npos);
1165 return SpansFromTermMatch( 1166 return SpansFromTermMatch(
1166 description_matches, clean_description.length(), false); 1167 description_matches, clean_description.length(), false);
1167 } 1168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698