OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/shortcuts_provider.h" | 5 #include "chrome/browser/autocomplete/shortcuts_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 return urls_.find(match.destination_url) != urls_.end(); | 65 return urls_.find(match.destination_url) != urls_.end(); |
66 } | 66 } |
67 private: | 67 private: |
68 // Lifetime of the object is less than the lifetime of passed |urls|, so | 68 // Lifetime of the object is less than the lifetime of passed |urls|, so |
69 // it is safe to store reference. | 69 // it is safe to store reference. |
70 const std::set<GURL>& urls_; | 70 const std::set<GURL>& urls_; |
71 }; | 71 }; |
72 | 72 |
73 } // namespace | 73 } // namespace |
74 | 74 |
75 // A match needs to score at least 1200 to be default, so set the max below | 75 // For ease of unit testing, make the clamp value divisible by 4 (since some |
76 // this. For ease of unit testing, make it divisible by 4 (since some tests | 76 // tests check for half or quarter of the max score). |
77 // check for half or quarter of the max score). | 77 // static |
78 const int ShortcutsProvider::kMaxScore = 1196; | 78 const int ShortcutsProvider::kMaxScore = |
79 (AutocompleteResult::kLowestDefaultScore - 1) & ~3; | |
sky
2011/07/15 23:01:34
Wow, that's obscure (the & ~3)
| |
79 | 80 |
80 ShortcutsProvider::ShortcutsProvider(ACProviderListener* listener, | 81 ShortcutsProvider::ShortcutsProvider(ACProviderListener* listener, |
81 Profile* profile) | 82 Profile* profile) |
82 : AutocompleteProvider(listener, profile, "ShortcutsProvider"), | 83 : AutocompleteProvider(listener, profile, "ShortcutsProvider"), |
83 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)) { | 84 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)) { |
84 notification_registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 85 notification_registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
85 Source<Profile>(profile)); | 86 Source<Profile>(profile)); |
86 notification_registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, | 87 notification_registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, |
87 Source<Profile>(profile)); | 88 Source<Profile>(profile)); |
88 } | 89 } |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 StripMatchMarkersFromClassifications(&description_class); | 394 StripMatchMarkersFromClassifications(&description_class); |
394 } | 395 } |
395 | 396 |
396 ShortcutsProvider::Shortcut::Shortcut() | 397 ShortcutsProvider::Shortcut::Shortcut() |
397 : last_access_time(base::Time::Now()), | 398 : last_access_time(base::Time::Now()), |
398 number_of_hits(0) { | 399 number_of_hits(0) { |
399 } | 400 } |
400 | 401 |
401 ShortcutsProvider::Shortcut::~Shortcut() { | 402 ShortcutsProvider::Shortcut::~Shortcut() { |
402 } | 403 } |
OLD | NEW |