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

Unified Diff: chrome/browser/ui/app_list/arc/arc_app_list_prefs.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_list_prefs.h ('k') | chrome/browser/ui/app_list/search/app_result.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc
diff --git a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc
index 4a3f15b748ad260eb912b06ed05f94291df03858..a8bd3d7902ac8e82008098f226e031bdee782164 100644
--- a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc
+++ b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc
@@ -42,6 +42,7 @@ const char kLastLaunchTime[] = "lastlaunchtime";
const char kShouldSync[] = "should_sync";
const char kSystem[] = "system";
const char kOrientationLock[] = "orientation_lock";
+const char kInstallTime[] = "install_time";
constexpr int kSetNotificationsEnabledMinVersion = 6;
@@ -59,7 +60,7 @@ class ScopedArcPrefUpdate : public DictionaryPrefUpdate {
base::DictionaryValue* Get() override {
base::DictionaryValue* dict = DictionaryPrefUpdate::Get();
base::DictionaryValue* dict_item = nullptr;
- if (!dict->GetDictionary(id_, &dict_item)) {
+ if (!dict->GetDictionaryWithoutPathExpansion(id_, &dict_item)) {
dict_item = new base::DictionaryValue();
dict->SetWithoutPathExpansion(id_, dict_item);
}
@@ -189,7 +190,8 @@ void RemovePackageFromPrefs(PrefService* prefs,
DCHECK(IsArcEnabled());
DictionaryPrefUpdate update(prefs, prefs::kArcPackages);
base::DictionaryValue* packages = update.Get();
- const bool removed = packages->Remove(package_name, nullptr);
+ const bool removed =
+ packages->RemoveWithoutPathExpansion(package_name, nullptr);
DCHECK(removed);
}
@@ -485,7 +487,7 @@ std::unique_ptr<ArcAppListPrefs::AppInfo> ArcAppListPrefs::GetApp(
return base::MakeUnique<AppInfo>(
name, package_name, activity, intent_uri, icon_resource_id,
- last_launch_time, sticky, notifications_enabled,
+ last_launch_time, GetInstallTime(app_id), sticky, notifications_enabled,
ready_apps_.count(app_id) > 0, arc::ShouldShowInLauncher(app_id),
shortcut, orientation_lock);
}
@@ -496,7 +498,7 @@ bool ArcAppListPrefs::IsRegistered(const std::string& app_id) const {
const base::DictionaryValue* app = nullptr;
const base::DictionaryValue* apps = prefs_->GetDictionary(prefs::kArcApps);
- return apps && apps->GetDictionary(app_id, &app);
+ return apps && apps->GetDictionaryWithoutPathExpansion(app_id, &app);
}
bool ArcAppListPrefs::IsShortcut(const std::string& app_id) const {
@@ -622,6 +624,14 @@ void ArcAppListPrefs::AddAppAndShortcut(
app_dict->SetBoolean(kShortcut, shortcut);
app_dict->SetInteger(kOrientationLock, static_cast<int>(orientation_lock));
+ // Note the install time is the first time the Chrome OS sees the app, not the
+ // actual install time in Android side.
+ if (GetInstallTime(app_id).is_null()) {
+ std::string install_time_str =
+ base::Int64ToString(base::Time::Now().ToInternalValue());
+ app_dict->SetString(kInstallTime, install_time_str);
+ }
+
// From now, app is available.
if (!ready_apps_.count(app_id))
ready_apps_.insert(app_id);
@@ -630,10 +640,10 @@ void ArcAppListPrefs::AddAppAndShortcut(
FOR_EACH_OBSERVER(Observer, observer_list_,
OnAppReadyChanged(app_id, true));
} else {
- AppInfo app_info(name, package_name, activity, intent_uri, icon_resource_id,
- base::Time(), sticky, notifications_enabled, true,
- arc::ShouldShowInLauncher(app_id), shortcut,
- orientation_lock);
+ AppInfo app_info(
+ name, package_name, activity, intent_uri, icon_resource_id,
+ base::Time(), GetInstallTime(app_id), sticky, notifications_enabled,
+ true, arc::ShouldShowInLauncher(app_id), shortcut, orientation_lock);
FOR_EACH_OBSERVER(Observer,
observer_list_,
OnAppRegistered(app_id, app_info));
@@ -899,6 +909,22 @@ std::vector<std::string> ArcAppListPrefs::GetPackagesFromPrefs() const {
return packages;
}
+base::Time ArcAppListPrefs::GetInstallTime(const std::string& app_id) const {
+ const base::DictionaryValue* app = nullptr;
+ const base::DictionaryValue* apps = prefs_->GetDictionary(prefs::kArcApps);
+ if (!apps || !apps->GetDictionaryWithoutPathExpansion(app_id, &app))
+ return base::Time();
+
+ std::string install_time_str;
+ if (!app->GetString(kInstallTime, &install_time_str))
+ return base::Time();
+
+ int64_t install_time_i64;
+ if (!base::StringToInt64(install_time_str, &install_time_i64))
+ return base::Time();
+ return base::Time::FromInternalValue(install_time_i64);
+}
+
void ArcAppListPrefs::InstallIcon(const std::string& app_id,
ui::ScaleFactor scale_factor,
const std::vector<uint8_t>& content_png) {
@@ -928,6 +954,7 @@ ArcAppListPrefs::AppInfo::AppInfo(const std::string& name,
const std::string& intent_uri,
const std::string& icon_resource_id,
const base::Time& last_launch_time,
+ const base::Time& install_time,
bool sticky,
bool notifications_enabled,
bool ready,
@@ -940,6 +967,7 @@ ArcAppListPrefs::AppInfo::AppInfo(const std::string& name,
intent_uri(intent_uri),
icon_resource_id(icon_resource_id),
last_launch_time(last_launch_time),
+ install_time(install_time),
sticky(sticky),
notifications_enabled(notifications_enabled),
ready(ready),
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_list_prefs.h ('k') | chrome/browser/ui/app_list/search/app_result.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698