| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // threads (though not simultaneously). | 173 // threads (though not simultaneously). |
| 174 void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend, | 174 void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend, |
| 175 history::URLDatabase* db, | 175 history::URLDatabase* db, |
| 176 HistoryURLProviderParams* params) { | 176 HistoryURLProviderParams* params) { |
| 177 // Create a What You Typed match, which we'll need below. | 177 // Create a What You Typed match, which we'll need below. |
| 178 // | 178 // |
| 179 // We display this to the user when there's a reasonable chance they actually | 179 // We display this to the user when there's a reasonable chance they actually |
| 180 // care: | 180 // care: |
| 181 // * Their input can be opened as a URL, and | 181 // * Their input can be opened as a URL, and |
| 182 // * They hit ctrl-enter, or we parsed the input as a URL, or it starts with | 182 // * They hit ctrl-enter, or we parsed the input as a URL, or it starts with |
| 183 // an explicit "http:" or "https:". | 183 // an explicit "http:", "https:", or "httpsv:". |
| 184 // Otherwise, this is just low-quality noise. In the cases where we've parsed | 184 // Otherwise, this is just low-quality noise. In the cases where we've parsed |
| 185 // as UNKNOWN, we'll still show an accidental search infobar if need be. | 185 // as UNKNOWN, we'll still show an accidental search infobar if need be. |
| 186 bool have_what_you_typed_match = | 186 bool have_what_you_typed_match = |
| 187 params->input.canonicalized_url().is_valid() && | 187 params->input.canonicalized_url().is_valid() && |
| 188 (params->input.type() != AutocompleteInput::QUERY) && | 188 (params->input.type() != AutocompleteInput::QUERY) && |
| 189 ((params->input.type() != AutocompleteInput::UNKNOWN) || | 189 ((params->input.type() != AutocompleteInput::UNKNOWN) || |
| 190 !params->trim_http || | 190 !params->trim_http || |
| 191 url_util::FindAndCompareScheme(UTF16ToUTF8(params->input.text()), | 191 url_util::FindAndCompareScheme(UTF16ToUTF8(params->input.text()), |
| 192 chrome::kHttpsScheme, NULL)); | 192 chrome::kHttpsScheme, NULL) || |
| 193 url_util::FindAndCompareScheme(UTF16ToUTF8(params->input.text()), |
| 194 chrome::kHttpsvScheme, NULL)); |
| 193 AutocompleteMatch what_you_typed_match(SuggestExactInput(params->input, | 195 AutocompleteMatch what_you_typed_match(SuggestExactInput(params->input, |
| 194 params->trim_http)); | 196 params->trim_http)); |
| 195 | 197 |
| 196 // Get the matching URLs from the DB | 198 // Get the matching URLs from the DB |
| 197 typedef std::vector<history::URLRow> URLRowVector; | 199 typedef std::vector<history::URLRow> URLRowVector; |
| 198 URLRowVector url_matches; | 200 URLRowVector url_matches; |
| 199 HistoryMatches history_matches; | 201 HistoryMatches history_matches; |
| 200 | 202 |
| 201 for (Prefixes::const_iterator i(prefixes_.begin()); i != prefixes_.end(); | 203 for (Prefixes::const_iterator i(prefixes_.begin()); i != prefixes_.end(); |
| 202 ++i) { | 204 ++i) { |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 &match.contents_class); | 807 &match.contents_class); |
| 806 } | 808 } |
| 807 match.description = info.title(); | 809 match.description = info.title(); |
| 808 AutocompleteMatch::ClassifyMatchInString(params->input.text(), | 810 AutocompleteMatch::ClassifyMatchInString(params->input.text(), |
| 809 info.title(), | 811 info.title(), |
| 810 ACMatchClassification::NONE, | 812 ACMatchClassification::NONE, |
| 811 &match.description_class); | 813 &match.description_class); |
| 812 | 814 |
| 813 return match; | 815 return match; |
| 814 } | 816 } |
| OLD | NEW |