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

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

Issue 2225073002: [Chrome OS] Change layout of the launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/search/app_search_provider.cc
diff --git a/chrome/browser/ui/app_list/search/app_search_provider.cc b/chrome/browser/ui/app_list/search/app_search_provider.cc
index e2ea88211b1bb4a5679906a07d48907794eb6241..435029d36bddb610b7b3f9bec19157da00ce2318 100644
--- a/chrome/browser/ui/app_list/search/app_search_provider.cc
+++ b/chrome/browser/ui/app_list/search/app_search_provider.cc
@@ -51,23 +51,27 @@ class AppSearchProvider::App {
App(AppSearchProvider::DataSource* data_source,
const std::string& id,
const std::string& name,
- const base::Time& last_launch_time)
+ const base::Time& last_launch_time,
+ const base::Time& install_time)
: data_source_(data_source),
id_(id),
indexed_name_(base::UTF8ToUTF16(name)),
- last_launch_time_(last_launch_time) {}
+ last_launch_time_(last_launch_time),
+ install_time_(install_time) {}
~App() {}
AppSearchProvider::DataSource* data_source() { return data_source_; }
const std::string& id() const { return id_; }
const TokenizedString& indexed_name() const { return indexed_name_; }
const base::Time& last_launch_time() const { return last_launch_time_; }
+ const base::Time& install_time() const { return install_time_; }
private:
AppSearchProvider::DataSource* data_source_;
const std::string id_;
const TokenizedString indexed_name_;
const base::Time last_launch_time_;
+ const base::Time install_time_;
DISALLOW_COPY_AND_ASSIGN(App);
};
@@ -160,7 +164,8 @@ class ExtensionDataSource : public AppSearchProvider::DataSource,
std::unique_ptr<AppSearchProvider::App> app(new AppSearchProvider::App(
this, extension->id(), extension->short_name(),
- prefs->GetLastLaunchTime(extension->id())));
+ prefs->GetLastLaunchTime(extension->id()),
+ prefs->GetInstallTime(extension->id())));
apps->push_back(std::move(app));
}
}
@@ -203,7 +208,8 @@ class ArcDataSource : public AppSearchProvider::DataSource,
}
std::unique_ptr<AppSearchProvider::App> app(new AppSearchProvider::App(
- this, app_id, app_info->name, app_info->last_launch_time));
+ this, app_id, app_info->name, app_info->last_launch_time,
+ app_info->install_time));
apps->push_back(std::move(app));
}
}
@@ -306,19 +312,27 @@ void AppSearchProvider::UpdateResults() {
result->set_title(app->indexed_name().text());
// Use the app list order to tiebreak apps that have never been launched.
+ // The apps that have been installed or launched recently should be
+ // more relevant than other apps.
if (app->last_launch_time().is_null()) {
- auto it = id_to_app_list_index.find(app->id());
- // If it's in a folder, it won't be in |id_to_app_list_index|. Rank
- // those as if they are at the end of the list.
- size_t app_list_index =
- it == id_to_app_list_index.end() ? apps_.size() : (*it).second;
- if (app_list_index > apps_.size())
- app_list_index = apps_.size();
-
- result->set_relevance(kUnlaunchedAppRelevanceStepSize *
- (apps_.size() - app_list_index));
+ if (app->install_time().is_null()) {
xiyuan 2016/08/08 18:02:15 nit: prefer to choose a time and get rid of one ne
xdai1 2016/08/08 21:25:37 Done.
+ auto it = id_to_app_list_index.find(app->id());
+ // If it's in a folder, it won't be in |id_to_app_list_index|. Rank
+ // those as if they are at the end of the list.
+ size_t app_list_index =
+ it == id_to_app_list_index.end() ? apps_.size() : (*it).second;
+ if (app_list_index > apps_.size())
+ app_list_index = apps_.size();
+
+ result->set_relevance(kUnlaunchedAppRelevanceStepSize *
+ (apps_.size() - app_list_index));
+ } else {
+ result->UpdateFromLastLaunchedOrInstalledTime(clock_->Now(),
+ app->install_time());
+ }
} else {
- result->UpdateFromLastLaunched(clock_->Now(), app->last_launch_time());
+ result->UpdateFromLastLaunchedOrInstalledTime(clock_->Now(),
+ app->last_launch_time());
}
Add(std::move(result));
}

Powered by Google App Engine
This is Rietveld 408576698