Commit 907ced37 authored by James Cook's avatar James Cook Committed by Commit Bot

chromeos: Clean up LoginDisplayHostWebUI constructor

Pull initialize_webui_hidden_ computation into a utility function.
This simplifies various IsUsingWindowService() checks for mash.

Bug: 143298, 756071
Change-Id: I538ea8597f2fd970dbd246a9ee184144a76462ca
Reviewed-on: https://chromium-review.googlesource.com/1189052Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586276}
parent c063c770
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
#include "ui/views/widget/widget_delegate.h" #include "ui/views/widget/widget_delegate.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace chromeos {
namespace { namespace {
// Maximum delay for startup sound after 'loginPromptVisible' signal. // Maximum delay for startup sound after 'loginPromptVisible' signal.
...@@ -140,14 +141,6 @@ const int kCrashCountLimit = 5; ...@@ -140,14 +141,6 @@ const int kCrashCountLimit = 5;
// The default fade out animation time in ms. // The default fade out animation time in ms.
const int kDefaultFadeTimeMs = 200; const int kDefaultFadeTimeMs = 200;
// Whether to enable tnitializing WebUI in hidden state (see
// |initialize_webui_hidden_|) by default.
const bool kHiddenWebUIInitializationDefault = true;
// Switch values that might be used to override WebUI init type.
const char kWebUIInitParallel[] = "parallel";
const char kWebUIInitPostpone[] = "postpone";
// A class to observe an implicit animation and invokes the callback after the // A class to observe an implicit animation and invokes the callback after the
// animation is completed. // animation is completed.
class AnimationObserver : public ui::ImplicitAnimationObserver { class AnimationObserver : public ui::ImplicitAnimationObserver {
...@@ -358,9 +351,25 @@ bool CanPlayStartupSound() { ...@@ -358,9 +351,25 @@ bool CanPlayStartupSound() {
device.type != chromeos::AudioDeviceType::AUDIO_TYPE_OTHER; device.type != chromeos::AudioDeviceType::AUDIO_TYPE_OTHER;
} }
} // namespace bool ShouldInitializeWebUIHidden() {
// Not supported under mash.
if (features::IsUsingWindowService())
return false;
namespace chromeos { // Always postpone WebUI initialization on first boot, otherwise we miss
// initial animation.
if (!StartupUtils::IsOobeCompleted())
return false;
// Tests and kiosk app autolaunch don't support hidden.
if (WizardController::IsZeroDelayEnabled())
return false;
// Default.
return true;
}
} // namespace
// static // static
const int LoginDisplayHostWebUI::kShowLoginWebUIid = 0x1111; const int LoginDisplayHostWebUI::kShowLoginWebUIid = 0x1111;
...@@ -429,12 +438,12 @@ class LoginDisplayHostWebUI::LoginWidgetDelegate ...@@ -429,12 +438,12 @@ class LoginDisplayHostWebUI::LoginWidgetDelegate
// LoginDisplayHostWebUI, public // LoginDisplayHostWebUI, public
LoginDisplayHostWebUI::LoginDisplayHostWebUI() LoginDisplayHostWebUI::LoginDisplayHostWebUI()
: oobe_startup_sound_played_(StartupUtils::IsOobeCompleted()), : initialize_webui_hidden_(ShouldInitializeWebUIHidden()),
oobe_startup_sound_played_(StartupUtils::IsOobeCompleted()),
weak_factory_(this) { weak_factory_(this) {
if (features::IsUsingWindowService()) { if (features::IsUsingWindowService()) {
// Animation, and initializing hidden, are not currently supported for Mash. // Animation is not currently supported for Mash.
finalize_animation_type_ = ANIMATION_NONE; finalize_animation_type_ = ANIMATION_NONE;
initialize_webui_hidden_ = false;
} }
DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
...@@ -455,30 +464,6 @@ LoginDisplayHostWebUI::LoginDisplayHostWebUI() ...@@ -455,30 +464,6 @@ LoginDisplayHostWebUI::LoginDisplayHostWebUI()
waiting_for_wallpaper_load_ = !zero_delay_enabled; waiting_for_wallpaper_load_ = !zero_delay_enabled;
// Initializing hidden is not supported in Mash
if (!features::IsUsingWindowService()) {
initialize_webui_hidden_ =
kHiddenWebUIInitializationDefault && !zero_delay_enabled;
}
// Check if WebUI init type is overriden. Not supported in Mash.
if (!features::IsUsingWindowService() &&
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshWebUIInit)) {
const std::string override_type =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kAshWebUIInit);
if (override_type == kWebUIInitParallel)
initialize_webui_hidden_ = true;
else if (override_type == kWebUIInitPostpone)
initialize_webui_hidden_ = false;
}
// Always postpone WebUI initialization on first boot, otherwise we miss
// initial animation.
if (!StartupUtils::IsOobeCompleted())
initialize_webui_hidden_ = false;
if (waiting_for_wallpaper_load_) { if (waiting_for_wallpaper_load_) {
registrar_.Add(this, chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, registrar_.Add(this, chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED,
content::NotificationService::AllSources()); content::NotificationService::AllSources());
......
...@@ -121,11 +121,6 @@ const char kArcTransitionMigrationRequired[] = ...@@ -121,11 +121,6 @@ const char kArcTransitionMigrationRequired[] =
// Screenshot testing: specifies the directoru where artifacts will be stored. // Screenshot testing: specifies the directoru where artifacts will be stored.
const char kArtifactsDir[] = "artifacts-dir"; const char kArtifactsDir[] = "artifacts-dir";
// When wallpaper boot animation is not disabled this switch
// is used to override OOBE/sign in WebUI init type.
// Possible values: parallel|postpone. Default: parallel.
const char kAshWebUIInit[] = "ash-webui-init";
// If this flag is set, it indicates that this device is a "Cellular First" // If this flag is set, it indicates that this device is a "Cellular First"
// device. Cellular First devices use cellular telephone data networks as // device. Cellular First devices use cellular telephone data networks as
// their primary means of connecting to the internet. // their primary means of connecting to the internet.
......
...@@ -38,7 +38,6 @@ CHROMEOS_EXPORT extern const char kArcPackagesCacheMode[]; ...@@ -38,7 +38,6 @@ CHROMEOS_EXPORT extern const char kArcPackagesCacheMode[];
CHROMEOS_EXPORT extern const char kArcStartMode[]; CHROMEOS_EXPORT extern const char kArcStartMode[];
CHROMEOS_EXPORT extern const char kArcTransitionMigrationRequired[]; CHROMEOS_EXPORT extern const char kArcTransitionMigrationRequired[];
CHROMEOS_EXPORT extern const char kArtifactsDir[]; CHROMEOS_EXPORT extern const char kArtifactsDir[];
CHROMEOS_EXPORT extern const char kAshWebUIInit[];
CHROMEOS_EXPORT extern const char kCellularFirst[]; CHROMEOS_EXPORT extern const char kCellularFirst[];
CHROMEOS_EXPORT extern const char kChildWallpaperLarge[]; CHROMEOS_EXPORT extern const char kChildWallpaperLarge[];
CHROMEOS_EXPORT extern const char kChildWallpaperSmall[]; CHROMEOS_EXPORT extern const char kChildWallpaperSmall[];
......
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