| Index: trunk/src/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
|
| ===================================================================
|
| --- trunk/src/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc (revision 277819)
|
| +++ trunk/src/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc (working copy)
|
| @@ -173,7 +173,6 @@
|
| }
|
|
|
| // Creates all new custom wallpaper directories for |user_id_hash| if not exist.
|
| -// static
|
| void EnsureCustomWallpaperDirectories(const std::string& user_id_hash) {
|
| base::FilePath dir;
|
| dir = GetCustomWallpaperDir(kSmallWallpaperSubDir);
|
| @@ -527,7 +526,7 @@
|
| CrosSettings::Get()->AddSettingsObserver(
|
| kAccountsPrefShowUserNamesOnSignIn,
|
| base::Bind(&WallpaperManager::InitializeRegisteredDeviceWallpaper,
|
| - weak_factory_.GetWeakPtr()));
|
| + base::Unretained(this)));
|
| }
|
|
|
| void WallpaperManager::EnsureLoggedInUserWallpaperLoaded() {
|
| @@ -570,6 +569,14 @@
|
| wallpaper_cache_ = logged_in_users_cache;
|
| }
|
|
|
| +base::FilePath WallpaperManager::GetCustomWallpaperPath(
|
| + const char* sub_dir,
|
| + const std::string& user_id_hash,
|
| + const std::string& file) const {
|
| + base::FilePath custom_wallpaper_path = GetCustomWallpaperDir(sub_dir);
|
| + return custom_wallpaper_path.Append(user_id_hash).Append(file);
|
| +}
|
| +
|
| bool WallpaperManager::GetLoggedInUserWallpaperInfo(WallpaperInfo* info) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -821,60 +828,6 @@
|
| : WALLPAPER_RESOLUTION_SMALL;
|
| }
|
|
|
| -// static
|
| -base::FilePath WallpaperManager::GetCustomWallpaperPath(
|
| - const char* sub_dir,
|
| - const std::string& user_id_hash,
|
| - const std::string& file) {
|
| - base::FilePath custom_wallpaper_path = GetCustomWallpaperDir(sub_dir);
|
| - return custom_wallpaper_path.Append(user_id_hash).Append(file);
|
| -}
|
| -
|
| -// static
|
| -void WallpaperManager::RecordUma(User::WallpaperType type, int index) {
|
| - UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", type,
|
| - User::WALLPAPER_TYPE_COUNT);
|
| -}
|
| -
|
| -// static
|
| -void WallpaperManager::SaveCustomWallpaper(const std::string& user_id_hash,
|
| - const base::FilePath& original_path,
|
| - ash::WallpaperLayout layout,
|
| - scoped_ptr<gfx::ImageSkia> image) {
|
| - EnsureCustomWallpaperDirectories(user_id_hash);
|
| - std::string file_name = original_path.BaseName().value();
|
| - base::FilePath small_wallpaper_path =
|
| - GetCustomWallpaperPath(kSmallWallpaperSubDir, user_id_hash, file_name);
|
| - base::FilePath large_wallpaper_path =
|
| - GetCustomWallpaperPath(kLargeWallpaperSubDir, user_id_hash, file_name);
|
| -
|
| - // Re-encode orginal file to jpeg format and saves the result in case that
|
| - // resized wallpaper is not generated (i.e. chrome shutdown before resized
|
| - // wallpaper is saved).
|
| - ResizeAndSaveWallpaper(*image,
|
| - original_path,
|
| - ash::WALLPAPER_LAYOUT_STRETCH,
|
| - image->width(),
|
| - image->height(),
|
| - NULL);
|
| - DeleteAllExcept(original_path);
|
| -
|
| - ResizeAndSaveWallpaper(*image,
|
| - small_wallpaper_path,
|
| - layout,
|
| - kSmallWallpaperMaxWidth,
|
| - kSmallWallpaperMaxHeight,
|
| - NULL);
|
| - DeleteAllExcept(small_wallpaper_path);
|
| - ResizeAndSaveWallpaper(*image,
|
| - large_wallpaper_path,
|
| - layout,
|
| - kLargeWallpaperMaxWidth,
|
| - kLargeWallpaperMaxHeight,
|
| - NULL);
|
| - DeleteAllExcept(large_wallpaper_path);
|
| -}
|
| -
|
| void WallpaperManager::SetPolicyControlledWallpaper(
|
| const std::string& user_id,
|
| const UserImage& user_image) {
|
| @@ -943,6 +896,7 @@
|
| blocking_task_runner->PostTask(
|
| FROM_HERE,
|
| base::Bind(&WallpaperManager::SaveCustomWallpaper,
|
| + base::Unretained(this),
|
| user_id_hash,
|
| base::FilePath(wallpaper_info.file),
|
| wallpaper_info.layout,
|
| @@ -1227,7 +1181,7 @@
|
| task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&WallpaperManager::GetCustomWallpaperInternal,
|
| - weak_factory_.GetWeakPtr(),
|
| + base::Unretained(this),
|
| user_id,
|
| info,
|
| wallpaper_path,
|
| @@ -1447,7 +1401,7 @@
|
| BrowserThread::UI,
|
| FROM_HERE,
|
| base::Bind(&WallpaperManager::MoveCustomWallpapersSuccess,
|
| - weak_factory_.GetWeakPtr(),
|
| + base::Unretained(this),
|
| user_id,
|
| user_id_hash));
|
| }
|
| @@ -1479,7 +1433,7 @@
|
| task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&WallpaperManager::MoveCustomWallpapersOnWorker,
|
| - weak_factory_.GetWeakPtr(),
|
| + base::Unretained(this),
|
| logged_in_user->email(),
|
| logged_in_user->username_hash()));
|
| }
|
| @@ -1515,14 +1469,14 @@
|
| BrowserThread::PostTask(BrowserThread::UI,
|
| FROM_HERE,
|
| base::Bind(&WallpaperManager::DoSetDefaultWallpaper,
|
| - weak_factory_.GetWeakPtr(),
|
| + base::Unretained(this),
|
| user_id,
|
| base::Passed(on_finish.Pass())));
|
| } else {
|
| BrowserThread::PostTask(BrowserThread::UI,
|
| FROM_HERE,
|
| base::Bind(&WallpaperManager::StartLoad,
|
| - weak_factory_.GetWeakPtr(),
|
| + base::Unretained(this),
|
| user_id,
|
| info,
|
| update_wallpaper,
|
| @@ -1566,6 +1520,52 @@
|
| }
|
| }
|
|
|
| +void WallpaperManager::SaveCustomWallpaper(
|
| + const std::string& user_id_hash,
|
| + const base::FilePath& original_path,
|
| + ash::WallpaperLayout layout,
|
| + scoped_ptr<gfx::ImageSkia> image) const {
|
| + DCHECK(BrowserThread::GetBlockingPool()->
|
| + IsRunningSequenceOnCurrentThread(sequence_token_));
|
| + EnsureCustomWallpaperDirectories(user_id_hash);
|
| + std::string file_name = original_path.BaseName().value();
|
| + base::FilePath small_wallpaper_path =
|
| + GetCustomWallpaperPath(kSmallWallpaperSubDir, user_id_hash, file_name);
|
| + base::FilePath large_wallpaper_path =
|
| + GetCustomWallpaperPath(kLargeWallpaperSubDir, user_id_hash, file_name);
|
| +
|
| + // Re-encode orginal file to jpeg format and saves the result in case that
|
| + // resized wallpaper is not generated (i.e. chrome shutdown before resized
|
| + // wallpaper is saved).
|
| + ResizeAndSaveWallpaper(*image,
|
| + original_path,
|
| + ash::WALLPAPER_LAYOUT_STRETCH,
|
| + image->width(),
|
| + image->height(),
|
| + NULL);
|
| + DeleteAllExcept(original_path);
|
| +
|
| + ResizeAndSaveWallpaper(*image,
|
| + small_wallpaper_path,
|
| + layout,
|
| + kSmallWallpaperMaxWidth,
|
| + kSmallWallpaperMaxHeight,
|
| + NULL);
|
| + DeleteAllExcept(small_wallpaper_path);
|
| + ResizeAndSaveWallpaper(*image,
|
| + large_wallpaper_path,
|
| + layout,
|
| + kLargeWallpaperMaxWidth,
|
| + kLargeWallpaperMaxHeight,
|
| + NULL);
|
| + DeleteAllExcept(large_wallpaper_path);
|
| +}
|
| +
|
| +void WallpaperManager::RecordUma(User::WallpaperType type, int index) const {
|
| + UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", type,
|
| + User::WALLPAPER_TYPE_COUNT);
|
| +}
|
| +
|
| void WallpaperManager::StartLoad(const std::string& user_id,
|
| const WallpaperInfo& info,
|
| bool update_wallpaper,
|
|
|