summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/login/user_manager_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/chromeos/login/user_manager_impl.cc')
-rw-r--r--chrome/browser/chromeos/login/user_manager_impl.cc39
1 files changed, 28 insertions, 11 deletions
diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc
index d74b410..c22ef19 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/user_manager_impl.cc
@@ -19,6 +19,7 @@
#include "base/path_service.h"
#include "base/rand_util.h"
#include "base/stl_util.h"
+#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/time.h"
@@ -79,6 +80,7 @@ const char kImageURLNodeName[] = "url";
const char kWallpaperTypeNodeName[] = "type";
const char kWallpaperIndexNodeName[] = "index";
+const char kWallpaperDateNodeName[] = "date";
// Default wallpaper index used in OOBE (first boot).
// Defined here because Chromium default index differs.
@@ -442,12 +444,11 @@ void UserManagerImpl::UserSelected(const std::string& email) {
if (IsKnownUser(email)) {
User::WallpaperType type;
int index;
- GetUserWallpaperProperties(email, &type, &index);
- if (type == User::RANDOM) {
- // Generate a new random wallpaper index if the selected user chose
- // RANDOM wallpaper.
- index = ash::GetRandomWallpaperIndex();
- SaveUserWallpaperProperties(email, User::RANDOM, index);
+ base::Time date;
+ GetUserWallpaperProperties(email, &type, &index, &date);
+ if (type == User::DAILY && date != base::Time::Now().LocalMidnight()) {
+ index = ash::GetNextWallpaperIndex(index);
+ SaveUserWallpaperProperties(email, User::DAILY, index);
} else if (type == User::CUSTOMIZED) {
std::string wallpaper_path =
GetWallpaperPathForUser(email, false).value();
@@ -463,6 +464,7 @@ void UserManagerImpl::UserSelected(const std::string& email) {
}
ash::Shell::GetInstance()->desktop_background_controller()->
SetDefaultWallpaper(index);
+ WallpaperManager::Get()->SetLastSelectedUser(email);
}
}
@@ -946,7 +948,8 @@ void UserManagerImpl::EnsureUsersLoaded() {
void UserManagerImpl::EnsureLoggedInUserWallpaperLoaded() {
User::WallpaperType type;
int index;
- GetLoggedInUserWallpaperProperties(&type, &index);
+ base::Time last_modification_date;
+ GetLoggedInUserWallpaperProperties(&type, &index, &last_modification_date);
if (type != current_user_wallpaper_type_ ||
index != current_user_wallpaper_index_)
@@ -1118,7 +1121,8 @@ void UserManagerImpl::MigrateWallpaperData() {
void UserManagerImpl::GetLoggedInUserWallpaperProperties(
User::WallpaperType* type,
- int* index) {
+ int* index,
+ base::Time* last_modification_date) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(logged_in_user_);
@@ -1128,7 +1132,10 @@ void UserManagerImpl::GetLoggedInUserWallpaperProperties(
return;
}
- GetUserWallpaperProperties(GetLoggedInUser().email(), type, index);
+ GetUserWallpaperProperties(GetLoggedInUser().email(),
+ type,
+ index,
+ last_modification_date);
}
void UserManagerImpl::SaveLoggedInUserWallpaperProperties(
@@ -1170,8 +1177,9 @@ void UserManagerImpl::SetUserImage(const std::string& username,
}
void UserManagerImpl::GetUserWallpaperProperties(const std::string& username,
- User::WallpaperType* type,
- int* index) {
+ User::WallpaperType* type,
+ int* index,
+ base::Time* last_modification_date) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Default to the values cached in memory.
@@ -1191,6 +1199,13 @@ void UserManagerImpl::GetUserWallpaperProperties(const std::string& username,
wallpaper_properties->GetInteger(kWallpaperTypeNodeName,
reinterpret_cast<int*>(type));
wallpaper_properties->GetInteger(kWallpaperIndexNodeName, index);
+ std::string date_string;
+ int64 val;
+ if (!(wallpaper_properties->GetString(kWallpaperDateNodeName,
+ &date_string) &&
+ base::StringToInt64(date_string, &val)))
+ val = 0;
+ *last_modification_date = base::Time::FromInternalValue(val);
}
}
}
@@ -1217,6 +1232,8 @@ void UserManagerImpl::SaveUserWallpaperProperties(const std::string& username,
new base::FundamentalValue(type));
wallpaper_properties->Set(kWallpaperIndexNodeName,
new base::FundamentalValue(index));
+ wallpaper_properties->SetString(kWallpaperDateNodeName,
+ base::Int64ToString(base::Time::Now().LocalMidnight().ToInternalValue()));
wallpaper_update->SetWithoutPathExpansion(username, wallpaper_properties);
}