| 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 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" | 26 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" |
| 27 #include "chrome/browser/autocomplete/url_prefix.h" | 27 #include "chrome/browser/autocomplete/url_prefix.h" |
| 28 #include "chrome/browser/history/history_notifications.h" | 28 #include "chrome/browser/history/history_notifications.h" |
| 29 #include "chrome/browser/history/history_service.h" | 29 #include "chrome/browser/history/history_service.h" |
| 30 #include "chrome/browser/history/history_service_factory.h" | 30 #include "chrome/browser/history/history_service_factory.h" |
| 31 #include "chrome/browser/omnibox/omnibox_field_trial.h" | 31 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
| 32 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 33 #include "chrome/common/net/url_fixer_upper.h" | 33 #include "chrome/common/net/url_fixer_upper.h" |
| 34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
| 36 #include "components/metrics/proto/omnibox_input_type.pb.h" | |
| 37 #include "url/url_parse.h" | 36 #include "url/url_parse.h" |
| 38 | 37 |
| 39 namespace { | 38 namespace { |
| 40 | 39 |
| 41 class DestinationURLEqualsURL { | 40 class DestinationURLEqualsURL { |
| 42 public: | 41 public: |
| 43 explicit DestinationURLEqualsURL(const GURL& url) : url_(url) {} | 42 explicit DestinationURLEqualsURL(const GURL& url) : url_(url) {} |
| 44 bool operator()(const AutocompleteMatch& match) const { | 43 bool operator()(const AutocompleteMatch& match) const { |
| 45 return match.destination_url == url_; | 44 return match.destination_url == url_; |
| 46 } | 45 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 64 backend->AddObserver(this); | 63 backend->AddObserver(this); |
| 65 if (backend->initialized()) | 64 if (backend->initialized()) |
| 66 initialized_ = true; | 65 initialized_ = true; |
| 67 } | 66 } |
| 68 } | 67 } |
| 69 | 68 |
| 70 void ShortcutsProvider::Start(const AutocompleteInput& input, | 69 void ShortcutsProvider::Start(const AutocompleteInput& input, |
| 71 bool minimal_changes) { | 70 bool minimal_changes) { |
| 72 matches_.clear(); | 71 matches_.clear(); |
| 73 | 72 |
| 74 if ((input.type() == metrics::OmniboxInputType::INVALID) || | 73 if ((input.type() == AutocompleteInput::INVALID) || |
| 75 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) | 74 (input.type() == AutocompleteInput::FORCED_QUERY)) |
| 76 return; | 75 return; |
| 77 | 76 |
| 78 if (input.text().empty()) | 77 if (input.text().empty()) |
| 79 return; | 78 return; |
| 80 | 79 |
| 81 if (!initialized_) | 80 if (!initialized_) |
| 82 return; | 81 return; |
| 83 | 82 |
| 84 base::TimeTicks start_time = base::TimeTicks::Now(); | 83 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 85 GetMatches(input); | 84 GetMatches(input); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. | 412 // (1.0 / each 5 additional hits), up to a maximum of 5x as long. |
| 414 const double kMaxDecaySpeedDivisor = 5.0; | 413 const double kMaxDecaySpeedDivisor = 5.0; |
| 415 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; | 414 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; |
| 416 double decay_divisor = std::min(kMaxDecaySpeedDivisor, | 415 double decay_divisor = std::min(kMaxDecaySpeedDivisor, |
| 417 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / | 416 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / |
| 418 kNumUsesPerDecaySpeedDivisorIncrement); | 417 kNumUsesPerDecaySpeedDivisorIncrement); |
| 419 | 418 |
| 420 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + | 419 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + |
| 421 0.5); | 420 0.5); |
| 422 } | 421 } |
| OLD | NEW |