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

Unified Diff: chrome/browser/ui/app_list/search/app_result.cc

Issue 379333005: Allow AppSearchProvider to provide recommendations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/search/app_result.cc
diff --git a/chrome/browser/ui/app_list/search/app_result.cc b/chrome/browser/ui/app_list/search/app_result.cc
index 5a966f17957f828e97f19b3d4e402901404ccf4d..db1152343e01cc6fa8811c33d1e7970240ac4828 100644
--- a/chrome/browser/ui/app_list/search/app_result.cc
+++ b/chrome/browser/ui/app_list/search/app_result.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/app_list/search/app_result.h"
+#include "base/time/time.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
@@ -73,6 +74,17 @@ void AppResult::UpdateFromMatch(const TokenizedString& title,
set_relevance(match.relevance());
}
+void AppResult::UpdateFromLastLaunched(const base::Time& current_time,
+ const base::Time& last_launched) {
+ base::TimeDelta delta = current_time - last_launched;
+ DCHECK_LE(0, delta.InSeconds());
+ const int kSecondsInWeek = 60 * 60 * 24 * 7;
+
+ // Set the relevance to a value between 0 and 1. This function decays as the
+ // time delta increases and reaches a value of 0.5 at 1 week.
+ set_relevance(1 / (1 + delta.InSecondsF() / kSecondsInWeek));
+}
+
void AppResult::Open(int event_flags) {
const extensions::Extension* extension =
extensions::ExtensionSystem::Get(profile_)->extension_service()

Powered by Google App Engine
This is Rietveld 408576698