| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/ash_constants.h" | 9 #include "ash/common/ash_constants.h" |
| 10 #include "ash/common/wallpaper/wallpaper_controller.h" | 10 #include "ash/common/wallpaper/wallpaper_controller.h" |
| 11 #include "ash/common/wm_shell.h" | |
| 12 #include "ash/public/interfaces/constants.mojom.h" | 11 #include "ash/public/interfaces/constants.mojom.h" |
| 12 #include "ash/shell.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
| 19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 20 #include "base/sha1.h" | 20 #include "base/sha1.h" |
| 21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 service_manager::Connector* connector = | 203 service_manager::Connector* connector = |
| 204 content::ServiceManagerConnection::GetForProcess()->GetConnector(); | 204 content::ServiceManagerConnection::GetForProcess()->GetConnector(); |
| 205 if (!connector) | 205 if (!connector) |
| 206 return; | 206 return; |
| 207 | 207 |
| 208 ash::mojom::WallpaperControllerPtr wallpaper_controller; | 208 ash::mojom::WallpaperControllerPtr wallpaper_controller; |
| 209 connector->BindInterface(ash::mojom::kServiceName, &wallpaper_controller); | 209 connector->BindInterface(ash::mojom::kServiceName, &wallpaper_controller); |
| 210 // TODO(crbug.com/655875): Optimize ash wallpaper transport; avoid sending | 210 // TODO(crbug.com/655875): Optimize ash wallpaper transport; avoid sending |
| 211 // large bitmaps over Mojo; use shared memory like BitmapUploader, etc. | 211 // large bitmaps over Mojo; use shared memory like BitmapUploader, etc. |
| 212 wallpaper_controller->SetWallpaper(*image.bitmap(), layout); | 212 wallpaper_controller->SetWallpaper(*image.bitmap(), layout); |
| 213 } else if (ash::WmShell::HasInstance()) { | 213 } else if (ash::Shell::HasInstance()) { |
| 214 // Note: Wallpaper setting is skipped in unit tests without shell instances. | 214 // Note: Wallpaper setting is skipped in unit tests without shell instances. |
| 215 // In classic ash, interact with the WallpaperController class directly. | 215 // In classic ash, interact with the WallpaperController class directly. |
| 216 ash::WmShell::Get()->wallpaper_controller()->SetWallpaperImage(image, | 216 ash::Shell::GetInstance()->wallpaper_controller()->SetWallpaperImage( |
| 217 layout); | 217 image, layout); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 // A helper function to check the existing/downloaded device wallpaper file's | 221 // A helper function to check the existing/downloaded device wallpaper file's |
| 222 // hash value matches with the hash value provided in the policy settings. | 222 // hash value matches with the hash value provided in the policy settings. |
| 223 bool CheckDeviceWallpaperMatchHash(const base::FilePath& device_wallpaper_file, | 223 bool CheckDeviceWallpaperMatchHash(const base::FilePath& device_wallpaper_file, |
| 224 const std::string& hash) { | 224 const std::string& hash) { |
| 225 std::string image_data; | 225 std::string image_data; |
| 226 if (base::ReadFileToString(device_wallpaper_file, &image_data)) { | 226 if (base::ReadFileToString(device_wallpaper_file, &image_data)) { |
| 227 std::string sha_hash = crypto::SHA256HashString(image_data); | 227 std::string sha_hash = crypto::SHA256HashString(image_data); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 // used here to determine if current user is guest. | 466 // used here to determine if current user is guest. |
| 467 return; | 467 return; |
| 468 } | 468 } |
| 469 | 469 |
| 470 if (command_line->HasSwitch(::switches::kTestType)) | 470 if (command_line->HasSwitch(::switches::kTestType)) |
| 471 WizardController::SetZeroDelays(); | 471 WizardController::SetZeroDelays(); |
| 472 | 472 |
| 473 // Zero delays is also set in autotests. | 473 // Zero delays is also set in autotests. |
| 474 if (WizardController::IsZeroDelayEnabled()) { | 474 if (WizardController::IsZeroDelayEnabled()) { |
| 475 // Ensure tests have some sort of wallpaper. | 475 // Ensure tests have some sort of wallpaper. |
| 476 ash::WmShell::Get()->wallpaper_controller()->CreateEmptyWallpaper(); | 476 ash::Shell::GetInstance()->wallpaper_controller()->CreateEmptyWallpaper(); |
| 477 return; | 477 return; |
| 478 } | 478 } |
| 479 | 479 |
| 480 if (!user_manager->IsUserLoggedIn()) { | 480 if (!user_manager->IsUserLoggedIn()) { |
| 481 if (!StartupUtils::IsDeviceRegistered()) | 481 if (!StartupUtils::IsDeviceRegistered()) |
| 482 SetDefaultWallpaperDelayed(user_manager::SignInAccountId()); | 482 SetDefaultWallpaperDelayed(user_manager::SignInAccountId()); |
| 483 else | 483 else |
| 484 InitializeRegisteredDeviceWallpaper(); | 484 InitializeRegisteredDeviceWallpaper(); |
| 485 return; | 485 return; |
| 486 } | 486 } |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1362 | 1362 |
| 1363 void WallpaperManager::SetDefaultWallpaperPath( | 1363 void WallpaperManager::SetDefaultWallpaperPath( |
| 1364 const base::FilePath& default_small_wallpaper_file, | 1364 const base::FilePath& default_small_wallpaper_file, |
| 1365 std::unique_ptr<gfx::ImageSkia> small_wallpaper_image, | 1365 std::unique_ptr<gfx::ImageSkia> small_wallpaper_image, |
| 1366 const base::FilePath& default_large_wallpaper_file, | 1366 const base::FilePath& default_large_wallpaper_file, |
| 1367 std::unique_ptr<gfx::ImageSkia> large_wallpaper_image) { | 1367 std::unique_ptr<gfx::ImageSkia> large_wallpaper_image) { |
| 1368 default_small_wallpaper_file_ = default_small_wallpaper_file; | 1368 default_small_wallpaper_file_ = default_small_wallpaper_file; |
| 1369 default_large_wallpaper_file_ = default_large_wallpaper_file; | 1369 default_large_wallpaper_file_ = default_large_wallpaper_file; |
| 1370 | 1370 |
| 1371 ash::WallpaperController* controller = | 1371 ash::WallpaperController* controller = |
| 1372 ash::WmShell::Get()->wallpaper_controller(); | 1372 ash::Shell::GetInstance()->wallpaper_controller(); |
| 1373 | 1373 |
| 1374 // |need_update_screen| is true if the previous default wallpaper is visible | 1374 // |need_update_screen| is true if the previous default wallpaper is visible |
| 1375 // now, so we need to update wallpaper on the screen. | 1375 // now, so we need to update wallpaper on the screen. |
| 1376 // | 1376 // |
| 1377 // Layout is ignored here, so wallpaper::WALLPAPER_LAYOUT_CENTER is used | 1377 // Layout is ignored here, so wallpaper::WALLPAPER_LAYOUT_CENTER is used |
| 1378 // as a placeholder only. | 1378 // as a placeholder only. |
| 1379 const bool need_update_screen = | 1379 const bool need_update_screen = |
| 1380 default_wallpaper_image_.get() && | 1380 default_wallpaper_image_.get() && |
| 1381 controller->WallpaperIsAlreadyLoaded(default_wallpaper_image_->image(), | 1381 controller->WallpaperIsAlreadyLoaded(default_wallpaper_image_->image(), |
| 1382 false /* compare_layouts */, | 1382 false /* compare_layouts */, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1407 | 1407 |
| 1408 UMA_HISTOGRAM_ENUMERATION( | 1408 UMA_HISTOGRAM_ENUMERATION( |
| 1409 "Ash.Wallpaper.Apps", | 1409 "Ash.Wallpaper.Apps", |
| 1410 wallpaper_manager_util::ShouldUseAndroidWallpapersApp(profile) | 1410 wallpaper_manager_util::ShouldUseAndroidWallpapersApp(profile) |
| 1411 ? WALLPAPERS_APP_ANDROID | 1411 ? WALLPAPERS_APP_ANDROID |
| 1412 : WALLPAPERS_PICKER_APP_CHROMEOS, | 1412 : WALLPAPERS_PICKER_APP_CHROMEOS, |
| 1413 WALLPAPERS_APPS_NUM); | 1413 WALLPAPERS_APPS_NUM); |
| 1414 } | 1414 } |
| 1415 | 1415 |
| 1416 } // namespace chromeos | 1416 } // namespace chromeos |
| OLD | NEW |