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/logging.h" | 13 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/prefs/pref_registry_simple.h" | 16 #include "base/prefs/pref_registry_simple.h" |
17 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
18 #include "base/prefs/scoped_user_pref_update.h" | 18 #include "base/prefs/scoped_user_pref_update.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
22 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
23 #include "base/threading/worker_pool.h" | 23 #include "base/threading/worker_pool.h" |
24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
25 #include "base/values.h" | 25 #include "base/values.h" |
26 #include "chromeos/chromeos_switches.h" | 26 #include "chromeos/chromeos_switches.h" |
27 #include "chromeos/cryptohome/async_method_caller.h" | 27 #include "chromeos/cryptohome/async_method_caller.h" |
28 #include "chromeos/dbus/dbus_thread_manager.h" | 28 #include "chromeos/dbus/dbus_thread_manager.h" |
29 #include "chromeos/login/user_names.h" | 29 #include "chromeos/login/user_names.h" |
| 30 #include "components/signin/core/account_id/account_id.h" |
30 #include "components/user_manager/user.h" | 31 #include "components/user_manager/user.h" |
31 #include "components/user_manager/user_image/user_image.h" | 32 #include "components/user_manager/user_image/user_image.h" |
32 #include "components/user_manager/user_manager.h" | 33 #include "components/user_manager/user_manager.h" |
33 #include "components/user_manager/user_type.h" | 34 #include "components/user_manager/user_type.h" |
34 #include "components/wallpaper/wallpaper_layout.h" | 35 #include "components/wallpaper/wallpaper_layout.h" |
35 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
36 #include "third_party/skia/include/core/SkColor.h" | 37 #include "third_party/skia/include/core/SkColor.h" |
37 #include "ui/gfx/codec/jpeg_codec.h" | 38 #include "ui/gfx/codec/jpeg_codec.h" |
38 #include "ui/gfx/geometry/safe_integer_conversions.h" | 39 #include "ui/gfx/geometry/safe_integer_conversions.h" |
39 #include "ui/gfx/image/image_skia_operations.h" | 40 #include "ui/gfx/image/image_skia_operations.h" |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 | 494 |
494 WallpaperManagerBase::~WallpaperManagerBase() { | 495 WallpaperManagerBase::~WallpaperManagerBase() { |
495 // TODO(bshe): Lifetime of WallpaperManagerBase needs more consideration. | 496 // TODO(bshe): Lifetime of WallpaperManagerBase needs more consideration. |
496 // http://crbug.com/171694 | 497 // http://crbug.com/171694 |
497 weak_factory_.InvalidateWeakPtrs(); | 498 weak_factory_.InvalidateWeakPtrs(); |
498 } | 499 } |
499 | 500 |
500 void WallpaperManagerBase::SetPolicyControlledWallpaper( | 501 void WallpaperManagerBase::SetPolicyControlledWallpaper( |
501 const std::string& user_id, | 502 const std::string& user_id, |
502 const user_manager::UserImage& user_image) { | 503 const user_manager::UserImage& user_image) { |
503 const user_manager::User* user = | 504 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
504 user_manager::UserManager::Get()->FindUser(user_id); | 505 AccountId::FromUserEmail(user_id)); |
505 if (!user) { | 506 if (!user) { |
506 NOTREACHED() << "Unknown user."; | 507 NOTREACHED() << "Unknown user."; |
507 return; | 508 return; |
508 } | 509 } |
509 | 510 |
510 if (user->username_hash().empty()) { | 511 if (user->username_hash().empty()) { |
511 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( | 512 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( |
512 user_id, | 513 user_id, |
513 base::Bind(&WallpaperManagerBase::SetCustomWallpaperOnSanitizedUsername, | 514 base::Bind(&WallpaperManagerBase::SetCustomWallpaperOnSanitizedUsername, |
514 weak_factory_.GetWeakPtr(), user_id, user_image.image(), | 515 weak_factory_.GetWeakPtr(), user_id, user_image.image(), |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 const std::string& user_id, | 879 const std::string& user_id, |
879 const std::string& user_id_hash) { | 880 const std::string& user_id_hash) { |
880 WallpaperInfo info; | 881 WallpaperInfo info; |
881 GetUserWallpaperInfo(user_id, &info); | 882 GetUserWallpaperInfo(user_id, &info); |
882 if (info.type == user_manager::User::CUSTOMIZED) { | 883 if (info.type == user_manager::User::CUSTOMIZED) { |
883 // New file field should include user id hash in addition to file name. | 884 // New file field should include user id hash in addition to file name. |
884 // This is needed because at login screen, user id hash is not available. | 885 // This is needed because at login screen, user id hash is not available. |
885 info.location = base::FilePath(user_id_hash).Append(info.location).value(); | 886 info.location = base::FilePath(user_id_hash).Append(info.location).value(); |
886 bool is_persistent = | 887 bool is_persistent = |
887 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 888 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
888 user_id); | 889 AccountId::FromUserEmail(user_id)); |
889 SetUserWallpaperInfo(user_id, info, is_persistent); | 890 SetUserWallpaperInfo(user_id, info, is_persistent); |
890 } | 891 } |
891 } | 892 } |
892 | 893 |
893 void WallpaperManagerBase::MoveLoggedInUserCustomWallpaper() { | 894 void WallpaperManagerBase::MoveLoggedInUserCustomWallpaper() { |
894 const user_manager::User* logged_in_user = | 895 const user_manager::User* logged_in_user = |
895 user_manager::UserManager::Get()->GetLoggedInUser(); | 896 user_manager::UserManager::Get()->GetLoggedInUser(); |
896 if (logged_in_user) { | 897 if (logged_in_user) { |
897 task_runner_->PostTask( | 898 task_runner_->PostTask( |
898 FROM_HERE, | 899 FROM_HERE, |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { | 1056 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { |
1056 loaded_wallpapers_for_test_++; | 1057 loaded_wallpapers_for_test_++; |
1057 SkBitmap bitmap; | 1058 SkBitmap bitmap; |
1058 bitmap.allocN32Pixels(1, 1); | 1059 bitmap.allocN32Pixels(1, 1); |
1059 bitmap.eraseColor(kDefaultWallpaperColor); | 1060 bitmap.eraseColor(kDefaultWallpaperColor); |
1060 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 1061 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
1061 default_wallpaper_image_.reset(new user_manager::UserImage(image)); | 1062 default_wallpaper_image_.reset(new user_manager::UserImage(image)); |
1062 } | 1063 } |
1063 | 1064 |
1064 } // namespace wallpaper | 1065 } // namespace wallpaper |
OLD | NEW |