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/bookmark_provider.h" | 5 #include "components/omnibox/browser/bookmark_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/trace_event/trace_event.h" |
14 #include "components/bookmarks/browser/bookmark_match.h" | 15 #include "components/bookmarks/browser/bookmark_match.h" |
15 #include "components/bookmarks/browser/bookmark_model.h" | 16 #include "components/bookmarks/browser/bookmark_model.h" |
16 #include "components/metrics/proto/omnibox_input_type.pb.h" | 17 #include "components/metrics/proto/omnibox_input_type.pb.h" |
17 #include "components/omnibox/browser/autocomplete_provider_client.h" | 18 #include "components/omnibox/browser/autocomplete_provider_client.h" |
18 #include "components/omnibox/browser/autocomplete_result.h" | 19 #include "components/omnibox/browser/autocomplete_result.h" |
19 #include "components/omnibox/browser/history_provider.h" | 20 #include "components/omnibox/browser/history_provider.h" |
20 #include "components/omnibox/browser/url_prefix.h" | 21 #include "components/omnibox/browser/url_prefix.h" |
21 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
22 #include "components/url_formatter/url_formatter.h" | 23 #include "components/url_formatter/url_formatter.h" |
23 #include "url/url_constants.h" | 24 #include "url/url_constants.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 client_(client), | 59 client_(client), |
59 bookmark_model_(NULL) { | 60 bookmark_model_(NULL) { |
60 if (client_) { | 61 if (client_) { |
61 bookmark_model_ = client_->GetBookmarkModel(); | 62 bookmark_model_ = client_->GetBookmarkModel(); |
62 languages_ = client_->GetAcceptLanguages(); | 63 languages_ = client_->GetAcceptLanguages(); |
63 } | 64 } |
64 } | 65 } |
65 | 66 |
66 void BookmarkProvider::Start(const AutocompleteInput& input, | 67 void BookmarkProvider::Start(const AutocompleteInput& input, |
67 bool minimal_changes) { | 68 bool minimal_changes) { |
| 69 TRACE_EVENT0("omnibox", "BookmarkProvider::Start"); |
68 if (minimal_changes) | 70 if (minimal_changes) |
69 return; | 71 return; |
70 matches_.clear(); | 72 matches_.clear(); |
71 | 73 |
72 if (input.from_omnibox_focus() || input.text().empty() || | 74 if (input.from_omnibox_focus() || input.text().empty() || |
73 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) | 75 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) |
74 return; | 76 return; |
75 | 77 |
76 DoAutocomplete(input); | 78 DoAutocomplete(input); |
77 } | 79 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 i != positions.end(); | 339 i != positions.end(); |
338 ++i) { | 340 ++i) { |
339 AutocompleteMatch::ACMatchClassifications new_class; | 341 AutocompleteMatch::ACMatchClassifications new_class; |
340 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first, | 342 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first, |
341 text_length, url_style, &new_class); | 343 text_length, url_style, &new_class); |
342 classifications = AutocompleteMatch::MergeClassifications( | 344 classifications = AutocompleteMatch::MergeClassifications( |
343 classifications, new_class); | 345 classifications, new_class); |
344 } | 346 } |
345 return classifications; | 347 return classifications; |
346 } | 348 } |
OLD | NEW |