Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/app_list/search/app_result.h" | 5 #include "chrome/browser/ui/app_list/search/app_result.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_util.h" | 9 #include "chrome/browser/extensions/extension_util.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 tags.push_back(Tag(Tag::MATCH, hits[i].start(), hits[i].end())); | 74 tags.push_back(Tag(Tag::MATCH, hits[i].start(), hits[i].end())); |
| 75 | 75 |
| 76 set_title(title.text()); | 76 set_title(title.text()); |
| 77 set_title_tags(tags); | 77 set_title_tags(tags); |
| 78 set_relevance(match.relevance()); | 78 set_relevance(match.relevance()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void AppResult::UpdateFromLastLaunched(const base::Time& current_time, | 81 void AppResult::UpdateFromLastLaunched(const base::Time& current_time, |
| 82 const base::Time& last_launched) { | 82 const base::Time& last_launched) { |
| 83 base::TimeDelta delta = current_time - last_launched; | 83 base::TimeDelta delta = current_time - last_launched; |
| 84 DCHECK_LE(0, delta.InSeconds()); | 84 if (current_time < last_launched) { |
|
Matt Giuca
2014/12/10 07:16:12
This certainly needs an explanation. (From the bug
calamity
2014/12/11 05:05:01
Done.
| |
| 85 set_relevance(1.0); | |
| 86 return; | |
| 87 } | |
| 88 | |
| 85 const int kSecondsInWeek = 60 * 60 * 24 * 7; | 89 const int kSecondsInWeek = 60 * 60 * 24 * 7; |
| 86 | 90 |
| 87 // Set the relevance to a value between 0 and 1. This function decays as the | 91 // Set the relevance to a value between 0 and 1. This function decays as the |
| 88 // time delta increases and reaches a value of 0.5 at 1 week. | 92 // time delta increases and reaches a value of 0.5 at 1 week. |
| 89 set_relevance(1 / (1 + delta.InSecondsF() / kSecondsInWeek)); | 93 set_relevance(1 / (1 + delta.InSecondsF() / kSecondsInWeek)); |
| 90 } | 94 } |
| 91 | 95 |
| 92 void AppResult::Open(int event_flags) { | 96 void AppResult::Open(int event_flags) { |
| 93 RecordHistogram(APP_SEARCH_RESULT); | 97 RecordHistogram(APP_SEARCH_RESULT); |
| 94 const extensions::Extension* extension = | 98 const extensions::Extension* extension = |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 const extensions::Extension* extension) { | 204 const extensions::Extension* extension) { |
| 201 UpdateIcon(); | 205 UpdateIcon(); |
| 202 } | 206 } |
| 203 | 207 |
| 204 void AppResult::OnShutdown(extensions::ExtensionRegistry* registry) { | 208 void AppResult::OnShutdown(extensions::ExtensionRegistry* registry) { |
| 205 DCHECK_EQ(extension_registry_, registry); | 209 DCHECK_EQ(extension_registry_, registry); |
| 206 StopObservingExtensionRegistry(); | 210 StopObservingExtensionRegistry(); |
| 207 } | 211 } |
| 208 | 212 |
| 209 } // namespace app_list | 213 } // namespace app_list |
| OLD | NEW |