Commit 7f67c48f authored by Wenzhao Zang's avatar Wenzhao Zang Committed by Commit Bot

cros: Smoothen the transition between boot splash and full-screen OOBE

1) The full-screen white background in OOBE is rendered in web-ui, so
   there's a delay showing it. Users will see a glimpse of the default
   wallpaper (it's blue on an eve) between the boot splash screen
   and the OOBE screen (both white). To avoid this, we can show a white
   wallpaper during the entire OOBE screen, which can show right after
   the boot splash seamlessly.

2) The original idea was to delay the dismissal of the boot splash
   screen until OOBE dialog is ready. However, boot splash screen will
   not always show (e.g. when a guest user exits, or browser crash and
   restart). In such cases, we also want to avoid showing the blue
   default wallpaper before the white OOBE screen is loaded. Therefore,
   showing a white wallpaper is a better solution.

Bug: 872936
Change-Id: Iaa600f9d455956743a6cfd3dd26f07ad2a4ed61d
Reviewed-on: https://chromium-review.googlesource.com/1172066Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarOliver Chang <ochang@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Wenzhao (Colin) Zang <wzang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583154}
parent 0366e7e4
...@@ -57,7 +57,12 @@ enum WallpaperType { ...@@ -57,7 +57,12 @@ enum WallpaperType {
DEVICE = 7, // Current wallpaper is the device policy controlled DEVICE = 7, // Current wallpaper is the device policy controlled
// wallpaper. It shows on the login screen if the device // wallpaper. It shows on the login screen if the device
// is an enterprise managed device. // is an enterprise managed device.
WALLPAPER_TYPE_COUNT = 8 ONE_SHOT = 8, // Current wallpaper is shown one-time only, which doesn't
// belong to a particular user and isn't saved to file. It
// goes away when another wallpaper is shown or the browser
// process exits. Note: the image will never be blurred or
// dimmed.
WALLPAPER_TYPE_COUNT = 9
}; };
// The color profile type, ordered as the color profiles applied in // The color profile type, ordered as the color profiles applied in
......
...@@ -199,6 +199,12 @@ interface WallpaperController { ...@@ -199,6 +199,12 @@ interface WallpaperController {
// device policy wallpaper or the default wallpaper. // device policy wallpaper or the default wallpaper.
ShowSigninWallpaper(); ShowSigninWallpaper();
// Shows a one-shot wallpaper, which does not belong to any particular user
// and is not saved to file. Note: the wallpaper will never be dimmed or
// blurred because it's assumed that the caller wants to show the image as is
// when using this method.
ShowOneShotWallpaper(gfx.mojom.ImageSkia image);
// 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. // |wallpaper_files_id|: The file id for user_info.account_id.
RemoveUserWallpaper(WallpaperUserInfo user_info, string wallpaper_files_id); RemoveUserWallpaper(WallpaperUserInfo user_info, string wallpaper_files_id);
......
...@@ -234,11 +234,11 @@ bool ResizeAndSaveWallpaper(const gfx::ImageSkia& image, ...@@ -234,11 +234,11 @@ bool ResizeAndSaveWallpaper(const gfx::ImageSkia& image,
return written_bytes == data->size(); return written_bytes == data->size();
} }
// Creates a 1x1 solid color image to be used as the backup default wallpaper. // Creates a 1x1 solid color image.
gfx::ImageSkia CreateSolidColorWallpaper() { gfx::ImageSkia CreateSolidColorWallpaper(SkColor color) {
SkBitmap bitmap; SkBitmap bitmap;
bitmap.allocN32Pixels(1, 1); bitmap.allocN32Pixels(1, 1);
bitmap.eraseColor(kDefaultWallpaperColor); bitmap.eraseColor(color);
return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
} }
...@@ -728,12 +728,13 @@ void WallpaperController::UpdateWallpaperBlur(bool blur) { ...@@ -728,12 +728,13 @@ void WallpaperController::UpdateWallpaperBlur(bool blur) {
bool WallpaperController::ShouldApplyDimming() const { bool WallpaperController::ShouldApplyDimming() const {
return Shell::Get()->session_controller()->IsUserSessionBlocked() && return Shell::Get()->session_controller()->IsUserSessionBlocked() &&
!IsOneShotWallpaper() &&
!base::CommandLine::ForCurrentProcess()->HasSwitch( !base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshDisableLoginDimAndBlur); switches::kAshDisableLoginDimAndBlur);
} }
bool WallpaperController::IsBlurAllowed() const { bool WallpaperController::IsBlurAllowed() const {
return !IsDevicePolicyWallpaper() && return !IsDevicePolicyWallpaper() && !IsOneShotWallpaper() &&
!base::CommandLine::ForCurrentProcess()->HasSwitch( !base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshDisableLoginDimAndBlur); switches::kAshDisableLoginDimAndBlur);
} }
...@@ -955,7 +956,8 @@ void WallpaperController::SetOnlineWallpaperFromData( ...@@ -955,7 +956,8 @@ void WallpaperController::SetOnlineWallpaperFromData(
weak_factory_.GetWeakPtr(), params, /*save_file=*/true, weak_factory_.GetWeakPtr(), params, /*save_file=*/true,
std::move(callback)); std::move(callback));
if (bypass_decode_for_testing_) { if (bypass_decode_for_testing_) {
std::move(decoded_callback).Run(CreateSolidColorWallpaper()); std::move(decoded_callback)
.Run(CreateSolidColorWallpaper(kDefaultWallpaperColor));
return; return;
} }
// Use default codec because 1) online wallpapers may have various formats, // Use default codec because 1) online wallpapers may have various formats,
...@@ -1020,7 +1022,7 @@ void WallpaperController::SetPolicyWallpaper( ...@@ -1020,7 +1022,7 @@ void WallpaperController::SetPolicyWallpaper(
POLICY, WALLPAPER_LAYOUT_CENTER_CROPPED, show_wallpaper); POLICY, WALLPAPER_LAYOUT_CENTER_CROPPED, show_wallpaper);
if (bypass_decode_for_testing_) { if (bypass_decode_for_testing_) {
std::move(callback).Run(CreateSolidColorWallpaper()); std::move(callback).Run(CreateSolidColorWallpaper(kDefaultWallpaperColor));
return; return;
} }
// The default codec cannot be used here because the image data is provided by // The default codec cannot be used here because the image data is provided by
...@@ -1211,6 +1213,13 @@ void WallpaperController::ShowSigninWallpaper() { ...@@ -1211,6 +1213,13 @@ void WallpaperController::ShowSigninWallpaper() {
} }
} }
void WallpaperController::ShowOneShotWallpaper(const gfx::ImageSkia& image) {
const WallpaperInfo info = {
std::string(), WallpaperLayout::WALLPAPER_LAYOUT_STRETCH,
WallpaperType::ONE_SHOT, base::Time::Now().LocalMidnight()};
ShowWallpaperImage(image, info, /*preview_mode=*/false);
}
void WallpaperController::RemoveUserWallpaper( void WallpaperController::RemoveUserWallpaper(
mojom::WallpaperUserInfoPtr user_info, mojom::WallpaperUserInfoPtr user_info,
const std::string& wallpaper_files_id) { const std::string& wallpaper_files_id) {
...@@ -1625,7 +1634,7 @@ void WallpaperController::ReadAndDecodeWallpaper( ...@@ -1625,7 +1634,7 @@ void WallpaperController::ReadAndDecodeWallpaper(
const base::FilePath& file_path) { const base::FilePath& file_path) {
decode_requests_for_testing_.push_back(file_path); decode_requests_for_testing_.push_back(file_path);
if (bypass_decode_for_testing_) { if (bypass_decode_for_testing_) {
std::move(callback).Run(CreateSolidColorWallpaper()); std::move(callback).Run(CreateSolidColorWallpaper(kDefaultWallpaperColor));
return; return;
} }
std::string* data = new std::string; std::string* data = new std::string;
...@@ -1783,7 +1792,8 @@ void WallpaperController::OnDefaultWallpaperDecoded( ...@@ -1783,7 +1792,8 @@ void WallpaperController::OnDefaultWallpaperDecoded(
const gfx::ImageSkia& image) { const gfx::ImageSkia& image) {
if (image.isNull()) { if (image.isNull()) {
// Create a solid color wallpaper if the default wallpaper decoding fails. // Create a solid color wallpaper if the default wallpaper decoding fails.
cached_default_wallpaper_.image = CreateSolidColorWallpaper(); cached_default_wallpaper_.image =
CreateSolidColorWallpaper(kDefaultWallpaperColor);
cached_default_wallpaper_.file_path.clear(); cached_default_wallpaper_.file_path.clear();
} else { } else {
cached_default_wallpaper_.image = image; cached_default_wallpaper_.image = image;
...@@ -2006,6 +2016,11 @@ bool WallpaperController::IsDevicePolicyWallpaper() const { ...@@ -2006,6 +2016,11 @@ bool WallpaperController::IsDevicePolicyWallpaper() const {
current_wallpaper_->wallpaper_info().type == WallpaperType::DEVICE; current_wallpaper_->wallpaper_info().type == WallpaperType::DEVICE;
} }
bool WallpaperController::IsOneShotWallpaper() const {
return current_wallpaper_ &&
current_wallpaper_->wallpaper_info().type == WallpaperType::ONE_SHOT;
}
bool WallpaperController::ShouldSetDevicePolicyWallpaper() const { bool WallpaperController::ShouldSetDevicePolicyWallpaper() const {
// Only allow the device wallpaper if the policy is in effect for enterprise // Only allow the device wallpaper if the policy is in effect for enterprise
// managed devices. // managed devices.
......
...@@ -254,6 +254,7 @@ class ASH_EXPORT WallpaperController : public mojom::WallpaperController, ...@@ -254,6 +254,7 @@ class ASH_EXPORT WallpaperController : public mojom::WallpaperController,
WallpaperLayout layout) override; WallpaperLayout layout) override;
void ShowUserWallpaper(mojom::WallpaperUserInfoPtr user_info) override; void ShowUserWallpaper(mojom::WallpaperUserInfoPtr user_info) override;
void ShowSigninWallpaper() override; void ShowSigninWallpaper() override;
void ShowOneShotWallpaper(const gfx::ImageSkia& image) override;
void RemoveUserWallpaper(mojom::WallpaperUserInfoPtr user_info, void RemoveUserWallpaper(mojom::WallpaperUserInfoPtr user_info,
const std::string& wallpaper_files_id) override; const std::string& wallpaper_files_id) override;
void RemovePolicyWallpaper(mojom::WallpaperUserInfoPtr user_info, void RemovePolicyWallpaper(mojom::WallpaperUserInfoPtr user_info,
...@@ -503,6 +504,9 @@ class ASH_EXPORT WallpaperController : public mojom::WallpaperController, ...@@ -503,6 +504,9 @@ class ASH_EXPORT WallpaperController : public mojom::WallpaperController,
// Returns whether the current wallpaper is set by device policy. // Returns whether the current wallpaper is set by device policy.
bool IsDevicePolicyWallpaper() const; bool IsDevicePolicyWallpaper() const;
// Returns whether the current wallpaper has type of ONE_SHOT.
bool IsOneShotWallpaper() const;
// Returns true if device wallpaper policy is in effect and we are at the // Returns true if device wallpaper policy is in effect and we are at the
// login screen right now. // login screen right now.
bool ShouldSetDevicePolicyWallpaper() const; bool ShouldSetDevicePolicyWallpaper() const;
......
...@@ -2312,6 +2312,53 @@ TEST_F(WallpaperControllerTest, AddFirstWallpaperAnimationEndCallback) { ...@@ -2312,6 +2312,53 @@ TEST_F(WallpaperControllerTest, AddFirstWallpaperAnimationEndCallback) {
EXPECT_TRUE(is_third_callback_run); EXPECT_TRUE(is_third_callback_run);
} }
TEST_F(WallpaperControllerTest, ShowOneShotWallpaper) {
gfx::ImageSkia custom_wallpaper = CreateImage(640, 480, kWallpaperColor);
WallpaperLayout layout = WALLPAPER_LAYOUT_CENTER;
SimulateUserLogin(kUser1);
// First, set a custom wallpaper for |kUser1|. Verify the wallpaper is shown
// successfully and the user wallpaper info is updated.
controller_->SetCustomWallpaper(InitializeUser(account_id_1),
wallpaper_files_id_1, file_name_1, layout,
custom_wallpaper, false /*preview_mode=*/);
RunAllTasksUntilIdle();
EXPECT_EQ(1, GetWallpaperCount());
EXPECT_EQ(kWallpaperColor, GetWallpaperColor());
EXPECT_EQ(WallpaperType::CUSTOMIZED, controller_->GetWallpaperType());
const WallpaperInfo expected_wallpaper_info(
base::FilePath(wallpaper_files_id_1).Append(file_name_1).value(), layout,
WallpaperType::CUSTOMIZED, base::Time::Now().LocalMidnight());
WallpaperInfo wallpaper_info;
EXPECT_TRUE(controller_->GetUserWallpaperInfo(account_id_1, &wallpaper_info,
false /*is_ephemeral=*/));
EXPECT_EQ(expected_wallpaper_info, wallpaper_info);
// Show a one-shot wallpaper. Verify it is shown successfully.
ClearWallpaperCount();
constexpr SkColor kOneShotWallpaperColor = SK_ColorWHITE;
gfx::ImageSkia one_shot_wallpaper =
CreateImage(640, 480, kOneShotWallpaperColor);
controller_->ShowOneShotWallpaper(one_shot_wallpaper);
RunAllTasksUntilIdle();
EXPECT_EQ(1, GetWallpaperCount());
EXPECT_EQ(kOneShotWallpaperColor, GetWallpaperColor());
EXPECT_EQ(WallpaperType::ONE_SHOT, controller_->GetWallpaperType());
EXPECT_FALSE(controller_->IsBlurAllowed());
EXPECT_FALSE(controller_->ShouldApplyDimming());
// Verify the user wallpaper info is unaffected, and the one-shot wallpaper
// can be replaced by the user wallpaper.
EXPECT_TRUE(controller_->GetUserWallpaperInfo(account_id_1, &wallpaper_info,
false /*is_ephemeral=*/));
EXPECT_EQ(expected_wallpaper_info, wallpaper_info);
ClearWallpaperCount();
controller_->ShowUserWallpaper(InitializeUser(account_id_1));
RunAllTasksUntilIdle();
EXPECT_EQ(1, GetWallpaperCount());
EXPECT_EQ(kWallpaperColor, GetWallpaperColor());
EXPECT_EQ(WallpaperType::CUSTOMIZED, controller_->GetWallpaperType());
}
// A test wallpaper controller client class. // A test wallpaper controller client class.
class TestWallpaperControllerClient : public mojom::WallpaperControllerClient { class TestWallpaperControllerClient : public mojom::WallpaperControllerClient {
public: public:
......
...@@ -126,6 +126,11 @@ void TestWallpaperController::ShowSigninWallpaper() { ...@@ -126,6 +126,11 @@ void TestWallpaperController::ShowSigninWallpaper() {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
void TestWallpaperController::ShowOneShotWallpaper(
const gfx::ImageSkia& image) {
NOTIMPLEMENTED();
}
void TestWallpaperController::RemoveUserWallpaper( void TestWallpaperController::RemoveUserWallpaper(
ash::mojom::WallpaperUserInfoPtr user_info, ash::mojom::WallpaperUserInfoPtr user_info,
const std::string& wallpaper_files_id) { const std::string& wallpaper_files_id) {
......
...@@ -85,6 +85,7 @@ class TestWallpaperController : ash::mojom::WallpaperController { ...@@ -85,6 +85,7 @@ class TestWallpaperController : ash::mojom::WallpaperController {
ash::WallpaperLayout layout) override; ash::WallpaperLayout layout) override;
void ShowUserWallpaper(ash::mojom::WallpaperUserInfoPtr user_info) override; void ShowUserWallpaper(ash::mojom::WallpaperUserInfoPtr user_info) override;
void ShowSigninWallpaper() override; void ShowSigninWallpaper() override;
void ShowOneShotWallpaper(const gfx::ImageSkia& image) override;
void RemoveUserWallpaper(ash::mojom::WallpaperUserInfoPtr user_info, void RemoveUserWallpaper(ash::mojom::WallpaperUserInfoPtr user_info,
const std::string& wallpaper_files_id) override; const std::string& wallpaper_files_id) override;
void RemovePolicyWallpaper(ash::mojom::WallpaperUserInfoPtr user_info, void RemovePolicyWallpaper(ash::mojom::WallpaperUserInfoPtr user_info,
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/customization/customization_wallpaper_util.h" #include "chrome/browser/chromeos/customization/customization_wallpaper_util.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/device_local_account.h" #include "chrome/browser/chromeos/policy/device_local_account.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
...@@ -21,6 +20,7 @@ ...@@ -21,6 +20,7 @@
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
#include "chromeos/chromeos_switches.h" #include "chromeos/chromeos_switches.h"
#include "chromeos/cryptohome/system_salt_getter.h" #include "chromeos/cryptohome/system_salt_getter.h"
#include "components/session_manager/core/session_manager.h"
#include "components/user_manager/known_user.h" #include "components/user_manager/known_user.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
...@@ -440,7 +440,7 @@ void WallpaperControllerClient::OnDeviceWallpaperPolicyCleared() { ...@@ -440,7 +440,7 @@ void WallpaperControllerClient::OnDeviceWallpaperPolicyCleared() {
} }
void WallpaperControllerClient::OnShowUserNamesOnLoginPolicyChanged() { void WallpaperControllerClient::OnShowUserNamesOnLoginPolicyChanged() {
UpdateRegisteredDeviceWallpaper(); ShowWallpaperOnLoginScreen();
} }
void WallpaperControllerClient::FlushForTesting() { void WallpaperControllerClient::FlushForTesting() {
...@@ -468,7 +468,7 @@ void WallpaperControllerClient::BindAndSetClient() { ...@@ -468,7 +468,7 @@ void WallpaperControllerClient::BindAndSetClient() {
policy_handler_.IsDeviceWallpaperPolicyEnforced()); policy_handler_.IsDeviceWallpaperPolicyEnforced());
} }
void WallpaperControllerClient::UpdateRegisteredDeviceWallpaper() { void WallpaperControllerClient::ShowWallpaperOnLoginScreen() {
if (user_manager::UserManager::Get()->IsUserLoggedIn()) if (user_manager::UserManager::Get()->IsUserLoggedIn())
return; return;
...@@ -508,11 +508,6 @@ void WallpaperControllerClient::OpenWallpaperPicker() { ...@@ -508,11 +508,6 @@ void WallpaperControllerClient::OpenWallpaperPicker() {
} }
void WallpaperControllerClient::OnReadyToSetWallpaper() { void WallpaperControllerClient::OnReadyToSetWallpaper() {
// TODO(wzang|784495): Consider deprecating this method after views-based
// login is enabled. It should be fast enough to request the first wallpaper
// so that there's no visible delay. In other scenarios such as restart after
// crash, user manager should request the wallpaper.
// Apply device customization. // Apply device customization.
namespace util = chromeos::customization_wallpaper_util; namespace util = chromeos::customization_wallpaper_util;
if (util::ShouldUseCustomizedDefaultWallpaper()) { if (util::ShouldUseCustomizedDefaultWallpaper()) {
...@@ -542,14 +537,18 @@ void WallpaperControllerClient::OnReadyToSetWallpaper() { ...@@ -542,14 +537,18 @@ void WallpaperControllerClient::OnReadyToSetWallpaper() {
return; return;
} }
// If the device is not registered yet (e.g. during OOBE), show the default // Show a white wallpaper during OOBE.
// signin wallpaper. if (session_manager::SessionManager::Get()->session_state() ==
if (!chromeos::StartupUtils::IsDeviceRegistered()) { session_manager::SessionState::OOBE) {
ShowSigninWallpaper(); SkBitmap bitmap;
bitmap.allocN32Pixels(1, 1);
bitmap.eraseColor(SK_ColorWHITE);
wallpaper_controller_->ShowOneShotWallpaper(
gfx::ImageSkia::CreateFrom1xBitmap(bitmap));
return; return;
} }
UpdateRegisteredDeviceWallpaper(); ShowWallpaperOnLoginScreen();
} }
void WallpaperControllerClient::OnFirstWallpaperAnimationFinished() { void WallpaperControllerClient::OnFirstWallpaperAnimationFinished() {
......
...@@ -109,10 +109,14 @@ class WallpaperControllerClient : public ash::mojom::WallpaperControllerClient, ...@@ -109,10 +109,14 @@ class WallpaperControllerClient : public ash::mojom::WallpaperControllerClient,
// Binds this object to its mojo interface and sets it as the ash client. // Binds this object to its mojo interface and sets it as the ash client.
void BindAndSetClient(); void BindAndSetClient();
// Updates the wallpaper of a registered device after device policy is // Shows the wallpaper of the first user in |UserManager::GetUsers|, or a
// trusted, outside an user session. Note that before device is enrolled, it // default signin wallpaper if there's no user. This ensures the wallpaper is
// proceeds with untrusted setting. // shown right after boot, regardless of when the login screen is available.
void UpdateRegisteredDeviceWallpaper(); //
// TODO(wzang|784495): Consider deprecating this method after views-based
// login is enabled. It should be fast enough to request the first wallpaper
// so that there's no visible delay.
void ShowWallpaperOnLoginScreen();
// ash::mojom::WallpaperControllerClient: // ash::mojom::WallpaperControllerClient:
void OpenWallpaperPicker() override; void OpenWallpaperPicker() override;
......
...@@ -49600,6 +49600,7 @@ Full version information for the fingerprint enum values: ...@@ -49600,6 +49600,7 @@ Full version information for the fingerprint enum values:
<int value="5" label="Policy"/> <int value="5" label="Policy"/>
<int value="6" label="Third party"/> <int value="6" label="Third party"/>
<int value="7" label="Device policy"/> <int value="7" label="Device policy"/>
<int value="8" label="One-shot"/>
</enum> </enum>
<enum name="WarmupStateOnLaunch"> <enum name="WarmupStateOnLaunch">
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