Commit 3545d90b authored by Mike Wasserman's avatar Mike Wasserman Committed by Commit Bot

Remove ash::WallpaperUserInfo, pass AccountIds instead

Remove WallpaperUserInfo (see PS1 for use of UserInfo instead).
Pass AccountIds to WallpaperController instead of structs.
Encapsulate lookup of the user type and ephemeral flag.

Remove now-unused ephemeral flag from OnlineWallpaperParams.
Remove InitializeUser test helper and inline Clear* as needed.
Add optional user type argument to SimulateUserLogin.

Bug: 958227
Test: No wallpaper regressions.
Change-Id: I768e6ac748faa008f7947839d56c2ce7e75be1bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1648749Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Auto-Submit: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668452}
parent 99a9109c
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "ash/public/cpp/multi_user_window_manager_delegate.h" #include "ash/public/cpp/multi_user_window_manager_delegate.h"
#include "ash/public/cpp/multi_user_window_manager_observer.h" #include "ash/public/cpp/multi_user_window_manager_observer.h"
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/wallpaper_user_info.h"
#include "ash/session/session_controller_impl.h" #include "ash/session/session_controller_impl.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/desks/desks_util.h" #include "ash/wm/desks/desks_util.h"
...@@ -60,26 +59,6 @@ bool HasSystemModalTransientChildWindow(aura::Window* window) { ...@@ -60,26 +59,6 @@ bool HasSystemModalTransientChildWindow(aura::Window* window) {
return false; return false;
} }
WallpaperUserInfo WallpaperUserInfoForAccount(const AccountId& account_id) {
DCHECK(account_id.is_valid());
WallpaperUserInfo wallpaper_user_info;
SessionControllerImpl* session_controller =
Shell::Get()->session_controller();
for (const std::unique_ptr<UserSession>& user_session :
session_controller->GetUserSessions()) {
if (user_session->user_info.account_id == account_id) {
wallpaper_user_info.account_id = account_id;
wallpaper_user_info.type = user_session->user_info.type;
wallpaper_user_info.is_ephemeral = user_session->user_info.is_ephemeral;
wallpaper_user_info.has_gaia_account =
user_session->user_info.has_gaia_account;
return wallpaper_user_info;
}
}
NOTREACHED();
return wallpaper_user_info;
}
} // namespace } // namespace
// A class to temporarily change the animation properties for a window. // A class to temporarily change the animation properties for a window.
...@@ -306,8 +285,7 @@ void MultiUserWindowManagerImpl::OnActiveUserSessionChanged( ...@@ -306,8 +285,7 @@ void MultiUserWindowManagerImpl::OnActiveUserSessionChanged(
// animation only to be reshown again by the destructor of the old animation. // animation only to be reshown again by the destructor of the old animation.
animation_.reset(); animation_.reset();
animation_ = std::make_unique<UserSwitchAnimator>( animation_ = std::make_unique<UserSwitchAnimator>(
this, WallpaperUserInfoForAccount(current_account_id_), this, current_account_id_, GetAdjustedAnimationTime(kUserFadeTime));
GetAdjustedAnimationTime(kUserFadeTime));
// Call RequestCaptureState here instead of having MediaClient observe // Call RequestCaptureState here instead of having MediaClient observe
// ActiveUserChanged because it must happen after // ActiveUserChanged because it must happen after
......
...@@ -80,13 +80,11 @@ void PutMruWindowLast(std::vector<aura::Window*>* window_list) { ...@@ -80,13 +80,11 @@ void PutMruWindowLast(std::vector<aura::Window*>* window_list) {
} // namespace } // namespace
UserSwitchAnimator::UserSwitchAnimator( UserSwitchAnimator::UserSwitchAnimator(MultiUserWindowManagerImpl* owner,
MultiUserWindowManagerImpl* owner, const AccountId& new_account_id,
const WallpaperUserInfo& wallpaper_user_info, base::TimeDelta animation_speed)
base::TimeDelta animation_speed)
: owner_(owner), : owner_(owner),
wallpaper_user_info_(wallpaper_user_info), new_account_id_(new_account_id),
new_account_id_(wallpaper_user_info_.account_id),
animation_speed_(animation_speed), animation_speed_(animation_speed),
animation_step_(ANIMATION_STEP_HIDE_OLD_USER), animation_step_(ANIMATION_STEP_HIDE_OLD_USER),
screen_cover_(GetScreenCover(NULL)), screen_cover_(GetScreenCover(NULL)),
...@@ -171,7 +169,7 @@ void UserSwitchAnimator::TransitionWallpaper(AnimationStep animation_step) { ...@@ -171,7 +169,7 @@ void UserSwitchAnimator::TransitionWallpaper(AnimationStep animation_step) {
wallpaper_controller->SetAnimationDuration( wallpaper_controller->SetAnimationDuration(
duration > kMinimalAnimationTime ? duration : kMinimalAnimationTime); duration > kMinimalAnimationTime ? duration : kMinimalAnimationTime);
if (screen_cover_ != NEW_USER_COVERS_SCREEN) { if (screen_cover_ != NEW_USER_COVERS_SCREEN) {
wallpaper_controller->ShowUserWallpaper(wallpaper_user_info_); wallpaper_controller->ShowUserWallpaper(new_account_id_);
wallpaper_user_id_for_test_ = wallpaper_user_id_for_test_ =
(NO_USER_COVERS_SCREEN == screen_cover_ ? "->" : "") + (NO_USER_COVERS_SCREEN == screen_cover_ ? "->" : "") +
new_account_id_.Serialize(); new_account_id_.Serialize();
...@@ -180,7 +178,7 @@ void UserSwitchAnimator::TransitionWallpaper(AnimationStep animation_step) { ...@@ -180,7 +178,7 @@ void UserSwitchAnimator::TransitionWallpaper(AnimationStep animation_step) {
// Revert the wallpaper cross dissolve animation duration back to the // Revert the wallpaper cross dissolve animation duration back to the
// default. // default.
if (screen_cover_ == NEW_USER_COVERS_SCREEN) if (screen_cover_ == NEW_USER_COVERS_SCREEN)
wallpaper_controller->ShowUserWallpaper(wallpaper_user_info_); wallpaper_controller->ShowUserWallpaper(new_account_id_);
// Coming here the wallpaper user id is the final result. No matter how we // Coming here the wallpaper user id is the final result. No matter how we
// got here. // got here.
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <string> #include <string>
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/public/cpp/wallpaper_user_info.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
...@@ -36,10 +35,10 @@ class ASH_EXPORT UserSwitchAnimator { ...@@ -36,10 +35,10 @@ class ASH_EXPORT UserSwitchAnimator {
ANIMATION_STEP_ENDED // The animation has ended. ANIMATION_STEP_ENDED // The animation has ended.
}; };
// Creates a UserSwitchAnimator to animate between the current user and // Creates a UserSwitchAnimator to animate between the current user and the
// |user_info|. // user associated with |new_account_id|.
UserSwitchAnimator(MultiUserWindowManagerImpl* owner, UserSwitchAnimator(MultiUserWindowManagerImpl* owner,
const WallpaperUserInfo& user_info, const AccountId& new_account_id,
base::TimeDelta animation_speed); base::TimeDelta animation_speed);
~UserSwitchAnimator(); ~UserSwitchAnimator();
...@@ -101,10 +100,6 @@ class ASH_EXPORT UserSwitchAnimator { ...@@ -101,10 +100,6 @@ class ASH_EXPORT UserSwitchAnimator {
// The owning window manager. // The owning window manager.
MultiUserWindowManagerImpl* owner_; MultiUserWindowManagerImpl* owner_;
// Contains the wallpaper configuration for the user switching to. This is
// passed to the WallpaperController at the right time.
WallpaperUserInfo wallpaper_user_info_;
// The new user to set. // The new user to set.
AccountId new_account_id_; AccountId new_account_id_;
......
...@@ -186,7 +186,6 @@ component("cpp") { ...@@ -186,7 +186,6 @@ component("cpp") {
"wallpaper_controller_observer.h", "wallpaper_controller_observer.h",
"wallpaper_info.h", "wallpaper_info.h",
"wallpaper_types.h", "wallpaper_types.h",
"wallpaper_user_info.h",
"window_animation_types.h", "window_animation_types.h",
"window_pin_type.cc", "window_pin_type.cc",
"window_pin_type.h", "window_pin_type.h",
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/time/time.h" #include "base/time/time.h"
class AccountId;
namespace gfx { namespace gfx {
class ImageSkia; class ImageSkia;
} }
...@@ -22,7 +24,6 @@ namespace ash { ...@@ -22,7 +24,6 @@ namespace ash {
class WallpaperControllerObserver; class WallpaperControllerObserver;
class WallpaperControllerClient; class WallpaperControllerClient;
struct WallpaperUserInfo;
// Used by Chrome to set the wallpaper displayed by ash. // Used by Chrome to set the wallpaper displayed by ash.
class ASH_PUBLIC_EXPORT WallpaperController { class ASH_PUBLIC_EXPORT WallpaperController {
...@@ -44,15 +45,15 @@ class ASH_PUBLIC_EXPORT WallpaperController { ...@@ -44,15 +45,15 @@ class ASH_PUBLIC_EXPORT WallpaperController {
// Sets wallpaper from a local file and updates the saved wallpaper info for // Sets wallpaper from a local file and updates the saved wallpaper info for
// the user. // the user.
// |user_info|: The user's information related to wallpaper. // |account_id|: The user's account id.
// |wallpaper_files_id|: The file id for user_info.account_id. // |wallpaper_files_id|: The file id for |account_id|.
// |file_name|: The name of the wallpaper file. // |file_name|: The name of the wallpaper file.
// |layout|: The layout of the wallpaper, used for wallpaper resizing. // |layout|: The layout of the wallpaper, used for wallpaper resizing.
// |image|: The wallpaper image. // |image|: The wallpaper image.
// |preview_mode|: If true, show the wallpaper immediately but doesn't change // |preview_mode|: If true, show the wallpaper immediately but doesn't change
// the user wallpaper info until |ConfirmPreviewWallpaper| is // the user wallpaper info until |ConfirmPreviewWallpaper| is
// called. // called.
virtual void SetCustomWallpaper(const WallpaperUserInfo& user_info, virtual void SetCustomWallpaper(const AccountId& account_id,
const std::string& wallpaper_files_id, const std::string& wallpaper_files_id,
const std::string& file_name, const std::string& file_name,
WallpaperLayout layout, WallpaperLayout layout,
...@@ -63,7 +64,7 @@ class ASH_PUBLIC_EXPORT WallpaperController { ...@@ -63,7 +64,7 @@ class ASH_PUBLIC_EXPORT WallpaperController {
// corresponding to |url| already exists in local file system (i.e. // corresponding to |url| already exists in local file system (i.e.
// |SetOnlineWallpaperFromData| was called earlier with the same |url|), // |SetOnlineWallpaperFromData| was called earlier with the same |url|),
// returns true and sets wallpaper for the user, otherwise returns false. // returns true and sets wallpaper for the user, otherwise returns false.
// |user_info|: The user's information related to wallpaper. // |account_id|: The user's account id.
// |url|: The wallpaper url. // |url|: The wallpaper url.
// |layout|: The layout of the wallpaper, used for wallpaper resizing. // |layout|: The layout of the wallpaper, used for wallpaper resizing.
// |preview_mode|: If true, show the wallpaper immediately but doesn't change // |preview_mode|: If true, show the wallpaper immediately but doesn't change
...@@ -72,7 +73,7 @@ class ASH_PUBLIC_EXPORT WallpaperController { ...@@ -72,7 +73,7 @@ class ASH_PUBLIC_EXPORT WallpaperController {
// Responds with true if the wallpaper file exists in local file system. // Responds with true if the wallpaper file exists in local file system.
using SetOnlineWallpaperIfExistsCallback = base::OnceCallback<void(bool)>; using SetOnlineWallpaperIfExistsCallback = base::OnceCallback<void(bool)>;
virtual void SetOnlineWallpaperIfExists( virtual void SetOnlineWallpaperIfExists(
const WallpaperUserInfo& user_info, const AccountId& account_id,
const std::string& url, const std::string& url,
WallpaperLayout layout, WallpaperLayout layout,
bool preview_mode, bool preview_mode,
...@@ -82,7 +83,7 @@ class ASH_PUBLIC_EXPORT WallpaperController { ...@@ -82,7 +83,7 @@ class ASH_PUBLIC_EXPORT WallpaperController {
// to local file system. After this, |SetOnlineWallpaperIfExists| will return // to local file system. After this, |SetOnlineWallpaperIfExists| will return
// true for the same |url|, so that there's no need to provide |image_data| // true for the same |url|, so that there's no need to provide |image_data|
// when the same wallpaper needs to be set again or for another user. // when the same wallpaper needs to be set again or for another user.
// |user_info|: The user's information related to wallpaper. // |account_id|: The user's account id.
// |url|: The wallpaper url. // |url|: The wallpaper url.
// |layout|: The layout of the wallpaper, used for wallpaper resizing. // |layout|: The layout of the wallpaper, used for wallpaper resizing.
// |preview_mode|: If true, show the wallpaper immediately but doesn't change // |preview_mode|: If true, show the wallpaper immediately but doesn't change
...@@ -92,7 +93,7 @@ class ASH_PUBLIC_EXPORT WallpaperController { ...@@ -92,7 +93,7 @@ class ASH_PUBLIC_EXPORT WallpaperController {
// error etc.). // error etc.).
using SetOnlineWallpaperFromDataCallback = base::OnceCallback<void(bool)>; using SetOnlineWallpaperFromDataCallback = base::OnceCallback<void(bool)>;
virtual void SetOnlineWallpaperFromData( virtual void SetOnlineWallpaperFromData(
const WallpaperUserInfo& user_info, const AccountId& account_id,
const std::string& image_data, const std::string& image_data,
const std::string& url, const std::string& url,
WallpaperLayout layout, WallpaperLayout layout,
...@@ -101,10 +102,11 @@ class ASH_PUBLIC_EXPORT WallpaperController { ...@@ -101,10 +102,11 @@ class ASH_PUBLIC_EXPORT WallpaperController {
// Sets the user's wallpaper to be the default wallpaper. Note: different user // Sets the user's wallpaper to be the default wallpaper. Note: different user
// types may have different default wallpapers. // types may have different default wallpapers.
// |wallpaper_files_id|: The file id for user_info.account_id. // |account_id|: The user's account id.
// |wallpaper_files_id|: The file id for |account_id|.
// |show_wallpaper|: If false, don't show the new wallpaper now but only // |show_wallpaper|: If false, don't show the new wallpaper now but only
// update cache. // update cache.
virtual void SetDefaultWallpaper(const WallpaperUserInfo& user_info, virtual void SetDefaultWallpaper(const AccountId& account_id,
const std::string& wallpaper_files_id, const std::string& wallpaper_files_id,
bool show_wallpaper) = 0; bool show_wallpaper) = 0;
...@@ -124,10 +126,10 @@ class ASH_PUBLIC_EXPORT WallpaperController { ...@@ -124,10 +126,10 @@ class ASH_PUBLIC_EXPORT WallpaperController {
// wallpaper immediately, otherwise, the policy wallpaper will be shown the // wallpaper immediately, otherwise, the policy wallpaper will be shown the
// next time |ShowUserWallpaper| is called. Note: it is different from device // next time |ShowUserWallpaper| is called. Note: it is different from device
// policy. // policy.
// |user_info|: The user's information related to wallpaper. // |account_id|: The user's account id.
// |wallpaper_files_id|: The file id for user_info.account_id. // |wallpaper_files_id|: The file id for |account_id|.
// |data|: The data used to decode the image. // |data|: The data used to decode the image.
virtual void SetPolicyWallpaper(const WallpaperUserInfo& user_info, virtual void SetPolicyWallpaper(const AccountId& account_id,
const std::string& wallpaper_files_id, const std::string& wallpaper_files_id,
const std::string& data) = 0; const std::string& data) = 0;
...@@ -140,15 +142,15 @@ class ASH_PUBLIC_EXPORT WallpaperController { ...@@ -140,15 +142,15 @@ class ASH_PUBLIC_EXPORT WallpaperController {
// Sets wallpaper from a third-party app (as opposed to the Chrome OS // Sets wallpaper from a third-party app (as opposed to the Chrome OS
// wallpaper picker). // wallpaper picker).
// |user_info|: The user's information related to wallpaper. // |account_id|: The user's account id.
// |wallpaper_files_id|: The file id for user_info.account_id. // |wallpaper_files_id|: The file id for |account_id|.
// |file_name|: The name of the wallpaper file. // |file_name|: The name of the wallpaper file.
// |layout|: The layout of the wallpaper, used for wallpaper resizing. // |layout|: The layout of the wallpaper, used for wallpaper resizing.
// |image|: The wallpaper image. // |image|: The wallpaper image.
// Returns if the wallpaper is allowed to be shown on screen. It's false if: // Returns if the wallpaper is allowed to be shown on screen. It's false if:
// 1) the user is not permitted to change wallpaper, or // 1) the user is not permitted to change wallpaper, or
// 2) updating the on-screen wallpaper is not allowed at the given moment. // 2) updating the on-screen wallpaper is not allowed at the given moment.
virtual bool SetThirdPartyWallpaper(const WallpaperUserInfo& user_info, virtual bool SetThirdPartyWallpaper(const AccountId& account_id,
const std::string& wallpaper_files_id, const std::string& wallpaper_files_id,
const std::string& file_name, const std::string& file_name,
WallpaperLayout layout, WallpaperLayout layout,
...@@ -164,9 +166,9 @@ class ASH_PUBLIC_EXPORT WallpaperController { ...@@ -164,9 +166,9 @@ class ASH_PUBLIC_EXPORT WallpaperController {
// Updates the layout for the user's custom wallpaper and reloads the // Updates the layout for the user's custom wallpaper and reloads the
// wallpaper with the new layout. // wallpaper with the new layout.
// |user_info|: The user's information related to wallpaper. // |account_id|: The user's account id.
// |layout|: The new layout of the wallpaper. // |layout|: The new layout of the wallpaper.
virtual void UpdateCustomWallpaperLayout(const WallpaperUserInfo& user_info, virtual void UpdateCustomWallpaperLayout(const AccountId& account_id,
WallpaperLayout layout) = 0; WallpaperLayout layout) = 0;
// Shows the user's wallpaper, which is determined in the following order: // Shows the user's wallpaper, which is determined in the following order:
...@@ -175,7 +177,7 @@ class ASH_PUBLIC_EXPORT WallpaperController { ...@@ -175,7 +177,7 @@ class ASH_PUBLIC_EXPORT WallpaperController {
// 3) Use the wallpaper set by the user (either by |SetOnlineWallpaper| or // 3) Use the wallpaper set by the user (either by |SetOnlineWallpaper| or
// |SetCustomWallpaper|), if any. // |SetCustomWallpaper|), if any.
// 4) Use the default wallpaper of this user. // 4) Use the default wallpaper of this user.
virtual void ShowUserWallpaper(const WallpaperUserInfo& user_info) = 0; virtual void ShowUserWallpaper(const AccountId& account_id) = 0;
// Used by the gaia-signin UI. Signin wallpaper is considered either as the // Used by the gaia-signin UI. Signin wallpaper is considered either as the
// device policy wallpaper or the default wallpaper. // device policy wallpaper or the default wallpaper.
...@@ -199,8 +201,9 @@ class ASH_PUBLIC_EXPORT WallpaperController { ...@@ -199,8 +201,9 @@ class ASH_PUBLIC_EXPORT WallpaperController {
virtual void RemoveAlwaysOnTopWallpaper() = 0; virtual void RemoveAlwaysOnTopWallpaper() = 0;
// Removes all of the user's saved wallpapers and related info. // Removes all of the user's saved wallpapers and related info.
// |wallpaper_files_id|: The file id for user_info.account_id. // |account_id|: The user's account id.
virtual void RemoveUserWallpaper(const WallpaperUserInfo& user_info, // |wallpaper_files_id|: The file id for |account_id|.
virtual void RemoveUserWallpaper(const AccountId& account_id,
const std::string& wallpaper_files_id) = 0; const std::string& wallpaper_files_id) = 0;
// Removes all of the user's saved wallpapers and related info if the // Removes all of the user's saved wallpapers and related info if the
...@@ -208,9 +211,9 @@ class ASH_PUBLIC_EXPORT WallpaperController { ...@@ -208,9 +211,9 @@ class ASH_PUBLIC_EXPORT WallpaperController {
// wallpaper to be the default. If the user has logged in, show the default // wallpaper to be the default. If the user has logged in, show the default
// wallpaper immediately, otherwise, the default wallpaper will be shown the // wallpaper immediately, otherwise, the default wallpaper will be shown the
// next time |ShowUserWallpaper| is called. // next time |ShowUserWallpaper| is called.
// |user_info|: The user's information related to wallpaper. // |account_id|: The user's account id.
// |wallpaper_files_id|: The file id for user_info.account_id. // |wallpaper_files_id|: The file id for |account_id|.
virtual void RemovePolicyWallpaper(const WallpaperUserInfo& user_info, virtual void RemovePolicyWallpaper(const AccountId& account_id,
const std::string& wallpaper_files_id) = 0; const std::string& wallpaper_files_id) = 0;
// Returns the urls of the wallpapers that exist in local file system (i.e. // Returns the urls of the wallpapers that exist in local file system (i.e.
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_PUBLIC_CPP_WALLPAPER_USER_INFO_H_
#define ASH_PUBLIC_CPP_WALLPAPER_USER_INFO_H_
#include "ash/public/cpp/ash_public_export.h"
#include "components/account_id/account_id.h"
#include "components/user_manager/user_type.h"
namespace ash {
// User info needed to set wallpapers. Clients must specify the user because
// it's not always the same as the active user, e.g., when showing wallpapers
// for different user pods at login screen, or setting wallpapers selectively
// for primary user and active user during a multi-profile session.
struct ASH_PUBLIC_EXPORT WallpaperUserInfo {
// The user's account id.
AccountId account_id = EmptyAccountId();
// The user type.
user_manager::UserType type = user_manager::USER_TYPE_REGULAR;
// True if the user's non-cryptohome data (wallpaper, avatar etc.) is
// ephemeral. See |UserManager::IsCurrentUserNonCryptohomeDataEphemeral| for
// more details.
bool is_ephemeral = false;
// True if the user has gaia account.
bool has_gaia_account = false;
};
} // namespace ash
#endif // ASH_PUBLIC_CPP_WALLPAPER_USER_INFO_H_
...@@ -373,25 +373,21 @@ void AshTestBase::CreateUserSessions(int n) { ...@@ -373,25 +373,21 @@ void AshTestBase::CreateUserSessions(int n) {
GetSessionControllerClient()->CreatePredefinedUserSessions(n); GetSessionControllerClient()->CreatePredefinedUserSessions(n);
} }
void AshTestBase::SimulateUserLogin(const std::string& user_email) { void AshTestBase::SimulateUserLogin(const std::string& user_email,
TestSessionControllerClient* const session_controller_client = user_manager::UserType user_type) {
GetSessionControllerClient(); TestSessionControllerClient* session = GetSessionControllerClient();
session_controller_client->AddUserSession(user_email); session->AddUserSession(user_email, user_type);
session_controller_client->SwitchActiveUser( session->SwitchActiveUser(AccountId::FromUserEmail(user_email));
AccountId::FromUserEmail(user_email)); session->SetSessionState(SessionState::ACTIVE);
session_controller_client->SetSessionState(SessionState::ACTIVE);
} }
void AshTestBase::SimulateNewUserFirstLogin(const std::string& user_email) { void AshTestBase::SimulateNewUserFirstLogin(const std::string& user_email) {
TestSessionControllerClient* const session_controller_client = TestSessionControllerClient* session = GetSessionControllerClient();
GetSessionControllerClient(); session->AddUserSession(
session_controller_client->AddUserSession(
user_email, user_manager::USER_TYPE_REGULAR, true /* enable_settings */, user_email, user_manager::USER_TYPE_REGULAR, true /* enable_settings */,
true /* provide_pref_service */, true /* is_new_profile */); true /* provide_pref_service */, true /* is_new_profile */);
session_controller_client->SwitchActiveUser( session->SwitchActiveUser(AccountId::FromUserEmail(user_email));
AccountId::FromUserEmail(user_email)); session->SetSessionState(session_manager::SessionState::ACTIVE);
session_controller_client->SetSessionState(
session_manager::SessionState::ACTIVE);
} }
void AshTestBase::SimulateGuestLogin() { void AshTestBase::SimulateGuestLogin() {
......
...@@ -205,7 +205,9 @@ class AshTestBase : public testing::Test { ...@@ -205,7 +205,9 @@ class AshTestBase : public testing::Test {
// Simulates a user sign-in. It creates a new user session, adds it to // Simulates a user sign-in. It creates a new user session, adds it to
// existing user sessions and makes it the active user session. // existing user sessions and makes it the active user session.
void SimulateUserLogin(const std::string& user_email); void SimulateUserLogin(
const std::string& user_email,
user_manager::UserType user_type = user_manager::USER_TYPE_REGULAR);
// Simular to SimulateUserLogin but for a newly created user first ever login. // Simular to SimulateUserLogin but for a newly created user first ever login.
void SimulateNewUserFirstLogin(const std::string& user_email); void SimulateNewUserFirstLogin(const std::string& user_email);
......
This diff is collapsed.
This diff is collapsed.
...@@ -47,8 +47,7 @@ void WallpaperControllerTestApi::StartWallpaperPreview() { ...@@ -47,8 +47,7 @@ void WallpaperControllerTestApi::StartWallpaperPreview() {
base::BindOnce(&WallpaperControllerImpl::SetWallpaperFromInfo, base::BindOnce(&WallpaperControllerImpl::SetWallpaperFromInfo,
controller_->weak_factory_.GetWeakPtr(), controller_->weak_factory_.GetWeakPtr(),
AccountId::FromUserEmail("user@test.com"), AccountId::FromUserEmail("user@test.com"),
user_manager::USER_TYPE_REGULAR, kTestWallpaperInfo, kTestWallpaperInfo, /*show_wallpaper=*/true);
/*show_wallpaper=*/true);
controller_->reload_preview_wallpaper_callback_ = base::BindRepeating( controller_->reload_preview_wallpaper_callback_ = base::BindRepeating(
&WallpaperControllerImpl::ShowWallpaperImage, &WallpaperControllerImpl::ShowWallpaperImage,
controller_->weak_factory_.GetWeakPtr(), controller_->weak_factory_.GetWeakPtr(),
......
...@@ -34,7 +34,7 @@ void TestWallpaperController::Init( ...@@ -34,7 +34,7 @@ void TestWallpaperController::Init(
} }
void TestWallpaperController::SetCustomWallpaper( void TestWallpaperController::SetCustomWallpaper(
const ash::WallpaperUserInfo& user_info, const AccountId& account_id,
const std::string& wallpaper_files_id, const std::string& wallpaper_files_id,
const std::string& file_name, const std::string& file_name,
ash::WallpaperLayout layout, ash::WallpaperLayout layout,
...@@ -44,7 +44,7 @@ void TestWallpaperController::SetCustomWallpaper( ...@@ -44,7 +44,7 @@ void TestWallpaperController::SetCustomWallpaper(
} }
void TestWallpaperController::SetOnlineWallpaperIfExists( void TestWallpaperController::SetOnlineWallpaperIfExists(
const ash::WallpaperUserInfo& user_info, const AccountId& account_id,
const std::string& url, const std::string& url,
ash::WallpaperLayout layout, ash::WallpaperLayout layout,
bool preview_mode, bool preview_mode,
...@@ -53,7 +53,7 @@ void TestWallpaperController::SetOnlineWallpaperIfExists( ...@@ -53,7 +53,7 @@ void TestWallpaperController::SetOnlineWallpaperIfExists(
} }
void TestWallpaperController::SetOnlineWallpaperFromData( void TestWallpaperController::SetOnlineWallpaperFromData(
const ash::WallpaperUserInfo& user_info, const AccountId& account_id,
const std::string& image_data, const std::string& image_data,
const std::string& url, const std::string& url,
ash::WallpaperLayout layout, ash::WallpaperLayout layout,
...@@ -63,7 +63,7 @@ void TestWallpaperController::SetOnlineWallpaperFromData( ...@@ -63,7 +63,7 @@ void TestWallpaperController::SetOnlineWallpaperFromData(
} }
void TestWallpaperController::SetDefaultWallpaper( void TestWallpaperController::SetDefaultWallpaper(
const ash::WallpaperUserInfo& user_info, const AccountId& account_id,
const std::string& wallpaper_files_id, const std::string& wallpaper_files_id,
bool show_wallpaper) { bool show_wallpaper) {
++set_default_wallpaper_count_; ++set_default_wallpaper_count_;
...@@ -76,7 +76,7 @@ void TestWallpaperController::SetCustomizedDefaultWallpaperPaths( ...@@ -76,7 +76,7 @@ void TestWallpaperController::SetCustomizedDefaultWallpaperPaths(
} }
void TestWallpaperController::SetPolicyWallpaper( void TestWallpaperController::SetPolicyWallpaper(
const ash::WallpaperUserInfo& user_info, const AccountId& account_id,
const std::string& wallpaper_files_id, const std::string& wallpaper_files_id,
const std::string& data) { const std::string& data) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
...@@ -88,7 +88,7 @@ void TestWallpaperController::SetDevicePolicyWallpaperPath( ...@@ -88,7 +88,7 @@ void TestWallpaperController::SetDevicePolicyWallpaperPath(
} }
bool TestWallpaperController::SetThirdPartyWallpaper( bool TestWallpaperController::SetThirdPartyWallpaper(
const ash::WallpaperUserInfo& user_info, const AccountId& account_id,
const std::string& wallpaper_files_id, const std::string& wallpaper_files_id,
const std::string& file_name, const std::string& file_name,
ash::WallpaperLayout layout, ash::WallpaperLayout layout,
...@@ -106,13 +106,12 @@ void TestWallpaperController::CancelPreviewWallpaper() { ...@@ -106,13 +106,12 @@ void TestWallpaperController::CancelPreviewWallpaper() {
} }
void TestWallpaperController::UpdateCustomWallpaperLayout( void TestWallpaperController::UpdateCustomWallpaperLayout(
const ash::WallpaperUserInfo& user_info, const AccountId& account_id,
ash::WallpaperLayout layout) { ash::WallpaperLayout layout) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
void TestWallpaperController::ShowUserWallpaper( void TestWallpaperController::ShowUserWallpaper(const AccountId& account_id) {
const ash::WallpaperUserInfo& user_info) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
...@@ -135,13 +134,13 @@ void TestWallpaperController::RemoveAlwaysOnTopWallpaper() { ...@@ -135,13 +134,13 @@ void TestWallpaperController::RemoveAlwaysOnTopWallpaper() {
} }
void TestWallpaperController::RemoveUserWallpaper( void TestWallpaperController::RemoveUserWallpaper(
const ash::WallpaperUserInfo& user_info, const AccountId& account_id,
const std::string& wallpaper_files_id) { const std::string& wallpaper_files_id) {
++remove_user_wallpaper_count_; ++remove_user_wallpaper_count_;
} }
void TestWallpaperController::RemovePolicyWallpaper( void TestWallpaperController::RemovePolicyWallpaper(
const ash::WallpaperUserInfo& user_info, const AccountId& account_id,
const std::string& wallpaper_files_id) { const std::string& wallpaper_files_id) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
......
...@@ -42,53 +42,53 @@ class TestWallpaperController : public ash::WallpaperController { ...@@ -42,53 +42,53 @@ class TestWallpaperController : public ash::WallpaperController {
const base::FilePath& wallpapers, const base::FilePath& wallpapers,
const base::FilePath& custom_wallpapers, const base::FilePath& custom_wallpapers,
const base::FilePath& device_policy_wallpaper) override; const base::FilePath& device_policy_wallpaper) override;
void SetCustomWallpaper(const ash::WallpaperUserInfo& user_info, void SetCustomWallpaper(const AccountId& account_id,
const std::string& wallpaper_files_id, const std::string& wallpaper_files_id,
const std::string& file_name, const std::string& file_name,
ash::WallpaperLayout layout, ash::WallpaperLayout layout,
const gfx::ImageSkia& image, const gfx::ImageSkia& image,
bool preview_mode) override; bool preview_mode) override;
void SetOnlineWallpaperIfExists( void SetOnlineWallpaperIfExists(
const ash::WallpaperUserInfo& user_info, const AccountId& account_id,
const std::string& url, const std::string& url,
ash::WallpaperLayout layout, ash::WallpaperLayout layout,
bool preview_mode, bool preview_mode,
SetOnlineWallpaperIfExistsCallback callback) override; SetOnlineWallpaperIfExistsCallback callback) override;
void SetOnlineWallpaperFromData( void SetOnlineWallpaperFromData(
const ash::WallpaperUserInfo& user_info, const AccountId& account_id,
const std::string& image_data, const std::string& image_data,
const std::string& url, const std::string& url,
ash::WallpaperLayout layout, ash::WallpaperLayout layout,
bool preview_mode, bool preview_mode,
SetOnlineWallpaperFromDataCallback callback) override; SetOnlineWallpaperFromDataCallback callback) override;
void SetDefaultWallpaper(const ash::WallpaperUserInfo& user_info, void SetDefaultWallpaper(const AccountId& account_id,
const std::string& wallpaper_files_id, const std::string& wallpaper_files_id,
bool show_wallpaper) override; bool show_wallpaper) override;
void SetCustomizedDefaultWallpaperPaths( void SetCustomizedDefaultWallpaperPaths(
const base::FilePath& customized_default_small_path, const base::FilePath& customized_default_small_path,
const base::FilePath& customized_default_large_path) override; const base::FilePath& customized_default_large_path) override;
void SetPolicyWallpaper(const ash::WallpaperUserInfo& user_info, void SetPolicyWallpaper(const AccountId& account_id,
const std::string& wallpaper_files_id, const std::string& wallpaper_files_id,
const std::string& data) override; const std::string& data) override;
void SetDevicePolicyWallpaperPath( void SetDevicePolicyWallpaperPath(
const base::FilePath& device_policy_wallpaper_path) override; const base::FilePath& device_policy_wallpaper_path) override;
bool SetThirdPartyWallpaper(const ash::WallpaperUserInfo& user_info, bool SetThirdPartyWallpaper(const AccountId& account_id,
const std::string& wallpaper_files_id, const std::string& wallpaper_files_id,
const std::string& file_name, const std::string& file_name,
ash::WallpaperLayout layout, ash::WallpaperLayout layout,
const gfx::ImageSkia& image) override; const gfx::ImageSkia& image) override;
void ConfirmPreviewWallpaper() override; void ConfirmPreviewWallpaper() override;
void CancelPreviewWallpaper() override; void CancelPreviewWallpaper() override;
void UpdateCustomWallpaperLayout(const ash::WallpaperUserInfo& user_info, void UpdateCustomWallpaperLayout(const AccountId& account_id,
ash::WallpaperLayout layout) override; ash::WallpaperLayout layout) override;
void ShowUserWallpaper(const ash::WallpaperUserInfo& user_info) override; void ShowUserWallpaper(const AccountId& account_id) override;
void ShowSigninWallpaper() override; void ShowSigninWallpaper() override;
void ShowOneShotWallpaper(const gfx::ImageSkia& image) override; void ShowOneShotWallpaper(const gfx::ImageSkia& image) override;
void ShowAlwaysOnTopWallpaper(const base::FilePath& image_path) override; void ShowAlwaysOnTopWallpaper(const base::FilePath& image_path) override;
void RemoveAlwaysOnTopWallpaper() override; void RemoveAlwaysOnTopWallpaper() override;
void RemoveUserWallpaper(const ash::WallpaperUserInfo& user_info, void RemoveUserWallpaper(const AccountId& account_id,
const std::string& wallpaper_files_id) override; const std::string& wallpaper_files_id) override;
void RemovePolicyWallpaper(const ash::WallpaperUserInfo& user_info, void RemovePolicyWallpaper(const AccountId& account_id,
const std::string& wallpaper_files_id) override; const std::string& wallpaper_files_id) override;
void GetOfflineWallpaperList( void GetOfflineWallpaperList(
GetOfflineWallpaperListCallback callback) override; GetOfflineWallpaperListCallback callback) override;
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "chrome/browser/ui/ash/wallpaper_controller_client.h" #include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "ash/public/cpp/wallpaper_user_info.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/hash/sha1.h" #include "base/hash/sha1.h"
#include "base/path_service.h" #include "base/path_service.h"
...@@ -40,28 +39,8 @@ const char kWallpaperFilesId[] = "wallpaper-files-id"; ...@@ -40,28 +39,8 @@ const char kWallpaperFilesId[] = "wallpaper-files-id";
WallpaperControllerClient* g_wallpaper_controller_client_instance = nullptr; WallpaperControllerClient* g_wallpaper_controller_client_instance = nullptr;
// Creates a WallpaperUserInfo for the account id. Returns nullptr if user bool IsKnownUser(const AccountId& account_id) {
// manager cannot find the user. return user_manager::UserManager::Get()->IsKnownUser(account_id);
base::Optional<ash::WallpaperUserInfo> AccountIdToWallpaperUserInfo(
const AccountId& account_id) {
if (!account_id.is_valid()) {
// |account_id| may be invalid in tests.
return base::nullopt;
}
const user_manager::User* user =
user_manager::UserManager::Get()->FindUser(account_id);
if (!user)
return base::nullopt;
ash::WallpaperUserInfo wallpaper_user_info;
wallpaper_user_info.account_id = account_id;
wallpaper_user_info.type = user->GetType();
wallpaper_user_info.is_ephemeral =
user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral(
account_id);
wallpaper_user_info.has_gaia_account = user->HasGaiaAccount();
return wallpaper_user_info;
} }
// This has once been copied from // This has once been copied from
...@@ -198,12 +177,10 @@ void WallpaperControllerClient::SetCustomWallpaper( ...@@ -198,12 +177,10 @@ void WallpaperControllerClient::SetCustomWallpaper(
ash::WallpaperLayout layout, ash::WallpaperLayout layout,
const gfx::ImageSkia& image, const gfx::ImageSkia& image,
bool preview_mode) { bool preview_mode) {
auto user_info = AccountIdToWallpaperUserInfo(account_id); if (!IsKnownUser(account_id))
if (!user_info)
return; return;
wallpaper_controller_->SetCustomWallpaper(user_info.value(), wallpaper_controller_->SetCustomWallpaper(
wallpaper_files_id, file_name, account_id, wallpaper_files_id, file_name, layout, image, preview_mode);
layout, image, preview_mode);
} }
void WallpaperControllerClient::SetOnlineWallpaperIfExists( void WallpaperControllerClient::SetOnlineWallpaperIfExists(
...@@ -212,11 +189,10 @@ void WallpaperControllerClient::SetOnlineWallpaperIfExists( ...@@ -212,11 +189,10 @@ void WallpaperControllerClient::SetOnlineWallpaperIfExists(
ash::WallpaperLayout layout, ash::WallpaperLayout layout,
bool preview_mode, bool preview_mode,
ash::WallpaperController::SetOnlineWallpaperIfExistsCallback callback) { ash::WallpaperController::SetOnlineWallpaperIfExistsCallback callback) {
auto user_info = AccountIdToWallpaperUserInfo(account_id); if (!IsKnownUser(account_id))
if (!user_info)
return; return;
wallpaper_controller_->SetOnlineWallpaperIfExists( wallpaper_controller_->SetOnlineWallpaperIfExists(
user_info.value(), url, layout, preview_mode, std::move(callback)); account_id, url, layout, preview_mode, std::move(callback));
} }
void WallpaperControllerClient::SetOnlineWallpaperFromData( void WallpaperControllerClient::SetOnlineWallpaperFromData(
...@@ -226,18 +202,15 @@ void WallpaperControllerClient::SetOnlineWallpaperFromData( ...@@ -226,18 +202,15 @@ void WallpaperControllerClient::SetOnlineWallpaperFromData(
ash::WallpaperLayout layout, ash::WallpaperLayout layout,
bool preview_mode, bool preview_mode,
ash::WallpaperController::SetOnlineWallpaperFromDataCallback callback) { ash::WallpaperController::SetOnlineWallpaperFromDataCallback callback) {
auto user_info = AccountIdToWallpaperUserInfo(account_id); if (!IsKnownUser(account_id))
if (!user_info)
return; return;
wallpaper_controller_->SetOnlineWallpaperFromData( wallpaper_controller_->SetOnlineWallpaperFromData(
user_info.value(), image_data, url, layout, preview_mode, account_id, image_data, url, layout, preview_mode, std::move(callback));
std::move(callback));
} }
void WallpaperControllerClient::SetDefaultWallpaper(const AccountId& account_id, void WallpaperControllerClient::SetDefaultWallpaper(const AccountId& account_id,
bool show_wallpaper) { bool show_wallpaper) {
auto user_info = AccountIdToWallpaperUserInfo(account_id); if (!IsKnownUser(account_id))
if (!user_info)
return; return;
// Postpone setting the wallpaper until we can get files id. // Postpone setting the wallpaper until we can get files id.
...@@ -251,8 +224,8 @@ void WallpaperControllerClient::SetDefaultWallpaper(const AccountId& account_id, ...@@ -251,8 +224,8 @@ void WallpaperControllerClient::SetDefaultWallpaper(const AccountId& account_id,
return; return;
} }
wallpaper_controller_->SetDefaultWallpaper( wallpaper_controller_->SetDefaultWallpaper(account_id, GetFilesId(account_id),
user_info.value(), GetFilesId(account_id), show_wallpaper); show_wallpaper);
} }
void WallpaperControllerClient::SetCustomizedDefaultWallpaperPaths( void WallpaperControllerClient::SetCustomizedDefaultWallpaperPaths(
...@@ -265,11 +238,7 @@ void WallpaperControllerClient::SetCustomizedDefaultWallpaperPaths( ...@@ -265,11 +238,7 @@ void WallpaperControllerClient::SetCustomizedDefaultWallpaperPaths(
void WallpaperControllerClient::SetPolicyWallpaper( void WallpaperControllerClient::SetPolicyWallpaper(
const AccountId& account_id, const AccountId& account_id,
std::unique_ptr<std::string> data) { std::unique_ptr<std::string> data) {
if (!data) if (!data || !IsKnownUser(account_id))
return;
auto user_info = AccountIdToWallpaperUserInfo(account_id);
if (!user_info)
return; return;
// Postpone setting the wallpaper until we can get files id. See // Postpone setting the wallpaper until we can get files id. See
...@@ -281,8 +250,8 @@ void WallpaperControllerClient::SetPolicyWallpaper( ...@@ -281,8 +250,8 @@ void WallpaperControllerClient::SetPolicyWallpaper(
return; return;
} }
wallpaper_controller_->SetPolicyWallpaper(user_info.value(), wallpaper_controller_->SetPolicyWallpaper(account_id, GetFilesId(account_id),
GetFilesId(account_id), *data); *data);
} }
bool WallpaperControllerClient::SetThirdPartyWallpaper( bool WallpaperControllerClient::SetThirdPartyWallpaper(
...@@ -291,11 +260,9 @@ bool WallpaperControllerClient::SetThirdPartyWallpaper( ...@@ -291,11 +260,9 @@ bool WallpaperControllerClient::SetThirdPartyWallpaper(
const std::string& file_name, const std::string& file_name,
ash::WallpaperLayout layout, ash::WallpaperLayout layout,
const gfx::ImageSkia& image) { const gfx::ImageSkia& image) {
auto user_info = AccountIdToWallpaperUserInfo(account_id); return IsKnownUser(account_id) &&
if (!user_info) wallpaper_controller_->SetThirdPartyWallpaper(
return false; account_id, wallpaper_files_id, file_name, layout, image);
return wallpaper_controller_->SetThirdPartyWallpaper(
user_info.value(), wallpaper_files_id, file_name, layout, image);
} }
void WallpaperControllerClient::ConfirmPreviewWallpaper() { void WallpaperControllerClient::ConfirmPreviewWallpaper() {
...@@ -309,17 +276,13 @@ void WallpaperControllerClient::CancelPreviewWallpaper() { ...@@ -309,17 +276,13 @@ void WallpaperControllerClient::CancelPreviewWallpaper() {
void WallpaperControllerClient::UpdateCustomWallpaperLayout( void WallpaperControllerClient::UpdateCustomWallpaperLayout(
const AccountId& account_id, const AccountId& account_id,
ash::WallpaperLayout layout) { ash::WallpaperLayout layout) {
auto user_info = AccountIdToWallpaperUserInfo(account_id); if (IsKnownUser(account_id))
if (!user_info) wallpaper_controller_->UpdateCustomWallpaperLayout(account_id, layout);
return;
wallpaper_controller_->UpdateCustomWallpaperLayout(user_info.value(), layout);
} }
void WallpaperControllerClient::ShowUserWallpaper(const AccountId& account_id) { void WallpaperControllerClient::ShowUserWallpaper(const AccountId& account_id) {
auto user_info = AccountIdToWallpaperUserInfo(account_id); if (IsKnownUser(account_id))
if (!user_info) wallpaper_controller_->ShowUserWallpaper(account_id);
return;
wallpaper_controller_->ShowUserWallpaper(user_info.value());
} }
void WallpaperControllerClient::ShowSigninWallpaper() { void WallpaperControllerClient::ShowSigninWallpaper() {
...@@ -337,8 +300,7 @@ void WallpaperControllerClient::RemoveAlwaysOnTopWallpaper() { ...@@ -337,8 +300,7 @@ void WallpaperControllerClient::RemoveAlwaysOnTopWallpaper() {
void WallpaperControllerClient::RemoveUserWallpaper( void WallpaperControllerClient::RemoveUserWallpaper(
const AccountId& account_id) { const AccountId& account_id) {
auto user_info = AccountIdToWallpaperUserInfo(account_id); if (!IsKnownUser(account_id))
if (!user_info)
return; return;
// Postpone removing the wallpaper until we can get files id. // Postpone removing the wallpaper until we can get files id.
...@@ -352,14 +314,13 @@ void WallpaperControllerClient::RemoveUserWallpaper( ...@@ -352,14 +314,13 @@ void WallpaperControllerClient::RemoveUserWallpaper(
return; return;
} }
wallpaper_controller_->RemoveUserWallpaper(user_info.value(), wallpaper_controller_->RemoveUserWallpaper(account_id,
GetFilesId(account_id)); GetFilesId(account_id));
} }
void WallpaperControllerClient::RemovePolicyWallpaper( void WallpaperControllerClient::RemovePolicyWallpaper(
const AccountId& account_id) { const AccountId& account_id) {
auto user_info = AccountIdToWallpaperUserInfo(account_id); if (!IsKnownUser(account_id))
if (!user_info)
return; return;
// Postpone removing the wallpaper until we can get files id. // Postpone removing the wallpaper until we can get files id.
...@@ -373,7 +334,7 @@ void WallpaperControllerClient::RemovePolicyWallpaper( ...@@ -373,7 +334,7 @@ void WallpaperControllerClient::RemovePolicyWallpaper(
return; return;
} }
wallpaper_controller_->RemovePolicyWallpaper(user_info.value(), wallpaper_controller_->RemovePolicyWallpaper(account_id,
GetFilesId(account_id)); GetFilesId(account_id));
} }
......
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