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 "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
6 | 6 |
7 #include <numeric> | 7 #include <numeric> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 | 524 |
525 void WallpaperManager::EnsureLoggedInUserWallpaperLoaded() { | 525 void WallpaperManager::EnsureLoggedInUserWallpaperLoaded() { |
526 // Some browser tests do not have a shell instance. As no wallpaper is needed | 526 // Some browser tests do not have a shell instance. As no wallpaper is needed |
527 // in these tests anyway, avoid loading one, preventing crashes and speeding | 527 // in these tests anyway, avoid loading one, preventing crashes and speeding |
528 // up the tests. | 528 // up the tests. |
529 if (!ash::Shell::HasInstance()) | 529 if (!ash::Shell::HasInstance()) |
530 return; | 530 return; |
531 | 531 |
532 WallpaperInfo info; | 532 WallpaperInfo info; |
533 if (GetLoggedInUserWallpaperInfo(&info)) { | 533 if (GetLoggedInUserWallpaperInfo(&info)) { |
534 // TODO(sschmitz): We need an index for default wallpapers for the new UI. | 534 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", info.type, |
535 RecordUma(info.type, -1); | 535 user_manager::User::WALLPAPER_TYPE_COUNT); |
536 if (info == current_user_wallpaper_info_) | 536 if (info == current_user_wallpaper_info_) |
537 return; | 537 return; |
538 } | 538 } |
539 SetUserWallpaperNow(UserManager::Get()->GetLoggedInUser()->email()); | 539 SetUserWallpaperNow(UserManager::Get()->GetLoggedInUser()->email()); |
540 } | 540 } |
541 | 541 |
542 void WallpaperManager::ClearDisposableWallpaperCache() { | 542 void WallpaperManager::ClearDisposableWallpaperCache() { |
543 // Cancel callback for previous cache requests. | 543 // Cancel callback for previous cache requests. |
544 weak_factory_.InvalidateWeakPtrs(); | 544 weak_factory_.InvalidateWeakPtrs(); |
545 // Keep the wallpaper of logged in users in cache at multi-profile mode. | 545 // Keep the wallpaper of logged in users in cache at multi-profile mode. |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 // 1x1 wallpaper is actually solid color, so it should be stretched. | 1001 // 1x1 wallpaper is actually solid color, so it should be stretched. |
1002 if (default_wallpaper_image_->image().width() == 1 && | 1002 if (default_wallpaper_image_->image().width() == 1 && |
1003 default_wallpaper_image_->image().height() == 1) | 1003 default_wallpaper_image_->image().height() == 1) |
1004 layout = ash::WALLPAPER_LAYOUT_STRETCH; | 1004 layout = ash::WALLPAPER_LAYOUT_STRETCH; |
1005 | 1005 |
1006 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( | 1006 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( |
1007 default_wallpaper_image_->image(), layout); | 1007 default_wallpaper_image_->image(), layout); |
1008 } | 1008 } |
1009 | 1009 |
1010 // static | 1010 // static |
1011 void WallpaperManager::RecordUma(user_manager::User::WallpaperType type, | |
1012 int index) { | |
1013 UMA_HISTOGRAM_ENUMERATION( | |
1014 "Ash.Wallpaper.Type", type, user_manager::User::WALLPAPER_TYPE_COUNT); | |
1015 } | |
1016 | |
1017 // static | |
1018 void WallpaperManager::SaveCustomWallpaper(const std::string& user_id_hash, | 1011 void WallpaperManager::SaveCustomWallpaper(const std::string& user_id_hash, |
1019 const base::FilePath& original_path, | 1012 const base::FilePath& original_path, |
1020 ash::WallpaperLayout layout, | 1013 ash::WallpaperLayout layout, |
1021 scoped_ptr<gfx::ImageSkia> image) { | 1014 scoped_ptr<gfx::ImageSkia> image) { |
1022 base::DeleteFile( | 1015 base::DeleteFile( |
1023 GetCustomWallpaperDir(kOriginalWallpaperSubDir).Append(user_id_hash), | 1016 GetCustomWallpaperDir(kOriginalWallpaperSubDir).Append(user_id_hash), |
1024 true /* recursive */); | 1017 true /* recursive */); |
1025 base::DeleteFile( | 1018 base::DeleteFile( |
1026 GetCustomWallpaperDir(kSmallWallpaperSubDir).Append(user_id_hash), | 1019 GetCustomWallpaperDir(kSmallWallpaperSubDir).Append(user_id_hash), |
1027 true /* recursive */); | 1020 true /* recursive */); |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1938 void WallpaperManager::CreateSolidDefaultWallpaper() { | 1931 void WallpaperManager::CreateSolidDefaultWallpaper() { |
1939 loaded_wallpapers_++; | 1932 loaded_wallpapers_++; |
1940 SkBitmap bitmap; | 1933 SkBitmap bitmap; |
1941 bitmap.allocN32Pixels(1, 1); | 1934 bitmap.allocN32Pixels(1, 1); |
1942 bitmap.eraseColor(kDefaultWallpaperColor); | 1935 bitmap.eraseColor(kDefaultWallpaperColor); |
1943 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 1936 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
1944 default_wallpaper_image_.reset(new user_manager::UserImage(image)); | 1937 default_wallpaper_image_.reset(new user_manager::UserImage(image)); |
1945 } | 1938 } |
1946 | 1939 |
1947 } // namespace chromeos | 1940 } // namespace chromeos |
OLD | NEW |