| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/wallpaper/wallpaper_manager_base.h" | 5 #include "components/wallpaper/wallpaper_manager_base.h" |
| 6 | 6 |
| 7 #include <numeric> | 7 #include <numeric> |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 20 #include "base/sys_info.h" | 20 #include "base/sys_info.h" |
| 21 #include "base/threading/worker_pool.h" | 21 #include "base/task_scheduler/post_task.h" |
| 22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 23 #include "base/values.h" | 23 #include "base/values.h" |
| 24 #include "components/prefs/pref_registry_simple.h" | 24 #include "components/prefs/pref_registry_simple.h" |
| 25 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
| 26 #include "components/prefs/scoped_user_pref_update.h" | 26 #include "components/prefs/scoped_user_pref_update.h" |
| 27 #include "components/signin/core/account_id/account_id.h" | 27 #include "components/signin/core/account_id/account_id.h" |
| 28 #include "components/user_manager/user.h" | 28 #include "components/user_manager/user.h" |
| 29 #include "components/user_manager/user_image/user_image.h" | 29 #include "components/user_manager/user_image/user_image.h" |
| 30 #include "components/user_manager/user_manager.h" | 30 #include "components/user_manager/user_manager.h" |
| 31 #include "components/user_manager/user_type.h" | 31 #include "components/user_manager/user_type.h" |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 file_to_remove.push_back(wallpaper_path.Append(account_id.GetUserEmail())); | 773 file_to_remove.push_back(wallpaper_path.Append(account_id.GetUserEmail())); |
| 774 wallpaper_path = wallpaper_path.Append(path_to_file); | 774 wallpaper_path = wallpaper_path.Append(path_to_file); |
| 775 file_to_remove.push_back(wallpaper_path); | 775 file_to_remove.push_back(wallpaper_path); |
| 776 | 776 |
| 777 // Remove original user wallpaper. | 777 // Remove original user wallpaper. |
| 778 wallpaper_path = GetCustomWallpaperDir(kOriginalWallpaperSubDir); | 778 wallpaper_path = GetCustomWallpaperDir(kOriginalWallpaperSubDir); |
| 779 file_to_remove.push_back(wallpaper_path.Append(account_id.GetUserEmail())); | 779 file_to_remove.push_back(wallpaper_path.Append(account_id.GetUserEmail())); |
| 780 wallpaper_path = wallpaper_path.Append(path_to_file); | 780 wallpaper_path = wallpaper_path.Append(path_to_file); |
| 781 file_to_remove.push_back(wallpaper_path); | 781 file_to_remove.push_back(wallpaper_path); |
| 782 | 782 |
| 783 base::WorkerPool::PostTask( | 783 base::PostTaskWithTraits( |
| 784 FROM_HERE, base::Bind(&DeleteWallpaperInList, file_to_remove), false); | 784 FROM_HERE, base::TaskTraits() |
| 785 .WithShutdownBehavior( |
| 786 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) |
| 787 .WithPriority(base::TaskPriority::BACKGROUND) |
| 788 .MayBlock(), |
| 789 base::Bind(&DeleteWallpaperInList, file_to_remove)); |
| 785 } | 790 } |
| 786 | 791 |
| 787 void WallpaperManagerBase::SetCommandLineForTesting( | 792 void WallpaperManagerBase::SetCommandLineForTesting( |
| 788 base::CommandLine* command_line) { | 793 base::CommandLine* command_line) { |
| 789 command_line_for_testing_ = command_line; | 794 command_line_for_testing_ = command_line; |
| 790 SetDefaultWallpaperPathsFromCommandLine(command_line); | 795 SetDefaultWallpaperPathsFromCommandLine(command_line); |
| 791 } | 796 } |
| 792 | 797 |
| 793 base::CommandLine* WallpaperManagerBase::GetCommandLine() { | 798 base::CommandLine* WallpaperManagerBase::GetCommandLine() { |
| 794 base::CommandLine* command_line = | 799 base::CommandLine* command_line = |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { | 1045 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { |
| 1041 loaded_wallpapers_for_test_++; | 1046 loaded_wallpapers_for_test_++; |
| 1042 SkBitmap bitmap; | 1047 SkBitmap bitmap; |
| 1043 bitmap.allocN32Pixels(1, 1); | 1048 bitmap.allocN32Pixels(1, 1); |
| 1044 bitmap.eraseColor(kDefaultWallpaperColor); | 1049 bitmap.eraseColor(kDefaultWallpaperColor); |
| 1045 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 1050 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
| 1046 default_wallpaper_image_.reset(new user_manager::UserImage(image)); | 1051 default_wallpaper_image_.reset(new user_manager::UserImage(image)); |
| 1047 } | 1052 } |
| 1048 | 1053 |
| 1049 } // namespace wallpaper | 1054 } // namespace wallpaper |
| OLD | NEW |