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/bookmark_provider.h" | 5 #include "chrome/browser/autocomplete/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 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 : AutocompleteProvider(AutocompleteProvider::TYPE_BOOKMARK), | 58 : AutocompleteProvider(AutocompleteProvider::TYPE_BOOKMARK), |
59 profile_(profile), | 59 profile_(profile), |
60 bookmark_model_(NULL) { | 60 bookmark_model_(NULL) { |
61 if (profile) { | 61 if (profile) { |
62 bookmark_model_ = BookmarkModelFactory::GetForProfile(profile); | 62 bookmark_model_ = BookmarkModelFactory::GetForProfile(profile); |
63 languages_ = profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); | 63 languages_ = profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 void BookmarkProvider::Start(const AutocompleteInput& input, | 67 void BookmarkProvider::Start(const AutocompleteInput& input, |
68 bool minimal_changes) { | 68 bool minimal_changes, |
| 69 bool called_due_to_focus) { |
69 if (minimal_changes) | 70 if (minimal_changes) |
70 return; | 71 return; |
71 matches_.clear(); | 72 matches_.clear(); |
72 | 73 |
73 if (input.text().empty() || | 74 if (called_due_to_focus || input.text().empty() || |
74 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) | 75 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) |
75 return; | 76 return; |
76 | 77 |
77 DoAutocomplete(input); | 78 DoAutocomplete(input); |
78 } | 79 } |
79 | 80 |
80 BookmarkProvider::~BookmarkProvider() {} | 81 BookmarkProvider::~BookmarkProvider() {} |
81 | 82 |
82 void BookmarkProvider::DoAutocomplete(const AutocompleteInput& input) { | 83 void BookmarkProvider::DoAutocomplete(const AutocompleteInput& input) { |
83 // We may not have a bookmark model for some unit tests. | 84 // We may not have a bookmark model for some unit tests. |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 i != positions.end(); | 338 i != positions.end(); |
338 ++i) { | 339 ++i) { |
339 AutocompleteMatch::ACMatchClassifications new_class; | 340 AutocompleteMatch::ACMatchClassifications new_class; |
340 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first, | 341 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first, |
341 text_length, url_style, &new_class); | 342 text_length, url_style, &new_class); |
342 classifications = AutocompleteMatch::MergeClassifications( | 343 classifications = AutocompleteMatch::MergeClassifications( |
343 classifications, new_class); | 344 classifications, new_class); |
344 } | 345 } |
345 return classifications; | 346 return classifications; |
346 } | 347 } |
OLD | NEW |