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

Side by Side Diff: chrome/browser/ui/app_list/search/app_result.cc

Issue 2253253002: [Merge to M53][Chrome OS] Change layout of the launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/app_list/app_list_switches.h" 8 #include "ui/app_list/app_list_switches.h"
9 9
10 namespace app_list { 10 namespace app_list {
11 11
12 AppResult::AppResult(Profile* profile, 12 AppResult::AppResult(Profile* profile,
13 const std::string& app_id, 13 const std::string& app_id,
14 AppListControllerDelegate* controller, 14 AppListControllerDelegate* controller,
15 bool is_recommendation) 15 bool is_recommendation)
16 : profile_(profile), 16 : profile_(profile),
17 app_id_(app_id), 17 app_id_(app_id),
18 controller_(controller) { 18 controller_(controller) {
19 if (app_list::switches::IsExperimentalAppListEnabled()) 19 if (app_list::switches::IsExperimentalAppListEnabled())
20 set_display_type(is_recommendation ? DISPLAY_RECOMMENDATION : DISPLAY_TILE); 20 set_display_type(is_recommendation ? DISPLAY_RECOMMENDATION : DISPLAY_TILE);
21 } 21 }
22 22
23 AppResult::~AppResult() { 23 AppResult::~AppResult() {
24 } 24 }
25 25
26 void AppResult::UpdateFromLastLaunched(const base::Time& current_time, 26 void AppResult::UpdateFromLastLaunchedOrInstalledTime(
27 const base::Time& last_launched) { 27 const base::Time& current_time,
28 base::TimeDelta delta = current_time - last_launched; 28 const base::Time& old_time) {
29 // |current_time| can be before |last_launched| in weird cases such as users 29 // |current_time| can be before |old_time| in weird cases such as users
30 // playing with their clocks. Handle this gracefully. 30 // playing with their clocks. Handle this gracefully.
31 if (current_time < last_launched) { 31 if (current_time < old_time) {
32 set_relevance(1.0); 32 set_relevance(1.0);
33 return; 33 return;
34 } 34 }
35 35
36 base::TimeDelta delta = current_time - old_time;
36 const int kSecondsInWeek = 60 * 60 * 24 * 7; 37 const int kSecondsInWeek = 60 * 60 * 24 * 7;
37 38
38 // Set the relevance to a value between 0 and 1. This function decays as the 39 // Set the relevance to a value between 0 and 1. This function decays as the
39 // time delta increases and reaches a value of 0.5 at 1 week. 40 // time delta increases and reaches a value of 0.5 at 1 week.
40 set_relevance(1 / (1 + delta.InSecondsF() / kSecondsInWeek)); 41 set_relevance(1 / (1 + delta.InSecondsF() / kSecondsInWeek));
41 } 42 }
42 43
43 } // namespace app_list 44 } // namespace app_list
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/search/app_result.h ('k') | chrome/browser/ui/app_list/search/app_search_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698