| 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 12 matching lines...) Expand all Loading... |
| 23 #include "chrome/browser/history/history_service.h" | 23 #include "chrome/browser/history/history_service.h" |
| 24 #include "chrome/browser/history/history_service_factory.h" | 24 #include "chrome/browser/history/history_service_factory.h" |
| 25 #include "chrome/browser/history/history_types.h" | 25 #include "chrome/browser/history/history_types.h" |
| 26 #include "chrome/browser/history/in_memory_url_index_types.h" | 26 #include "chrome/browser/history/in_memory_url_index_types.h" |
| 27 #include "chrome/browser/history/scored_history_match.h" | 27 #include "chrome/browser/history/scored_history_match.h" |
| 28 #include "chrome/browser/omnibox/omnibox_field_trial.h" | 28 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/search_engines/template_url_service.h" | 30 #include "chrome/browser/search_engines/template_url_service.h" |
| 31 #include "chrome/browser/search_engines/template_url_service_factory.h" | 31 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/net/url_fixer_upper.h" | |
| 34 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
| 36 #include "components/bookmarks/browser/bookmark_utils.h" | 35 #include "components/bookmarks/browser/bookmark_utils.h" |
| 37 #include "components/metrics/proto/omnibox_input_type.pb.h" | 36 #include "components/metrics/proto/omnibox_input_type.pb.h" |
| 37 #include "components/url_fixer/url_fixer.h" |
| 38 #include "net/base/net_util.h" | 38 #include "net/base/net_util.h" |
| 39 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 39 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 40 #include "url/gurl.h" | 40 #include "url/gurl.h" |
| 41 #include "url/url_parse.h" | 41 #include "url/url_parse.h" |
| 42 #include "url/url_util.h" | 42 #include "url/url_util.h" |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 // If |create_if_necessary| is true, ensures that |matches| contains an | 46 // If |create_if_necessary| is true, ensures that |matches| contains an |
| 47 // entry for |info|, creating a new such entry if necessary (using | 47 // entry for |info|, creating a new such entry if necessary (using |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 TemplateURL* default_search_provider = template_url_service ? | 444 TemplateURL* default_search_provider = template_url_service ? |
| 445 template_url_service->GetDefaultSearchProvider() : NULL; | 445 template_url_service->GetDefaultSearchProvider() : NULL; |
| 446 UIThreadSearchTermsData data(profile_); | 446 UIThreadSearchTermsData data(profile_); |
| 447 | 447 |
| 448 // Do some fixup on the user input before matching against it, so we provide | 448 // Do some fixup on the user input before matching against it, so we provide |
| 449 // good results for local file paths, input with spaces, etc. | 449 // good results for local file paths, input with spaces, etc. |
| 450 const FixupReturn fixup_return(FixupUserInput(input)); | 450 const FixupReturn fixup_return(FixupUserInput(input)); |
| 451 if (!fixup_return.first) | 451 if (!fixup_return.first) |
| 452 return; | 452 return; |
| 453 url::Parsed parts; | 453 url::Parsed parts; |
| 454 URLFixerUpper::SegmentURL(fixup_return.second, &parts); | 454 url_fixer::SegmentURL(fixup_return.second, &parts); |
| 455 AutocompleteInput fixed_up_input(input); | 455 AutocompleteInput fixed_up_input(input); |
| 456 fixed_up_input.UpdateText(fixup_return.second, base::string16::npos, parts); | 456 fixed_up_input.UpdateText(fixup_return.second, base::string16::npos, parts); |
| 457 | 457 |
| 458 // Create the data structure for the autocomplete passes. We'll save this off | 458 // Create the data structure for the autocomplete passes. We'll save this off |
| 459 // onto the |params_| member for later deletion below if we need to run pass | 459 // onto the |params_| member for later deletion below if we need to run pass |
| 460 // 2. | 460 // 2. |
| 461 scoped_ptr<HistoryURLProviderParams> params( | 461 scoped_ptr<HistoryURLProviderParams> params( |
| 462 new HistoryURLProviderParams( | 462 new HistoryURLProviderParams( |
| 463 fixed_up_input, trim_http, | 463 fixed_up_input, trim_http, |
| 464 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 464 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 // If HistoryURL retrieves any matches (and hence we reach this code), we | 1156 // If HistoryURL retrieves any matches (and hence we reach this code), we |
| 1157 // are guaranteed that the beginning of input_text must be a word break. | 1157 // are guaranteed that the beginning of input_text must be a word break. |
| 1158 history::WordStarts offsets(1, 0u); | 1158 history::WordStarts offsets(1, 0u); |
| 1159 description_matches = | 1159 description_matches = |
| 1160 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts( | 1160 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts( |
| 1161 description_matches, offsets, description_word_starts, 0, | 1161 description_matches, offsets, description_word_starts, 0, |
| 1162 std::string::npos); | 1162 std::string::npos); |
| 1163 return SpansFromTermMatch( | 1163 return SpansFromTermMatch( |
| 1164 description_matches, clean_description.length(), false); | 1164 description_matches, clean_description.length(), false); |
| 1165 } | 1165 } |
| OLD | NEW |