OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 } | 386 } |
387 | 387 |
388 void WallpaperManager::ResizeAndSaveWallpaper(const UserImage& wallpaper, | 388 void WallpaperManager::ResizeAndSaveWallpaper(const UserImage& wallpaper, |
389 const base::FilePath& path, | 389 const base::FilePath& path, |
390 ash::WallpaperLayout layout, | 390 ash::WallpaperLayout layout, |
391 int preferred_width, | 391 int preferred_width, |
392 int preferred_height) { | 392 int preferred_height) { |
393 if (layout == ash::WALLPAPER_LAYOUT_CENTER) { | 393 if (layout == ash::WALLPAPER_LAYOUT_CENTER) { |
394 // TODO(bshe): Generates cropped custom wallpaper for CENTER layout. | 394 // TODO(bshe): Generates cropped custom wallpaper for CENTER layout. |
395 if (file_util::PathExists(path)) | 395 if (file_util::PathExists(path)) |
396 file_util::Delete(path, false); | 396 base::Delete(path, false); |
397 return; | 397 return; |
398 } | 398 } |
399 scoped_refptr<base::RefCountedBytes> data; | 399 scoped_refptr<base::RefCountedBytes> data; |
400 if (ResizeWallpaper(wallpaper, layout, preferred_width, preferred_height, | 400 if (ResizeWallpaper(wallpaper, layout, preferred_width, preferred_height, |
401 &data)) { | 401 &data)) { |
402 SaveWallpaperInternal(path, | 402 SaveWallpaperInternal(path, |
403 reinterpret_cast<const char*>(data->front()), | 403 reinterpret_cast<const char*>(data->front()), |
404 data->size()); | 404 data->size()); |
405 } | 405 } |
406 } | 406 } |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 wallpapers_pref->Clear(); | 668 wallpapers_pref->Clear(); |
669 } | 669 } |
670 | 670 |
671 void WallpaperManager::DeleteAllExcept(const base::FilePath& path) { | 671 void WallpaperManager::DeleteAllExcept(const base::FilePath& path) { |
672 base::FilePath dir = path.DirName(); | 672 base::FilePath dir = path.DirName(); |
673 if (file_util::DirectoryExists(dir)) { | 673 if (file_util::DirectoryExists(dir)) { |
674 base::FileEnumerator files(dir, false, base::FileEnumerator::FILES); | 674 base::FileEnumerator files(dir, false, base::FileEnumerator::FILES); |
675 for (base::FilePath current = files.Next(); !current.empty(); | 675 for (base::FilePath current = files.Next(); !current.empty(); |
676 current = files.Next()) { | 676 current = files.Next()) { |
677 if (current != path) | 677 if (current != path) |
678 file_util::Delete(current, false); | 678 base::Delete(current, false); |
679 } | 679 } |
680 } | 680 } |
681 } | 681 } |
682 | 682 |
683 void WallpaperManager::DeleteWallpaperInList( | 683 void WallpaperManager::DeleteWallpaperInList( |
684 const std::vector<base::FilePath>& file_list) { | 684 const std::vector<base::FilePath>& file_list) { |
685 for (std::vector<base::FilePath>::const_iterator it = file_list.begin(); | 685 for (std::vector<base::FilePath>::const_iterator it = file_list.begin(); |
686 it != file_list.end(); ++it) { | 686 it != file_list.end(); ++it) { |
687 base::FilePath path = *it; | 687 base::FilePath path = *it; |
688 // Some users may still have legacy wallpapers with png extension. We need | 688 // Some users may still have legacy wallpapers with png extension. We need |
689 // to delete these wallpapers too. | 689 // to delete these wallpapers too. |
690 if (!file_util::Delete(path, true) && | 690 if (!base::Delete(path, true) && |
691 !file_util::Delete(path.AddExtension(".png"), false)) { | 691 !base::Delete(path.AddExtension(".png"), false)) { |
692 LOG(ERROR) << "Failed to remove user wallpaper at " << path.value(); | 692 LOG(ERROR) << "Failed to remove user wallpaper at " << path.value(); |
693 } | 693 } |
694 } | 694 } |
695 } | 695 } |
696 | 696 |
697 void WallpaperManager::DeleteUserWallpapers(const std::string& email) { | 697 void WallpaperManager::DeleteUserWallpapers(const std::string& email) { |
698 std::vector<base::FilePath> file_to_remove; | 698 std::vector<base::FilePath> file_to_remove; |
699 // Remove small user wallpaper. | 699 // Remove small user wallpaper. |
700 base::FilePath wallpaper_path = GetWallpaperPathForUser(email, true); | 700 base::FilePath wallpaper_path = GetWallpaperPathForUser(email, true); |
701 file_to_remove.push_back(wallpaper_path); | 701 file_to_remove.push_back(wallpaper_path); |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 | 1095 |
1096 void WallpaperManager::SystemResumed(const base::TimeDelta& sleep_duration) { | 1096 void WallpaperManager::SystemResumed(const base::TimeDelta& sleep_duration) { |
1097 BatchUpdateWallpaper(); | 1097 BatchUpdateWallpaper(); |
1098 } | 1098 } |
1099 | 1099 |
1100 void WallpaperManager::TimezoneChanged(const icu::TimeZone& timezone) { | 1100 void WallpaperManager::TimezoneChanged(const icu::TimeZone& timezone) { |
1101 RestartTimer(); | 1101 RestartTimer(); |
1102 } | 1102 } |
1103 | 1103 |
1104 } // namespace chromeos | 1104 } // namespace chromeos |
OLD | NEW |