Commit 32df00de authored by Wenzhao Zang's avatar Wenzhao Zang Committed by Commit Bot

wallpaper refactoring: Switch to ShowUserWallpaper in //ash

The implementation of ShowUserWallpaper has been fully moved to //ash.

TBR=alemate@chromium.org, oshima@chromium.org

Bug: 779221
Test: ash_unittests, manual
Change-Id: I3c8de532228669baf56e336ad91c467407cfd9e5
Reviewed-on: https://chromium-review.googlesource.com/848311
Commit-Queue: Wenzhao (Colin) Zang <wzang@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534150}
parent 8c67a59d
......@@ -864,6 +864,10 @@ void WallpaperController::OnLocalStatePrefServiceInitialized(
void WallpaperController::OnSessionStateChanged(
session_manager::SessionState state) {
// Replace the device policy wallpaper with a user wallpaper if necessary.
if (IsDevicePolicyWallpaper() && !ShouldSetDevicePolicyWallpaper())
ReloadWallpaper(false /*clear_cache=*/);
CalculateWallpaperColors();
// The wallpaper may be dimmed/blurred based on session state. The color of
......@@ -1063,6 +1067,21 @@ bool WallpaperController::GetPathFromCache(const AccountId& account_id,
return false;
}
bool WallpaperController::ShouldSetDevicePolicyWallpaper() const {
// Only allow the device wallpaper if the policy is in effect for enterprise
// managed devices.
if (!is_device_wallpaper_policy_enforced_)
return false;
// Only set the device wallpaper if we're at the login screen.
if (Shell::Get()->session_controller()->GetSessionState() !=
session_manager::SessionState::LOGIN_PRIMARY) {
return false;
}
return true;
}
void WallpaperController::Init(
mojom::WallpaperControllerClientPtr client,
const base::FilePath& user_data_path,
......@@ -1215,9 +1234,20 @@ void WallpaperController::UpdateCustomWallpaperLayout(
void WallpaperController::ShowUserWallpaper(
mojom::WallpaperUserInfoPtr user_info) {
current_user_ = std::move(user_info);
const user_manager::UserType user_type = current_user_->type;
if (user_type == user_manager::USER_TYPE_KIOSK_APP ||
user_type == user_manager::USER_TYPE_ARC_KIOSK_APP) {
return;
}
if (ShouldSetDevicePolicyWallpaper()) {
SetDevicePolicyWallpaper();
return;
}
const AccountId account_id = current_user_->account_id;
const bool is_persistent = !current_user_->is_ephemeral;
// Guest user or regular user in ephemeral mode.
// TODO(wzang/xdai): Check if the wallpaper info for ephemeral users should
// be saved to local state.
......@@ -1293,6 +1323,7 @@ void WallpaperController::ShowUserWallpaper(
}
void WallpaperController::ShowSigninWallpaper() {
current_user_.reset();
if (ShouldSetDevicePolicyWallpaper()) {
SetDevicePolicyWallpaper();
} else {
......@@ -1710,7 +1741,6 @@ void WallpaperController::OnWallpaperDecoded(
}
void WallpaperController::ReloadWallpaper(bool clear_cache) {
current_wallpaper_.reset();
if (clear_cache)
wallpaper_cache_map_.clear();
......@@ -1806,19 +1836,6 @@ bool WallpaperController::IsDevicePolicyWallpaper() const {
return false;
}
bool WallpaperController::ShouldSetDevicePolicyWallpaper() const {
// Only allow the device wallpaper if the policy is in effect for enterprise
// managed devices.
if (!is_device_wallpaper_policy_enforced_)
return false;
// Only set the device wallpaper if we're at the login screen.
if (Shell::Get()->session_controller()->IsActiveUserSessionStarted())
return false;
return true;
}
void WallpaperController::SetDevicePolicyWallpaper() {
DCHECK(ShouldSetDevicePolicyWallpaper());
ReadAndDecodeWallpaper(
......
......@@ -360,6 +360,10 @@ class ASH_EXPORT WallpaperController
// Gets path of encoded wallpaper from cache. Returns true if success.
bool GetPathFromCache(const AccountId& account_id, base::FilePath* path);
// Returns true if device wallpaper policy is in effect and we are at the
// login screen right now.
bool ShouldSetDevicePolicyWallpaper() const;
// mojom::WallpaperController overrides:
void Init(mojom::WallpaperControllerClientPtr client,
const base::FilePath& user_data_path,
......@@ -390,10 +394,6 @@ class ASH_EXPORT WallpaperController
void SetDeviceWallpaperPolicyEnforced(bool enforced) override;
void UpdateCustomWallpaperLayout(mojom::WallpaperUserInfoPtr user_info,
wallpaper::WallpaperLayout layout) override;
// TODO(crbug.com/776464): |ShowUserWallpaper| is incomplete until device
// policy wallpaper is migrated. Callers from chrome should use
// |WallpaperManager::ShowUserWallpaper| instead. Callers in ash can't use it
// for now.
void ShowUserWallpaper(mojom::WallpaperUserInfoPtr user_info) override;
void ShowSigninWallpaper() override;
void RemoveUserWallpaper(mojom::WallpaperUserInfoPtr user_info,
......@@ -542,10 +542,6 @@ class ASH_EXPORT WallpaperController
// Returns whether the current wallpaper is set by device policy.
bool IsDevicePolicyWallpaper() const;
// Returns true if device wallpaper policy is in effect and we are at the
// login screen right now.
bool ShouldSetDevicePolicyWallpaper() const;
// Reads the device wallpaper file and sets it as the current wallpaper. Note
// when it's called, it's guaranteed that ShouldSetDevicePolicyWallpaper()
// should be true.
......
......@@ -464,6 +464,11 @@ class WallpaperControllerTest : public AshTestBase {
return controller_->IsActiveUserWallpaperControlledByPolicyImpl();
}
// Wrapper for private IsDevicePolicyWallpaper().
bool IsDevicePolicyWallpaper() {
return controller_->IsDevicePolicyWallpaper();
}
int GetWallpaperCount() { return controller_->wallpaper_count_for_testing_; }
void SetBypassDecode() { controller_->bypass_decode_for_testing_ = true; }
......@@ -1615,4 +1620,39 @@ TEST_F(WallpaperControllerTest, WallpaperBlurDuringLockScreenTransition) {
controller_->RemoveObserver(&observer);
}
TEST_F(WallpaperControllerTest, OnlyShowDevicePolicyWallpaperOnLoginScreen) {
SetBypassDecode();
// Verify the device policy wallpaper is shown on login screen.
SetSessionState(SessionState::LOGIN_PRIMARY);
controller_->SetDeviceWallpaperPolicyEnforced(true);
RunAllTasksUntilIdle();
EXPECT_EQ(1, GetWallpaperCount());
EXPECT_TRUE(IsDevicePolicyWallpaper());
// Verify the device policy wallpaper is replaced when session state is no
// longer LOGIN_PRIMARY.
SetSessionState(SessionState::LOGGED_IN_NOT_ACTIVE);
RunAllTasksUntilIdle();
EXPECT_EQ(2, GetWallpaperCount());
EXPECT_FALSE(IsDevicePolicyWallpaper());
// Verify the device policy wallpaper never shows up again when session
// state changes.
SetSessionState(SessionState::ACTIVE);
RunAllTasksUntilIdle();
EXPECT_EQ(2, GetWallpaperCount());
EXPECT_FALSE(IsDevicePolicyWallpaper());
SetSessionState(SessionState::LOCKED);
RunAllTasksUntilIdle();
EXPECT_EQ(2, GetWallpaperCount());
EXPECT_FALSE(IsDevicePolicyWallpaper());
SetSessionState(SessionState::LOGIN_SECONDARY);
RunAllTasksUntilIdle();
EXPECT_EQ(2, GetWallpaperCount());
EXPECT_FALSE(IsDevicePolicyWallpaper());
}
} // namespace ash
......@@ -20,9 +20,9 @@
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h"
#include "chrome/browser/chromeos/login/screens/chrome_user_selection_screen.h"
#include "chrome/browser/chromeos/login/user_selection_screen_proxy.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
#include "chrome/browser/chromeos/system/system_clock.h"
#include "chrome/browser/ui/ash/session_controller_client.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
......@@ -236,7 +236,7 @@ void ViewsScreenLocker::HandleOnFocusPod(const AccountId& account_id) {
lock_screen_utils::SetUserInputMethod(account_id.GetUserEmail(),
ime_state_.get());
lock_screen_utils::SetKeyboardSettings(account_id);
WallpaperManager::Get()->ShowUserWallpaper(account_id);
WallpaperControllerClient::Get()->ShowUserWallpaper(account_id);
bool use_24hour_clock = false;
if (user_manager::known_user::GetBooleanPref(
......
......@@ -10,10 +10,10 @@
#include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
#include "chrome/browser/chromeos/mobile_config.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/system/device_disabling_manager.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
namespace chromeos {
namespace {
......@@ -168,11 +168,11 @@ void LoginDisplayHost::SetDisplayAndGivenName(const std::string& display_name,
}
void LoginDisplayHost::LoadWallpaper(const AccountId& account_id) {
WallpaperManager::Get()->ShowUserWallpaper(account_id);
WallpaperControllerClient::Get()->ShowUserWallpaper(account_id);
}
void LoginDisplayHost::LoadSigninWallpaper() {
WallpaperManager::Get()->ShowSigninWallpaper();
WallpaperControllerClient::Get()->ShowSigninWallpaper();
}
bool LoginDisplayHost::IsUserWhitelisted(const AccountId& account_id) {
......
......@@ -12,7 +12,6 @@
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "chrome/browser/chromeos/login/ui/webui_login_view.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/grit/generated_resources.h"
......
......@@ -12,7 +12,7 @@
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_webui.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen_input_methods_controller.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "components/session_manager/core/session_manager.h"
#include "components/user_manager/user_manager.h"
#include "ui/gfx/geometry/rect.h"
......@@ -69,7 +69,7 @@ void UserAddingScreenImpl::Cancel() {
// Reset wallpaper if cancel adding user from multiple user sign in page.
if (user_manager::UserManager::Get()->IsUserLoggedIn()) {
WallpaperManager::Get()->ShowUserWallpaper(
WallpaperControllerClient::Get()->ShowUserWallpaper(
user_manager::UserManager::Get()->GetActiveUser()->GetAccountId());
}
}
......
......@@ -48,7 +48,6 @@
#include "chrome/browser/chromeos/login/users/default_user_image/default_user_images.h"
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
#include "chrome/browser/chromeos/login/users/supervised_user_manager_impl.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/printing/external_printers.h"
#include "chrome/browser/chromeos/printing/external_printers_factory.h"
......@@ -811,7 +810,8 @@ void ChromeUserManagerImpl::GuestUserLoggedIn() {
user_manager::User::USER_IMAGE_INVALID, false);
// Initializes wallpaper after active_user_ is set.
WallpaperManager::Get()->ShowUserWallpaper(user_manager::GuestAccountId());
WallpaperControllerClient::Get()->ShowUserWallpaper(
user_manager::GuestAccountId());
}
void ChromeUserManagerImpl::RegularUserLoggedIn(
......@@ -839,7 +839,7 @@ void ChromeUserManagerImpl::RegularUserLoggedInAsEphemeral(
ChromeUserManager::RegularUserLoggedInAsEphemeral(account_id, user_type);
GetUserImageManager(account_id)->UserLoggedIn(IsCurrentUserNew(), false);
WallpaperManager::Get()->ShowUserWallpaper(account_id);
WallpaperControllerClient::Get()->ShowUserWallpaper(account_id);
}
void ChromeUserManagerImpl::SupervisedUserLoggedIn(
......@@ -910,7 +910,7 @@ void ChromeUserManagerImpl::KioskAppLoggedIn(user_manager::User* user) {
user_manager::User::USER_IMAGE_INVALID, false);
const AccountId& kiosk_app_account_id = user->GetAccountId();
WallpaperManager::Get()->ShowUserWallpaper(kiosk_app_account_id);
WallpaperControllerClient::Get()->ShowUserWallpaper(kiosk_app_account_id);
// TODO(bartfab): Add KioskAppUsers to the users_ list and keep metadata like
// the kiosk_app_id in these objects, removing the need to re-parse the
......@@ -980,7 +980,8 @@ void ChromeUserManagerImpl::DemoAccountLoggedIn() {
*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_LOGIN_DEFAULT_USER)),
user_manager::User::USER_IMAGE_INVALID, false);
WallpaperManager::Get()->ShowUserWallpaper(user_manager::DemoAccountId());
WallpaperControllerClient::Get()->ShowUserWallpaper(
user_manager::DemoAccountId());
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
command_line->AppendSwitch(::switches::kForceAppMode);
......
......@@ -95,27 +95,6 @@ bool HasNonDeviceLocalAccounts(const user_manager::UserList& users) {
return false;
}
// A helper to set the wallpaper image for Classic Ash and Mash.
void SetWallpaper(const gfx::ImageSkia& image, wallpaper::WallpaperInfo info) {
if (ash_util::IsRunningInMash()) {
// In mash, connect to the WallpaperController interface via mojo.
service_manager::Connector* connector =
content::ServiceManagerConnection::GetForProcess()->GetConnector();
if (!connector)
return;
ash::mojom::WallpaperControllerPtr wallpaper_controller;
connector->BindInterface(ash::mojom::kServiceName, &wallpaper_controller);
// TODO(crbug.com/655875): Optimize ash wallpaper transport; avoid sending
// large bitmaps over Mojo; use shared memory like BitmapUploader, etc.
wallpaper_controller->SetWallpaper(*image.bitmap(), info);
} else if (ash::Shell::HasInstance()) {
// Note: Wallpaper setting is skipped in unit tests without shell instances.
// In classic ash, interact with the WallpaperController class directly.
ash::Shell::Get()->wallpaper_controller()->SetWallpaperImage(image, info);
}
}
} // namespace
void AssertCalledOnWallpaperSequence(base::SequencedTaskRunner* task_runner) {
......@@ -152,44 +131,6 @@ void WallpaperManager::Shutdown() {
wallpaper_manager = nullptr;
}
void WallpaperManager::ShowUserWallpaper(const AccountId& account_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Some unit tests come here without a UserManager or without a pref system.
if (!user_manager::UserManager::IsInitialized() ||
!g_browser_process->local_state()) {
return;
}
const user_manager::User* user =
user_manager::UserManager::Get()->FindUser(account_id);
// User is unknown or there is no visible wallpaper in kiosk mode.
if (!user || user->GetType() == user_manager::USER_TYPE_KIOSK_APP ||
user->GetType() == user_manager::USER_TYPE_ARC_KIOSK_APP) {
return;
}
// For a enterprise managed user, set the device wallpaper if we're at the
// login screen.
// TODO(xdai): Replace these two functions ShouldSetDeviceWallpaper() and
// OnDeviceWallpaperChanged() with functions in WallpaperController.
std::string url;
std::string hash;
if (ShouldSetDeviceWallpaper(account_id, &url, &hash)) {
WallpaperControllerClient::Get()->OnDeviceWallpaperChanged();
return;
}
// TODO(crbug.com/776464): Move the above to
// |WallpaperController::ShowUserWallpaper| after
// |SetDeviceWallpaperIfApplicable| is migrated.
WallpaperControllerClient::Get()->ShowUserWallpaper(account_id);
}
void WallpaperManager::ShowSigninWallpaper() {
WallpaperControllerClient::Get()->ShowSigninWallpaper();
}
void WallpaperManager::InitializeWallpaper() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
......@@ -223,12 +164,13 @@ void WallpaperManager::InitializeWallpaper() {
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
if (!user_manager->IsUserLoggedIn()) {
if (!StartupUtils::IsDeviceRegistered())
ShowSigninWallpaper();
WallpaperControllerClient::Get()->ShowSigninWallpaper();
else
InitializeRegisteredDeviceWallpaper();
return;
}
ShowUserWallpaper(user_manager->GetActiveUser()->GetAccountId());
WallpaperControllerClient::Get()->ShowUserWallpaper(
user_manager->GetActiveUser()->GetAccountId());
}
void WallpaperManager::SetCustomizedDefaultWallpaperPaths(
......@@ -271,20 +213,6 @@ WallpaperManager::WallpaperManager() : weak_factory_(this) {
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN});
}
void WallpaperManager::SetUserWallpaperInfo(const AccountId& account_id,
const WallpaperInfo& info,
bool is_persistent) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!ash::Shell::HasInstance() || ash_util::IsRunningInMash()) {
// Some unit tests come here without a Shell instance.
// TODO(crbug.com/776464): This is intended not to work under mash. Make it
// work again after WallpaperManager is removed.
return;
}
ash::Shell::Get()->wallpaper_controller()->SetUserWallpaperInfo(
account_id, info, is_persistent);
}
base::CommandLine* WallpaperManager::GetCommandLine() {
base::CommandLine* command_line =
command_line_for_testing_ ? command_line_for_testing_
......@@ -307,13 +235,14 @@ void WallpaperManager::InitializeRegisteredDeviceWallpaper() {
if ((!show_users && public_session_user_index == -1) ||
!HasNonDeviceLocalAccounts(users)) {
// Boot into the sign in screen.
ShowSigninWallpaper();
WallpaperControllerClient::Get()->ShowSigninWallpaper();
return;
}
// Normal boot, load user wallpaper.
int index = public_session_user_index != -1 ? public_session_user_index : 0;
ShowUserWallpaper(users[index]->GetAccountId());
WallpaperControllerClient::Get()->ShowUserWallpaper(
users[index]->GetAccountId());
}
bool WallpaperManager::GetUserWallpaperInfo(const AccountId& account_id,
......@@ -332,51 +261,4 @@ bool WallpaperManager::GetUserWallpaperInfo(const AccountId& account_id,
account_id, info, is_persistent);
}
bool WallpaperManager::ShouldSetDeviceWallpaper(const AccountId& account_id,
std::string* url,
std::string* hash) {
// Only allow the device wallpaper for enterprise managed devices.
if (!g_browser_process->platform_part()
->browser_policy_connector_chromeos()
->IsEnterpriseManaged()) {
return false;
}
const base::DictionaryValue* dict = nullptr;
if (!CrosSettings::Get()->GetDictionary(kDeviceWallpaperImage, &dict) ||
!dict->GetStringWithoutPathExpansion("url", url) ||
!dict->GetStringWithoutPathExpansion("hash", hash)) {
return false;
}
// Only set the device wallpaper if we're at the login screen.
if (user_manager::UserManager::Get()->IsUserLoggedIn())
return false;
return true;
}
void WallpaperManager::SetDefaultWallpaperImpl(const AccountId& account_id,
bool show_wallpaper) {
if (!ash::Shell::HasInstance() || ash_util::IsRunningInMash()) {
// Some unit tests come here without a Shell instance.
// TODO(crbug.com/776464): This is intended not to work under mash. Make it
// work again after WallpaperManager is removed.
WallpaperInfo info("", wallpaper::WALLPAPER_LAYOUT_STRETCH,
wallpaper::DEFAULT, base::Time::Now().LocalMidnight());
SetWallpaper(ash::WallpaperController::CreateSolidColorWallpaper(), info);
return;
}
const user_manager::User* user =
user_manager::UserManager::Get()->FindUser(account_id);
if (!user) {
LOG(ERROR) << "User of " << account_id
<< " cannot be found. This should never happen"
<< " within WallpaperManager::SetDefaultWallpaperImpl.";
return;
}
ash::Shell::Get()->wallpaper_controller()->SetDefaultWallpaperImpl(
account_id, user->GetType(), show_wallpaper);
}
} // namespace chromeos
......@@ -57,18 +57,6 @@ class WallpaperManager {
// WallpaperManager to remove any observers it has registered.
static void Shutdown();
// Shows |account_id|'s wallpaper, which is determined in the following order:
// 1) Use device policy wallpaper if it exists AND we are at the login screen.
// 2) Use user policy wallpaper if it exists.
// 3) Use the wallpaper set by the user (either by |SetOnlineWallpaper| or
// |SetCustomWallpaper|), if any.
// 4) Use the default wallpaper of this user.
void ShowUserWallpaper(const AccountId& account_id);
// Used by the gaia-signin UI. Signin wallpaper is considered either as the
// device policy wallpaper or the default wallpaper.
void ShowSigninWallpaper();
// Initializes wallpaper. If logged in, loads user's wallpaper. If not logged
// in, uses a solid color wallpaper. If logged in as a stub user, uses an
// empty wallpaper.
......@@ -94,11 +82,6 @@ class WallpaperManager {
WallpaperManager();
// A wrapper of |WallpaperController::SetUserWallpaperInfo|.
void SetUserWallpaperInfo(const AccountId& account_id,
const wallpaper::WallpaperInfo& info,
bool is_persistent);
// Gets the CommandLine representing the current process's command line.
base::CommandLine* GetCommandLine();
......@@ -110,16 +93,6 @@ class WallpaperManager {
bool GetUserWallpaperInfo(const AccountId& account_id,
wallpaper::WallpaperInfo* info) const;
// Returns true if the device wallpaper should be set for the account.
// TODO(xdai): Remove this function after migrating ShowUserWallpaper().
bool ShouldSetDeviceWallpaper(const AccountId& account_id,
std::string* url,
std::string* hash);
// A wrapper of |WallpaperController::SetDefaultWallpaperImpl|.
void SetDefaultWallpaperImpl(const AccountId& account_id,
bool show_wallpaper);
// Returns the cached logged-in user wallpaper info, or a dummy value under
// mash.
wallpaper::WallpaperInfo* GetCachedWallpaperInfo();
......
......@@ -51,6 +51,7 @@
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_names.h"
#include "components/wallpaper/wallpaper_info.h"
#include "content/public/test/browser_test_utils.h"
#include "crypto/rsa_private_key.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
......@@ -245,6 +246,15 @@ class WallpaperManagerPolicyTest : public LoginManagerTest,
}
}
// Runs the loop until wallpaper has changed to the specified type.
void RunUntilWallpaperChangeType(wallpaper::WallpaperType type) {
while (ash::Shell::Get()->wallpaper_controller()->GetWallpaperType() !=
type) {
run_loop_.reset(new base::RunLoop);
run_loop_->Run();
}
}
std::string ConstructPolicy(const std::string& relative_path) const {
std::string image_data;
if (!base::ReadFileToString(test_data_dir_.Append(relative_path),
......@@ -303,10 +313,10 @@ class WallpaperManagerPolicyTest : public LoginManagerTest,
fake_session_manager_client_->OnPropertyChangeComplete(true /* success */);
}
bool ShouldSetDeviceWallpaper(const AccountId& account_id) {
std::string url, hash;
return WallpaperManager::Get()->ShouldSetDeviceWallpaper(account_id, &url,
&hash);
bool ShouldSetDeviceWallpaper() {
return ash::Shell::Get()
->wallpaper_controller()
->ShouldSetDevicePolicyWallpaper();
}
// Obtain WallpaperInfo for |user_number| from WallpaperManager.
......@@ -421,24 +431,25 @@ IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, DevicePolicyTest) {
// Set the device wallpaper policy. Test that the device policy controlled
// wallpaper shows up in the login screen.
InjectDevicePolicy(kRedImageFileName);
RunUntilWallpaperChangeCount(1);
EXPECT_TRUE(ShouldSetDeviceWallpaper(user_manager::SignInAccountId()));
RunUntilWallpaperChangeType(wallpaper::DEVICE);
EXPECT_TRUE(ShouldSetDeviceWallpaper());
EXPECT_EQ(kRedImageColor, GetAverageWallpaperColor());
// Log in a test user and set the user wallpaper policy. The user policy
// controlled wallpaper shows up in the user session.
// Log in a test user. The default wallpaper should be shown to replace the
// device policy wallpaper.
LoginUser(testUsers_[0]);
RunUntilWallpaperChangeCount(2);
RunUntilWallpaperChangeType(wallpaper::DEFAULT);
// Now set the user wallpaper policy. The user policy controlled wallpaper
// should show up in the user session.
InjectPolicy(0, kGreenImageFileName);
RunUntilWallpaperChangeCount(3);
RunUntilWallpaperChangeType(wallpaper::POLICY);
EXPECT_EQ(kGreenImageColor, GetAverageWallpaperColor());
// Set the device wallpaper policy inside the user session. That that the
// user wallpaper doesn't change.
InjectDevicePolicy(kBlueImageFileName);
EXPECT_FALSE(ShouldSetDeviceWallpaper(
user_manager::UserManager::Get()->GetActiveUser()->GetAccountId()));
EXPECT_FALSE(ShouldSetDeviceWallpaper());
EXPECT_EQ(kGreenImageColor, GetAverageWallpaperColor());
}
......
......@@ -10,7 +10,7 @@
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
#include "chrome/browser/chromeos/login/reauth_stats.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "content/public/common/service_manager_connection.h"
#include "services/service_manager/public/cpp/connector.h"
......@@ -107,7 +107,7 @@ void LoginScreenClient::FocusLockScreenApps(bool reverse) {
}
void LoginScreenClient::LoadWallpaper(const AccountId& account_id) {
chromeos::WallpaperManager::Get()->ShowUserWallpaper(account_id);
WallpaperControllerClient::Get()->ShowUserWallpaper(account_id);
}
void LoginScreenClient::SignOutUser() {
......
......@@ -9,9 +9,9 @@
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/window_positioner.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "ui/app_list/presenter/app_list.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/compositor/layer_animation_observer.h"
......@@ -173,7 +173,7 @@ void UserSwitchAnimatorChromeOS::TransitionWallpaper(
wallpaper_delegate->SetAnimationDurationOverride(
std::max(duration, kMinimalAnimationTimeMS));
if (screen_cover_ != NEW_USER_COVERS_SCREEN) {
chromeos::WallpaperManager::Get()->ShowUserWallpaper(new_account_id_);
WallpaperControllerClient::Get()->ShowUserWallpaper(new_account_id_);
wallpaper_user_id_for_test_ =
(NO_USER_COVERS_SCREEN == screen_cover_ ? "->" : "") +
new_account_id_.Serialize();
......@@ -182,7 +182,7 @@ void UserSwitchAnimatorChromeOS::TransitionWallpaper(
// Revert the wallpaper cross dissolve animation duration back to the
// default.
if (screen_cover_ == NEW_USER_COVERS_SCREEN)
chromeos::WallpaperManager::Get()->ShowUserWallpaper(new_account_id_);
WallpaperControllerClient::Get()->ShowUserWallpaper(new_account_id_);
// Coming here the wallpaper user id is the final result. No matter how we
// got here.
......
......@@ -15,8 +15,8 @@
#include "chrome/browser/chromeos/login/supervised/supervised_user_creation_flow.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
......@@ -300,7 +300,7 @@ void SupervisedUserCreationScreenHandler::HandleManagerSelected(
const AccountId& manager_id) {
if (!delegate_)
return;
WallpaperManager::Get()->ShowUserWallpaper(manager_id);
WallpaperControllerClient::Get()->ShowUserWallpaper(manager_id);
}
void SupervisedUserCreationScreenHandler::HandleImportUserSelected(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment