OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 bool is_keyword) const { | 567 bool is_keyword) const { |
568 // The relevance of past searches falls off over time. There are two distinct | 568 // The relevance of past searches falls off over time. There are two distinct |
569 // equations used. If the first equation is used (searches to the primary | 569 // equations used. If the first equation is used (searches to the primary |
570 // provider with a type other than URL) the score starts at 1399 and falls to | 570 // provider with a type other than URL) the score starts at 1399 and falls to |
571 // 1300. If the second equation is used the relevance of a search 15 minutes | 571 // 1300. If the second equation is used the relevance of a search 15 minutes |
572 // ago is discounted about 50 points, while the relevance of a search two | 572 // ago is discounted about 50 points, while the relevance of a search two |
573 // weeks ago is discounted about 450 points. | 573 // weeks ago is discounted about 450 points. |
574 double elapsed_time = std::max((Time::Now() - time).InSecondsF(), 0.); | 574 double elapsed_time = std::max((Time::Now() - time).InSecondsF(), 0.); |
575 | 575 |
576 if (providers_.is_primary_provider(is_keyword) && | 576 if (providers_.is_primary_provider(is_keyword) && |
577 input_.type() != AutocompleteInput::URL) { | 577 input_.type() != AutocompleteInput::URL && |
| 578 !input_.prevent_inline_autocomplete()) { |
578 // Searches with the past two days get a different curve. | 579 // Searches with the past two days get a different curve. |
579 const double autocomplete_time= 2 * 24 * 60 * 60; | 580 const double autocomplete_time= 2 * 24 * 60 * 60; |
580 if (elapsed_time < autocomplete_time) { | 581 if (elapsed_time < autocomplete_time) { |
581 return 1399 - static_cast<int>(99 * | 582 return 1399 - static_cast<int>(99 * |
582 std::pow(elapsed_time / autocomplete_time, 2.5)); | 583 std::pow(elapsed_time / autocomplete_time, 2.5)); |
583 } | 584 } |
584 elapsed_time -= autocomplete_time; | 585 elapsed_time -= autocomplete_time; |
585 } | 586 } |
586 | 587 |
587 const int score_discount = | 588 const int score_discount = |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 if (input_.type() == AutocompleteInput::FORCED_QUERY) | 754 if (input_.type() == AutocompleteInput::FORCED_QUERY) |
754 match.fill_into_edit.assign(L"?"); | 755 match.fill_into_edit.assign(L"?"); |
755 match.fill_into_edit.append( | 756 match.fill_into_edit.append( |
756 AutocompleteInput::FormattedStringWithEquivalentMeaning(navigation.url, | 757 AutocompleteInput::FormattedStringWithEquivalentMeaning(navigation.url, |
757 match.contents)); | 758 match.contents)); |
758 // TODO(pkasting): http://b/1112879 These should perhaps be | 759 // TODO(pkasting): http://b/1112879 These should perhaps be |
759 // inline-autocompletable? | 760 // inline-autocompletable? |
760 | 761 |
761 return match; | 762 return match; |
762 } | 763 } |
OLD | NEW |