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/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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 scoped_refptr<ShortcutsBackend> backend = | 60 scoped_refptr<ShortcutsBackend> backend = |
61 ShortcutsBackendFactory::GetForProfile(profile_); | 61 ShortcutsBackendFactory::GetForProfile(profile_); |
62 if (backend.get()) { | 62 if (backend.get()) { |
63 backend->AddObserver(this); | 63 backend->AddObserver(this); |
64 if (backend->initialized()) | 64 if (backend->initialized()) |
65 initialized_ = true; | 65 initialized_ = true; |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 void ShortcutsProvider::Start(const AutocompleteInput& input, | 69 void ShortcutsProvider::Start(const AutocompleteInput& input, |
70 bool minimal_changes) { | 70 bool minimal_changes, |
71 bool on_focus) { | |
71 matches_.clear(); | 72 matches_.clear(); |
72 | 73 |
74 if (on_focus) | |
Peter Kasting
2015/01/07 20:16:36
Nit: I would just combine all these conditions her
Maria
2015/01/08 07:52:38
Done.
| |
75 return; | |
76 | |
73 if ((input.type() == metrics::OmniboxInputType::INVALID) || | 77 if ((input.type() == metrics::OmniboxInputType::INVALID) || |
74 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) | 78 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) |
75 return; | 79 return; |
76 | 80 |
77 if (input.text().empty()) | 81 if (input.text().empty()) |
78 return; | 82 return; |
79 | 83 |
80 if (!initialized_) | 84 if (!initialized_) |
81 return; | 85 return; |
82 | 86 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. | 407 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. |
404 const double kMaxDecaySpeedDivisor = 5.0; | 408 const double kMaxDecaySpeedDivisor = 5.0; |
405 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; | 409 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; |
406 double decay_divisor = std::min(kMaxDecaySpeedDivisor, | 410 double decay_divisor = std::min(kMaxDecaySpeedDivisor, |
407 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / | 411 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / |
408 kNumUsesPerDecaySpeedDivisorIncrement); | 412 kNumUsesPerDecaySpeedDivisorIncrement); |
409 | 413 |
410 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + | 414 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + |
411 0.5); | 415 0.5); |
412 } | 416 } |
OLD | NEW |