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 "components/omnibox/browser/history_quick_provider.h" | 5 #include "components/omnibox/browser/history_quick_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "components/url_formatter/url_formatter.h" | 31 #include "components/url_formatter/url_formatter.h" |
32 #include "net/base/escape.h" | 32 #include "net/base/escape.h" |
33 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 33 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
34 #include "url/third_party/mozilla/url_parse.h" | 34 #include "url/third_party/mozilla/url_parse.h" |
35 #include "url/url_util.h" | 35 #include "url/url_util.h" |
36 | 36 |
37 bool HistoryQuickProvider::disabled_ = false; | 37 bool HistoryQuickProvider::disabled_ = false; |
38 | 38 |
39 HistoryQuickProvider::HistoryQuickProvider(AutocompleteProviderClient* client) | 39 HistoryQuickProvider::HistoryQuickProvider(AutocompleteProviderClient* client) |
40 : HistoryProvider(AutocompleteProvider::TYPE_HISTORY_QUICK, client), | 40 : HistoryProvider(AutocompleteProvider::TYPE_HISTORY_QUICK, client), |
41 languages_(client->GetAcceptLanguages()), | |
42 in_memory_url_index_(client->GetInMemoryURLIndex()) { | 41 in_memory_url_index_(client->GetInMemoryURLIndex()) { |
43 } | 42 } |
44 | 43 |
45 void HistoryQuickProvider::Start(const AutocompleteInput& input, | 44 void HistoryQuickProvider::Start(const AutocompleteInput& input, |
46 bool minimal_changes) { | 45 bool minimal_changes) { |
47 TRACE_EVENT0("omnibox", "HistoryQuickProvider::Start"); | 46 TRACE_EVENT0("omnibox", "HistoryQuickProvider::Start"); |
48 matches_.clear(); | 47 matches_.clear(); |
49 if (disabled_ || input.from_omnibox_focus()) | 48 if (disabled_ || input.from_omnibox_focus()) |
50 return; | 49 return; |
51 | 50 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 size_t inline_autocomplete_offset = URLPrefix::GetInlineAutocompleteOffset( | 201 size_t inline_autocomplete_offset = URLPrefix::GetInlineAutocompleteOffset( |
203 autocomplete_input_.text(), FixupUserInput(autocomplete_input_).second, | 202 autocomplete_input_.text(), FixupUserInput(autocomplete_input_).second, |
204 false, base::UTF8ToUTF16(info.url().spec())); | 203 false, base::UTF8ToUTF16(info.url().spec())); |
205 | 204 |
206 // Format the URL autocomplete presentation. | 205 // Format the URL autocomplete presentation. |
207 const url_formatter::FormatUrlTypes format_types = | 206 const url_formatter::FormatUrlTypes format_types = |
208 url_formatter::kFormatUrlOmitAll & | 207 url_formatter::kFormatUrlOmitAll & |
209 ~(!history_match.match_in_scheme ? 0 : url_formatter::kFormatUrlOmitHTTP); | 208 ~(!history_match.match_in_scheme ? 0 : url_formatter::kFormatUrlOmitHTTP); |
210 base::OffsetAdjuster::Adjustments adjustments; | 209 base::OffsetAdjuster::Adjustments adjustments; |
211 match.contents = url_formatter::FormatUrlWithAdjustments( | 210 match.contents = url_formatter::FormatUrlWithAdjustments( |
212 info.url(), languages_, format_types, net::UnescapeRule::SPACES, nullptr, | 211 info.url(), format_types, net::UnescapeRule::SPACES, nullptr, |
213 nullptr, &adjustments); | 212 nullptr, &adjustments); |
214 match.fill_into_edit = | 213 match.fill_into_edit = |
215 AutocompleteInput::FormattedStringWithEquivalentMeaning( | 214 AutocompleteInput::FormattedStringWithEquivalentMeaning( |
216 info.url(), match.contents, client()->GetSchemeClassifier()); | 215 info.url(), match.contents, client()->GetSchemeClassifier()); |
217 std::vector<size_t> offsets = | 216 std::vector<size_t> offsets = |
218 OffsetsFromTermMatches(history_match.url_matches); | 217 OffsetsFromTermMatches(history_match.url_matches); |
219 // In addition to knowing how |offsets| is transformed, we need to know how | 218 // In addition to knowing how |offsets| is transformed, we need to know how |
220 // |inline_autocomplete_offset| is transformed. We add it to the end of | 219 // |inline_autocomplete_offset| is transformed. We add it to the end of |
221 // |offsets|, compute how everything is transformed, then remove it from the | 220 // |offsets|, compute how everything is transformed, then remove it from the |
222 // end. | 221 // end. |
(...skipping 12 matching lines...) Expand all Loading... | |
235 // |match.fill_into_edit| if the user has typed an URL with a scheme and the | 234 // |match.fill_into_edit| if the user has typed an URL with a scheme and the |
236 // last character typed is a slash. That slash is removed by the | 235 // last character typed is a slash. That slash is removed by the |
237 // FormatURLWithAdjustments call above. | 236 // FormatURLWithAdjustments call above. |
238 if (inline_autocomplete_offset < match.fill_into_edit.length()) { | 237 if (inline_autocomplete_offset < match.fill_into_edit.length()) { |
239 match.inline_autocompletion = | 238 match.inline_autocompletion = |
240 match.fill_into_edit.substr(inline_autocomplete_offset); | 239 match.fill_into_edit.substr(inline_autocomplete_offset); |
241 } | 240 } |
242 match.allowed_to_be_default_match = match.inline_autocompletion.empty() || | 241 match.allowed_to_be_default_match = match.inline_autocompletion.empty() || |
243 !PreventInlineAutocomplete(autocomplete_input_); | 242 !PreventInlineAutocomplete(autocomplete_input_); |
244 } | 243 } |
245 match.EnsureUWYTIsAllowedToBeDefault( | 244 match.EnsureUWYTIsAllowedToBeDefault(autocomplete_input_, |
246 autocomplete_input_, | |
247 client()->GetAcceptLanguages(), | |
248 client()->GetTemplateURLService()); | 245 client()->GetTemplateURLService()); |
Peter Kasting
2016/04/05 02:42:32
Nit: All lines of args must be indented the same
jungshik at Google
2016/04/05 18:56:18
Done.
| |
249 | 246 |
250 // Format the description autocomplete presentation. | 247 // Format the description autocomplete presentation. |
251 match.description = info.title(); | 248 match.description = info.title(); |
252 match.description_class = SpansFromTermMatch( | 249 match.description_class = SpansFromTermMatch( |
253 history_match.title_matches, match.description.length(), false); | 250 history_match.title_matches, match.description.length(), false); |
254 | 251 |
255 match.RecordAdditionalInfo("typed count", info.typed_count()); | 252 match.RecordAdditionalInfo("typed count", info.typed_count()); |
256 match.RecordAdditionalInfo("visit count", info.visit_count()); | 253 match.RecordAdditionalInfo("visit count", info.visit_count()); |
257 match.RecordAdditionalInfo("last visit", info.last_visit()); | 254 match.RecordAdditionalInfo("last visit", info.last_visit()); |
258 | 255 |
259 return match; | 256 return match; |
260 } | 257 } |
OLD | NEW |