Commit 56c14a16 authored by tnagel@chromium.org's avatar tnagel@chromium.org

Rename WallpaperInfo::file --> WallpaperInfo::location.

I consider "file" somewhat misleading since the field either contains a path
segment (file name plus lowermost directory) or an URL.

TBR=bshe@chromium.org
BUG=none

Review URL: https://codereview.chromium.org/443163002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288020 0039d316-1c4b-4281-b951-d872f2087c98
parent 763504a4
...@@ -273,7 +273,7 @@ bool WallpaperPrivateGetStringsFunction::RunSync() { ...@@ -273,7 +273,7 @@ bool WallpaperPrivateGetStringsFunction::RunSync() {
chromeos::WallpaperInfo info; chromeos::WallpaperInfo info;
if (wallpaper_manager->GetLoggedInUserWallpaperInfo(&info)) if (wallpaper_manager->GetLoggedInUserWallpaperInfo(&info))
dict->SetString("currentWallpaper", info.file); dict->SetString("currentWallpaper", info.location);
#if defined(GOOGLE_CHROME_BUILD) #if defined(GOOGLE_CHROME_BUILD)
dict->SetString("manifestBaseURL", kWallpaperManifestBaseURL); dict->SetString("manifestBaseURL", kWallpaperManifestBaseURL);
......
...@@ -79,7 +79,7 @@ const char kUserWallpapersProperties[] = "UserWallpapersProperties"; ...@@ -79,7 +79,7 @@ const char kUserWallpapersProperties[] = "UserWallpapersProperties";
// dictionary. // dictionary.
const char kNewWallpaperDateNodeName[] = "date"; const char kNewWallpaperDateNodeName[] = "date";
const char kNewWallpaperLayoutNodeName[] = "layout"; const char kNewWallpaperLayoutNodeName[] = "layout";
const char kNewWallpaperFileNodeName[] = "file"; const char kNewWallpaperLocationNodeName[] = "file";
const char kNewWallpaperTypeNodeName[] = "type"; const char kNewWallpaperTypeNodeName[] = "type";
// Maximum number of wallpapers cached by CacheUsersWallpapers(). // Maximum number of wallpapers cached by CacheUsersWallpapers().
...@@ -396,7 +396,7 @@ void WallpaperManager::PendingWallpaper::ProcessRequest() { ...@@ -396,7 +396,7 @@ void WallpaperManager::PendingWallpaper::ProcessRequest() {
true /* update wallpaper */, true /* update wallpaper */,
base::Passed(on_finish_.Pass()), base::Passed(on_finish_.Pass()),
manager->weak_factory_.GetWeakPtr())); manager->weak_factory_.GetWeakPtr()));
} else if (!info_.file.empty()) { } else if (!info_.location.empty()) {
manager->LoadWallpaper(user_id_, info_, true, on_finish_.Pass()); manager->LoadWallpaper(user_id_, info_, true, on_finish_.Pass());
} else { } else {
// PendingWallpaper was created and never initialized? // PendingWallpaper was created and never initialized?
...@@ -567,7 +567,7 @@ bool WallpaperManager::GetLoggedInUserWallpaperInfo(WallpaperInfo* info) { ...@@ -567,7 +567,7 @@ bool WallpaperManager::GetLoggedInUserWallpaperInfo(WallpaperInfo* info) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (UserManager::Get()->IsLoggedInAsStub()) { if (UserManager::Get()->IsLoggedInAsStub()) {
info->file = current_user_wallpaper_info_.file = ""; info->location = current_user_wallpaper_info_.location = "";
info->layout = current_user_wallpaper_info_.layout = info->layout = current_user_wallpaper_info_.layout =
ash::WALLPAPER_LAYOUT_CENTER_CROPPED; ash::WALLPAPER_LAYOUT_CENTER_CROPPED;
info->type = current_user_wallpaper_info_.type = info->type = current_user_wallpaper_info_.type =
...@@ -674,7 +674,7 @@ void WallpaperManager::RemoveUserWallpaperInfo(const std::string& user_id) { ...@@ -674,7 +674,7 @@ void WallpaperManager::RemoveUserWallpaperInfo(const std::string& user_id) {
DictionaryPrefUpdate prefs_wallpapers_info_update(prefs, DictionaryPrefUpdate prefs_wallpapers_info_update(prefs,
prefs::kUsersWallpaperInfo); prefs::kUsersWallpaperInfo);
prefs_wallpapers_info_update->RemoveWithoutPathExpansion(user_id, NULL); prefs_wallpapers_info_update->RemoveWithoutPathExpansion(user_id, NULL);
DeleteUserWallpapers(user_id, info.file); DeleteUserWallpapers(user_id, info.location);
} }
// static // static
...@@ -926,7 +926,7 @@ void WallpaperManager::SetCustomWallpaper( ...@@ -926,7 +926,7 @@ void WallpaperManager::SetCustomWallpaper(
FROM_HERE, FROM_HERE,
base::Bind(&WallpaperManager::SaveCustomWallpaper, base::Bind(&WallpaperManager::SaveCustomWallpaper,
user_id_hash, user_id_hash,
base::FilePath(wallpaper_info.file), base::FilePath(wallpaper_info.location),
wallpaper_info.layout, wallpaper_info.layout,
base::Passed(deep_copy.Pass()))); base::Passed(deep_copy.Pass())));
} }
...@@ -1098,14 +1098,14 @@ void WallpaperManager::GetCustomWallpaperInternal( ...@@ -1098,14 +1098,14 @@ void WallpaperManager::GetCustomWallpaperInternal(
// exist. This may happen when the original custom wallpaper is small or // exist. This may happen when the original custom wallpaper is small or
// browser shutdown before resized wallpaper saved. // browser shutdown before resized wallpaper saved.
valid_path = GetCustomWallpaperDir(kOriginalWallpaperSubDir); valid_path = GetCustomWallpaperDir(kOriginalWallpaperSubDir);
valid_path = valid_path.Append(info.file); valid_path = valid_path.Append(info.location);
} }
if (!base::PathExists(valid_path)) { if (!base::PathExists(valid_path)) {
// Falls back to custom wallpaper that uses email as part of its file path. // Falls back to custom wallpaper that uses email as part of its file path.
// Note that email is used instead of user_id_hash here. // Note that email is used instead of user_id_hash here.
valid_path = valid_path = GetCustomWallpaperPath(kOriginalWallpaperSubDir,
GetCustomWallpaperPath(kOriginalWallpaperSubDir, user_id, info.file); user_id, info.location);
} }
if (!base::PathExists(valid_path)) { if (!base::PathExists(valid_path)) {
...@@ -1132,7 +1132,7 @@ void WallpaperManager::GetCustomWallpaperInternal( ...@@ -1132,7 +1132,7 @@ void WallpaperManager::GetCustomWallpaperInternal(
void WallpaperManager::InitInitialUserWallpaper(const std::string& user_id, void WallpaperManager::InitInitialUserWallpaper(const std::string& user_id,
bool is_persistent) { bool is_persistent) {
current_user_wallpaper_info_.file = ""; current_user_wallpaper_info_.location = "";
current_user_wallpaper_info_.layout = ash::WALLPAPER_LAYOUT_CENTER_CROPPED; current_user_wallpaper_info_.layout = ash::WALLPAPER_LAYOUT_CENTER_CROPPED;
current_user_wallpaper_info_.type = user_manager::User::DEFAULT; current_user_wallpaper_info_.type = user_manager::User::DEFAULT;
current_user_wallpaper_info_.date = base::Time::Now().LocalMidnight(); current_user_wallpaper_info_.date = base::Time::Now().LocalMidnight();
...@@ -1156,7 +1156,7 @@ void WallpaperManager::SetUserWallpaperInfo(const std::string& user_id, ...@@ -1156,7 +1156,7 @@ void WallpaperManager::SetUserWallpaperInfo(const std::string& user_id,
base::DictionaryValue* wallpaper_info_dict = new base::DictionaryValue(); base::DictionaryValue* wallpaper_info_dict = new base::DictionaryValue();
wallpaper_info_dict->SetString(kNewWallpaperDateNodeName, wallpaper_info_dict->SetString(kNewWallpaperDateNodeName,
base::Int64ToString(info.date.ToInternalValue())); base::Int64ToString(info.date.ToInternalValue()));
wallpaper_info_dict->SetString(kNewWallpaperFileNodeName, info.file); wallpaper_info_dict->SetString(kNewWallpaperLocationNodeName, info.location);
wallpaper_info_dict->SetInteger(kNewWallpaperLayoutNodeName, info.layout); wallpaper_info_dict->SetInteger(kNewWallpaperLayoutNodeName, info.layout);
wallpaper_info_dict->SetInteger(kNewWallpaperTypeNodeName, info.type); wallpaper_info_dict->SetInteger(kNewWallpaperTypeNodeName, info.type);
wallpaper_update->SetWithoutPathExpansion(user_id, wallpaper_info_dict); wallpaper_update->SetWithoutPathExpansion(user_id, wallpaper_info_dict);
...@@ -1206,7 +1206,7 @@ void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id, ...@@ -1206,7 +1206,7 @@ void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id,
GetPendingWallpaper(user_id, delayed) GetPendingWallpaper(user_id, delayed)
->ResetSetWallpaperImage(user_wallpaper, info); ->ResetSetWallpaperImage(user_wallpaper, info);
} else { } else {
if (info.file.empty()) { if (info.location.empty()) {
// Uses default built-in wallpaper when file is empty. Eventually, we // Uses default built-in wallpaper when file is empty. Eventually, we
// will only ship one built-in wallpaper in ChromeOS image. // will only ship one built-in wallpaper in ChromeOS image.
GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper();
...@@ -1222,7 +1222,7 @@ void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id, ...@@ -1222,7 +1222,7 @@ void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id,
if (info.layout == ash::WALLPAPER_LAYOUT_CENTER) if (info.layout == ash::WALLPAPER_LAYOUT_CENTER)
sub_dir = kOriginalWallpaperSubDir; sub_dir = kOriginalWallpaperSubDir;
base::FilePath wallpaper_path = GetCustomWallpaperDir(sub_dir); base::FilePath wallpaper_path = GetCustomWallpaperDir(sub_dir);
wallpaper_path = wallpaper_path.Append(info.file); wallpaper_path = wallpaper_path.Append(info.location);
if (current_wallpaper_path_ == wallpaper_path) if (current_wallpaper_path_ == wallpaper_path)
return; return;
current_wallpaper_path_ = wallpaper_path; current_wallpaper_path_ = wallpaper_path;
...@@ -1321,7 +1321,7 @@ void WallpaperManager::CacheUserWallpaper(const std::string& user_id) { ...@@ -1321,7 +1321,7 @@ void WallpaperManager::CacheUserWallpaper(const std::string& user_id) {
return; return;
WallpaperInfo info; WallpaperInfo info;
if (GetUserWallpaperInfo(user_id, &info)) { if (GetUserWallpaperInfo(user_id, &info)) {
if (info.file.empty()) if (info.location.empty())
return; return;
base::FilePath wallpaper_dir; base::FilePath wallpaper_dir;
...@@ -1330,7 +1330,7 @@ void WallpaperManager::CacheUserWallpaper(const std::string& user_id) { ...@@ -1330,7 +1330,7 @@ void WallpaperManager::CacheUserWallpaper(const std::string& user_id) {
info.type == user_manager::User::POLICY) { info.type == user_manager::User::POLICY) {
const char* sub_dir = GetCustomWallpaperSubdirForCurrentResolution(); const char* sub_dir = GetCustomWallpaperSubdirForCurrentResolution();
base::FilePath wallpaper_path = GetCustomWallpaperDir(sub_dir); base::FilePath wallpaper_path = GetCustomWallpaperDir(sub_dir);
wallpaper_path = wallpaper_path.Append(info.file); wallpaper_path = wallpaper_path.Append(info.location);
task_runner_->PostTask( task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&WallpaperManager::GetCustomWallpaperInternal, base::Bind(&WallpaperManager::GetCustomWallpaperInternal,
...@@ -1443,7 +1443,7 @@ void WallpaperManager::LoadWallpaper(const std::string& user_id, ...@@ -1443,7 +1443,7 @@ void WallpaperManager::LoadWallpaper(const std::string& user_id,
// Do a sanity check that file path information is not empty. // Do a sanity check that file path information is not empty.
if (info.type == user_manager::User::ONLINE || if (info.type == user_manager::User::ONLINE ||
info.type == user_manager::User::DEFAULT) { info.type == user_manager::User::DEFAULT) {
if (info.file.empty()) { if (info.location.empty()) {
if (base::SysInfo::IsRunningOnChromeOS()) { if (base::SysInfo::IsRunningOnChromeOS()) {
NOTREACHED() << "User wallpaper info appears to be broken: " << user_id; NOTREACHED() << "User wallpaper info appears to be broken: " << user_id;
} else { } else {
...@@ -1459,7 +1459,7 @@ void WallpaperManager::LoadWallpaper(const std::string& user_id, ...@@ -1459,7 +1459,7 @@ void WallpaperManager::LoadWallpaper(const std::string& user_id,
} }
if (info.type == user_manager::User::ONLINE) { if (info.type == user_manager::User::ONLINE) {
std::string file_name = GURL(info.file).ExtractFileName(); std::string file_name = GURL(info.location).ExtractFileName();
WallpaperResolution resolution = GetAppropriateResolution(); WallpaperResolution resolution = GetAppropriateResolution();
// Only solid color wallpapers have stretch layout and they have only one // Only solid color wallpapers have stretch layout and they have only one
// resolution. // resolution.
...@@ -1486,7 +1486,7 @@ void WallpaperManager::LoadWallpaper(const std::string& user_id, ...@@ -1486,7 +1486,7 @@ void WallpaperManager::LoadWallpaper(const std::string& user_id,
// M26 from M21. See crosbug.com/38429 for details. // M26 from M21. See crosbug.com/38429 for details.
base::FilePath user_data_dir; base::FilePath user_data_dir;
PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
wallpaper_path = user_data_dir.Append(info.file); wallpaper_path = user_data_dir.Append(info.location);
StartLoad( StartLoad(
user_id, info, update_wallpaper, wallpaper_path, on_finish.Pass()); user_id, info, update_wallpaper, wallpaper_path, on_finish.Pass());
} else { } else {
...@@ -1518,8 +1518,8 @@ bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, ...@@ -1518,8 +1518,8 @@ bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id,
} }
// Use temporary variables to keep |info| untouched in the error case. // Use temporary variables to keep |info| untouched in the error case.
std::string file; std::string location;
if (!info_dict->GetString(kNewWallpaperFileNodeName, &file)) if (!info_dict->GetString(kNewWallpaperLocationNodeName, &location))
return false; return false;
int layout; int layout;
if (!info_dict->GetInteger(kNewWallpaperLayoutNodeName, &layout)) if (!info_dict->GetInteger(kNewWallpaperLayoutNodeName, &layout))
...@@ -1534,7 +1534,7 @@ bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, ...@@ -1534,7 +1534,7 @@ bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id,
if (!base::StringToInt64(date_string, &date_val)) if (!base::StringToInt64(date_string, &date_val))
return false; return false;
info->file = file; info->location = location;
info->layout = static_cast<ash::WallpaperLayout>(layout); info->layout = static_cast<ash::WallpaperLayout>(layout);
info->type = static_cast<user_manager::User::WallpaperType>(type); info->type = static_cast<user_manager::User::WallpaperType>(type);
info->date = base::Time::FromInternalValue(date_val); info->date = base::Time::FromInternalValue(date_val);
...@@ -1549,9 +1549,7 @@ void WallpaperManager::MoveCustomWallpapersSuccess( ...@@ -1549,9 +1549,7 @@ void WallpaperManager::MoveCustomWallpapersSuccess(
if (info.type == user_manager::User::CUSTOMIZED) { if (info.type == user_manager::User::CUSTOMIZED) {
// New file field should include user id hash in addition to file name. // New file field should include user id hash in addition to file name.
// This is needed because at login screen, user id hash is not available. // This is needed because at login screen, user id hash is not available.
std::string relative_path = info.location = base::FilePath(user_id_hash).Append(info.location).value();
base::FilePath(user_id_hash).Append(info.file).value();
info.file = relative_path;
bool is_persistent = bool is_persistent =
!UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id); !UserManager::Get()->IsUserNonCryptohomeDataEphemeral(user_id);
SetUserWallpaperInfo(user_id, info, is_persistent); SetUserWallpaperInfo(user_id, info, is_persistent);
......
...@@ -41,13 +41,14 @@ class UserImage; ...@@ -41,13 +41,14 @@ class UserImage;
namespace chromeos { namespace chromeos {
struct WallpaperInfo { struct WallpaperInfo {
// Online wallpaper URL or file name of migrated wallpaper. // Either file name of migrated wallpaper including first directory level
std::string file; // (corresponding to user id hash) or online wallpaper URL.
std::string location;
ash::WallpaperLayout layout; ash::WallpaperLayout layout;
user_manager::User::WallpaperType type; user_manager::User::WallpaperType type;
base::Time date; base::Time date;
bool operator==(const WallpaperInfo& other) { bool operator==(const WallpaperInfo& other) {
return (file == other.file) && (layout == other.layout) && return (location == other.location) && (layout == other.layout) &&
(type == other.type); (type == other.type);
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment