Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: chrome/browser/autocomplete/shortcuts_provider.cc

Issue 10909130: autocomplete: Add AutocompleteProvider::Type enum. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix inadvertently-change parameter in test Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 private: 43 private:
44 // Lifetime of the object is less than the lifetime of passed |urls|, so 44 // Lifetime of the object is less than the lifetime of passed |urls|, so
45 // it is safe to store reference. 45 // it is safe to store reference.
46 const std::set<GURL>& urls_; 46 const std::set<GURL>& urls_;
47 }; 47 };
48 48
49 } // namespace 49 } // namespace
50 50
51 ShortcutsProvider::ShortcutsProvider(AutocompleteProviderListener* listener, 51 ShortcutsProvider::ShortcutsProvider(AutocompleteProviderListener* listener,
52 Profile* profile) 52 Profile* profile)
53 : AutocompleteProvider(listener, profile, "Shortcuts"), 53 : AutocompleteProvider(listener, profile,
54 AutocompleteProvider::TYPE_SHORTCUTS),
54 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), 55 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)),
55 initialized_(false) { 56 initialized_(false) {
56 scoped_refptr<history::ShortcutsBackend> backend = 57 scoped_refptr<history::ShortcutsBackend> backend =
57 ShortcutsBackendFactory::GetForProfile(profile_); 58 ShortcutsBackendFactory::GetForProfile(profile_);
58 if (backend) { 59 if (backend) {
59 backend->AddObserver(this); 60 backend->AddObserver(this);
60 if (backend->initialized()) 61 if (backend->initialized())
61 initialized_ = true; 62 initialized_ = true;
62 } 63 }
63 } 64 }
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. 358 // (1.0 / each 5 additional hits), up to a maximum of 5x as long.
358 const double kMaxDecaySpeedDivisor = 5.0; 359 const double kMaxDecaySpeedDivisor = 5.0;
359 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; 360 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0;
360 double decay_divisor = std::min(kMaxDecaySpeedDivisor, 361 double decay_divisor = std::min(kMaxDecaySpeedDivisor,
361 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / 362 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) /
362 kNumUsesPerDecaySpeedDivisorIncrement); 363 kNumUsesPerDecaySpeedDivisorIncrement);
363 364
364 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + 365 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) +
365 0.5); 366 0.5);
366 } 367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698