| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/browser/omnibox/omnibox_field_trial.h" | 29 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
| 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 "net/base/url_constants.h" |
| 39 #include "url/gurl.h" | 40 #include "url/gurl.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 // |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 } | 858 } |
| 858 | 859 |
| 859 bool HistoryURLProvider::CanFindIntranetURL( | 860 bool HistoryURLProvider::CanFindIntranetURL( |
| 860 history::URLDatabase* db, | 861 history::URLDatabase* db, |
| 861 const AutocompleteInput& input) const { | 862 const AutocompleteInput& input) const { |
| 862 // Normally passing the first two conditions below ought to guarantee the | 863 // Normally passing the first two conditions below ought to guarantee the |
| 863 // third condition, but because FixupUserInput() can run and modify the | 864 // third condition, but because FixupUserInput() can run and modify the |
| 864 // input's text and parts between Parse() and here, it seems better to be | 865 // input's text and parts between Parse() and here, it seems better to be |
| 865 // paranoid and check. | 866 // paranoid and check. |
| 866 if ((input.type() != AutocompleteInput::UNKNOWN) || | 867 if ((input.type() != AutocompleteInput::UNKNOWN) || |
| 867 !LowerCaseEqualsASCII(input.scheme(), content::kHttpScheme) || | 868 !LowerCaseEqualsASCII(input.scheme(), net::kHttpScheme) || |
| 868 !input.parts().host.is_nonempty()) | 869 !input.parts().host.is_nonempty()) |
| 869 return false; | 870 return false; |
| 870 const std::string host(base::UTF16ToUTF8( | 871 const std::string host(base::UTF16ToUTF8( |
| 871 input.text().substr(input.parts().host.begin, input.parts().host.len))); | 872 input.text().substr(input.parts().host.begin, input.parts().host.len))); |
| 872 const size_t registry_length = | 873 const size_t registry_length = |
| 873 net::registry_controlled_domains::GetRegistryLength( | 874 net::registry_controlled_domains::GetRegistryLength( |
| 874 host, | 875 host, |
| 875 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, | 876 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, |
| 876 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | 877 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
| 877 return registry_length == 0 && db->IsTypedHost(host); | 878 return registry_length == 0 && db->IsTypedHost(host); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 // If HistoryURL retrieves any matches (and hence we reach this code), we | 1161 // If HistoryURL retrieves any matches (and hence we reach this code), we |
| 1161 // are guaranteed that the beginning of input_text must be a word break. | 1162 // are guaranteed that the beginning of input_text must be a word break. |
| 1162 history::WordStarts offsets(1, 0u); | 1163 history::WordStarts offsets(1, 0u); |
| 1163 description_matches = | 1164 description_matches = |
| 1164 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts( | 1165 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts( |
| 1165 description_matches, offsets, description_word_starts, 0, | 1166 description_matches, offsets, description_word_starts, 0, |
| 1166 std::string::npos); | 1167 std::string::npos); |
| 1167 return SpansFromTermMatch( | 1168 return SpansFromTermMatch( |
| 1168 description_matches, clean_description.length(), false); | 1169 description_matches, clean_description.length(), false); |
| 1169 } | 1170 } |
| OLD | NEW |