Initialize OOBE/login WebUI in hidden state in parallel with wallpaper animation.

* Boot time animation decreased from 2s to 1s (for both OOBE / normal boot).
* WebUI is initialized in hidden state in parallel with wallpaper animation.
* Using EASE_OUT instead of LINEAR for boot animation.

BUG=141150

Review URL: https://chromiumcodereview.appspot.com/10824203

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150535 0039d316-1c4b-4281-b951-d872f2087c98
parent f5eaff95
...@@ -71,7 +71,7 @@ const float kCrossFadeDurationMinMs = 100.f; ...@@ -71,7 +71,7 @@ const float kCrossFadeDurationMinMs = 100.f;
const float kCrossFadeDurationMaxMs = 400.f; const float kCrossFadeDurationMaxMs = 400.f;
// Durations for the brightness/grayscale fade animation, in milliseconds. // Durations for the brightness/grayscale fade animation, in milliseconds.
const int kBrightnessGrayscaleFadeDurationMs = 2000; const int kBrightnessGrayscaleFadeDurationMs = 1000;
// Brightness/grayscale values for hide/show window animations. // Brightness/grayscale values for hide/show window animations.
const float kWindowAnimation_HideBrightnessGrayscale = 1.f; const float kWindowAnimation_HideBrightnessGrayscale = 1.f;
...@@ -506,16 +506,21 @@ void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window, ...@@ -506,16 +506,21 @@ void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window,
scoped_ptr<ui::LayerAnimationSequence> grayscale_sequence( scoped_ptr<ui::LayerAnimationSequence> grayscale_sequence(
new ui::LayerAnimationSequence()); new ui::LayerAnimationSequence());
brightness_sequence->AddElement( scoped_ptr<ui::LayerAnimationElement> brightness_element(
ui::LayerAnimationElement::CreateBrightnessElement( ui::LayerAnimationElement::CreateBrightnessElement(
end_value, end_value,
base::TimeDelta::FromMilliseconds( base::TimeDelta::FromMilliseconds(
kBrightnessGrayscaleFadeDurationMs))); kBrightnessGrayscaleFadeDurationMs)));
grayscale_sequence->AddElement( brightness_element->set_tween_type(ui::Tween::EASE_OUT);
brightness_sequence->AddElement(brightness_element.release());
scoped_ptr<ui::LayerAnimationElement> grayscale_element(
ui::LayerAnimationElement::CreateGrayscaleElement( ui::LayerAnimationElement::CreateGrayscaleElement(
end_value, end_value,
base::TimeDelta::FromMilliseconds( base::TimeDelta::FromMilliseconds(
kBrightnessGrayscaleFadeDurationMs))); kBrightnessGrayscaleFadeDurationMs)));
grayscale_element->set_tween_type(ui::Tween::EASE_OUT);
grayscale_sequence->AddElement(grayscale_element.release());
std::vector<ui::LayerAnimationSequence*> animations; std::vector<ui::LayerAnimationSequence*> animations;
animations.push_back(brightness_sequence.release()); animations.push_back(brightness_sequence.release());
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
...@@ -43,6 +44,15 @@ const int kLoginFadeoutTransitionDurationMs = 700; ...@@ -43,6 +44,15 @@ const int kLoginFadeoutTransitionDurationMs = 700;
// Number of times we try to reload OOBE/login WebUI if it crashes. // Number of times we try to reload OOBE/login WebUI if it crashes.
const int kCrashCountLimit = 5; const int kCrashCountLimit = 5;
// When wallpaper animation is not disabled (no flag --disable-boot-animation)
// initialize OOBE/sign in WebUI in hidden state in parallel with
// wallpaper animation.
const bool kInitializeWebUIInParallelDefault = true;
// Switch values that might be used to override WebUI init type.
const char kWebUIInitParallel[] = "parallel";
const char kWebUIInitPostpone[] = "postpone";
} // namespace } // namespace
// WebUILoginDisplayHost ------------------------------------------------------- // WebUILoginDisplayHost -------------------------------------------------------
...@@ -54,6 +64,8 @@ WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds) ...@@ -54,6 +64,8 @@ WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds)
webui_login_display_(NULL), webui_login_display_(NULL),
is_showing_login_(false), is_showing_login_(false),
is_wallpaper_loaded_(false), is_wallpaper_loaded_(false),
initialize_webui_in_parallel_(kInitializeWebUIInParallelDefault),
status_area_saved_visibility_(false),
crash_count_(0), crash_count_(0),
restore_path_(RESTORE_UNKNOWN) { restore_path_(RESTORE_UNKNOWN) {
bool is_registered = WizardController::IsDeviceRegistered(); bool is_registered = WizardController::IsDeviceRegistered();
...@@ -74,7 +86,19 @@ WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds) ...@@ -74,7 +86,19 @@ WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds)
content::NotificationService::AllSources()); content::NotificationService::AllSources());
// Prevents white flashing on OOBE (http://crbug.com/131569). // Prevents white flashing on OOBE (http://crbug.com/131569).
aura::Env::GetInstance()->set_render_white_bg(false); aura::Env::GetInstance()->set_render_white_bg(false);
// Check if WebUI init type is overriden.
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshWebUIInit)) {
const std::string override_type = CommandLine::ForCurrentProcess()->
GetSwitchValueASCII(switches::kAshWebUIInit);
if (override_type == kWebUIInitParallel)
initialize_webui_in_parallel_ = true;
else if (override_type == kWebUIInitPostpone)
initialize_webui_in_parallel_ = false;
}
} }
// In case if we're not waiting for wallpaper load,
// |initialize_webui_in_parallel_| value is ignored through the code flow.
} }
WebUILoginDisplayHost::~WebUILoginDisplayHost() { WebUILoginDisplayHost::~WebUILoginDisplayHost() {
...@@ -112,7 +136,9 @@ void WebUILoginDisplayHost::SetShutdownButtonEnabled(bool enable) { ...@@ -112,7 +136,9 @@ void WebUILoginDisplayHost::SetShutdownButtonEnabled(bool enable) {
} }
void WebUILoginDisplayHost::SetStatusAreaVisible(bool visible) { void WebUILoginDisplayHost::SetStatusAreaVisible(bool visible) {
if (login_view_) if (waiting_for_wallpaper_load_ && initialize_webui_in_parallel_)
status_area_saved_visibility_ = visible;
else if (login_view_)
login_view_->SetStatusAreaVisible(visible); login_view_->SetStatusAreaVisible(visible);
} }
...@@ -128,7 +154,7 @@ void WebUILoginDisplayHost::StartWizard(const std::string& first_screen_name, ...@@ -128,7 +154,7 @@ void WebUILoginDisplayHost::StartWizard(const std::string& first_screen_name,
is_showing_login_ = false; is_showing_login_ = false;
scoped_ptr<DictionaryValue> scoped_parameters(screen_parameters); scoped_ptr<DictionaryValue> scoped_parameters(screen_parameters);
if (waiting_for_wallpaper_load_) if (waiting_for_wallpaper_load_ && !initialize_webui_in_parallel_)
return; return;
if (!login_window_) if (!login_window_)
...@@ -142,7 +168,7 @@ void WebUILoginDisplayHost::StartSignInScreen() { ...@@ -142,7 +168,7 @@ void WebUILoginDisplayHost::StartSignInScreen() {
restore_path_ = RESTORE_SIGN_IN; restore_path_ = RESTORE_SIGN_IN;
is_showing_login_ = true; is_showing_login_ = true;
if (waiting_for_wallpaper_load_) if (waiting_for_wallpaper_load_ && !initialize_webui_in_parallel_)
return; return;
if (!login_window_) if (!login_window_)
...@@ -178,8 +204,12 @@ void WebUILoginDisplayHost::Observe( ...@@ -178,8 +204,12 @@ void WebUILoginDisplayHost::Observe(
is_wallpaper_loaded_ = true; is_wallpaper_loaded_ = true;
ash::Shell::GetInstance()->user_wallpaper_delegate()-> ash::Shell::GetInstance()->user_wallpaper_delegate()->
OnWallpaperBootAnimationFinished(); OnWallpaperBootAnimationFinished();
if (waiting_for_wallpaper_load_) if (waiting_for_wallpaper_load_) {
StartPostponedWebUI(); if (initialize_webui_in_parallel_)
ShowWebUI();
else
StartPostponedWebUI();
}
registrar_.Remove(this, registrar_.Remove(this,
chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED,
content::NotificationService::AllSources()); content::NotificationService::AllSources());
...@@ -215,7 +245,16 @@ void WebUILoginDisplayHost::LoadURL(const GURL& url) { ...@@ -215,7 +245,16 @@ void WebUILoginDisplayHost::LoadURL(const GURL& url) {
login_window_->SetContentsView(login_view_); login_window_->SetContentsView(login_view_);
login_view_->UpdateWindowType(); login_view_->UpdateWindowType();
login_window_->Show(); // When not waiting for wallpaper any request to load a URL in WebUI
// should trigger window visibility as well.
// Otherwise, when we're waiting for wallpaper load then show WebUI
// right away only if it is not initialized in parallel i.e. was postponed.
// In case of WebUI being initialized in parallel with wallpaper load
// it will be hidden initially.
if (!waiting_for_wallpaper_load_ || !initialize_webui_in_parallel_)
login_window_->Show();
else
login_view_->set_is_hidden(true);
login_window_->GetNativeView()->SetName("WebUILoginView"); login_window_->GetNativeView()->SetName("WebUILoginView");
login_view_->OnWindowCreated(); login_view_->OnWindowCreated();
} }
...@@ -263,6 +302,17 @@ WizardController* WebUILoginDisplayHost::CreateWizardController() { ...@@ -263,6 +302,17 @@ WizardController* WebUILoginDisplayHost::CreateWizardController() {
return new WizardController(this, oobe_display); return new WizardController(this, oobe_display);
} }
void WebUILoginDisplayHost::ShowWebUI() {
if (!login_window_ || !login_view_) {
NOTREACHED();
return;
}
login_window_->Show();
login_view_->GetWebContents()->Focus();
login_view_->SetStatusAreaVisible(status_area_saved_visibility_);
login_view_->OnPostponedShow();
}
void WebUILoginDisplayHost::StartPostponedWebUI() { void WebUILoginDisplayHost::StartPostponedWebUI() {
if (!waiting_for_wallpaper_load_ || !is_wallpaper_loaded_) { if (!waiting_for_wallpaper_load_ || !is_wallpaper_loaded_) {
NOTREACHED(); NOTREACHED();
......
...@@ -67,6 +67,9 @@ class WebUILoginDisplayHost : public BaseLoginDisplayHost, ...@@ -67,6 +67,9 @@ class WebUILoginDisplayHost : public BaseLoginDisplayHost,
// Loads given URL. Creates WebUILoginView if needed. // Loads given URL. Creates WebUILoginView if needed.
void LoadURL(const GURL& url); void LoadURL(const GURL& url);
// Shows OOBE/sign in WebUI that was previously initialized in hidden state.
void ShowWebUI();
// Starts postponed WebUI (OOBE/sign in) if it was waiting for // Starts postponed WebUI (OOBE/sign in) if it was waiting for
// wallpaper animation end. // wallpaper animation end.
void StartPostponedWebUI(); void StartPostponedWebUI();
...@@ -87,10 +90,20 @@ class WebUILoginDisplayHost : public BaseLoginDisplayHost, ...@@ -87,10 +90,20 @@ class WebUILoginDisplayHost : public BaseLoginDisplayHost,
// received. // received.
bool is_wallpaper_loaded_; bool is_wallpaper_loaded_;
// True if WebUI is initialized hidden in parallel with wallpaper animation.
// Otherwise it is postponed and only starts initializing when animation
// finishes. Makes sense only if |waiting_for_wallpaper_load_| is true.
// By default is true. Could be used to tune performance if needed.
bool initialize_webui_in_parallel_;
// Stores status area current visibility to be applied once login WebUI
// is shown.
bool status_area_saved_visibility_;
// True if should not show WebUI on first StartWizard/StartSignInScreen call // True if should not show WebUI on first StartWizard/StartSignInScreen call
// but wait for wallpaper load animation to finish. // but wait for wallpaper load animation to finish.
// Used in OOBE (first boot, boot after update) i.e. till // OOBE/sign in WebUI is either initialized hidden or postponed i.e. loaded
// device is marked as registered to postpone loading OOBE screen / sign in. // only when wallpaper animation finishes.
bool waiting_for_wallpaper_load_; bool waiting_for_wallpaper_load_;
content::NotificationRegistrar registrar_; content::NotificationRegistrar registrar_;
......
...@@ -115,6 +115,9 @@ WebUILoginView::WebUILoginView() ...@@ -115,6 +115,9 @@ WebUILoginView::WebUILoginView()
: webui_login_(NULL), : webui_login_(NULL),
login_window_(NULL), login_window_(NULL),
host_window_frozen_(false), host_window_frozen_(false),
is_hidden_(false),
login_visible_notification_fired_(false),
login_prompt_visible_handled_(false),
should_emit_login_prompt_visible_(true) { should_emit_login_prompt_visible_(true) {
registrar_.Add(this, registrar_.Add(this,
chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE,
...@@ -231,6 +234,13 @@ void WebUILoginView::OpenProxySettings() { ...@@ -231,6 +234,13 @@ void WebUILoginView::OpenProxySettings() {
dialog->Show(); dialog->Show();
} }
void WebUILoginView::OnPostponedShow() {
set_is_hidden(false);
// If notification will happen later let it fire login-prompt-visible signal.
if (login_visible_notification_fired_)
OnLoginPromptVisible();
}
void WebUILoginView::SetStatusAreaVisible(bool visible) { void WebUILoginView::SetStatusAreaVisible(bool visible) {
ash::SystemTray* tray = ash::Shell::GetInstance()->system_tray(); ash::SystemTray* tray = ash::Shell::GetInstance()->system_tray();
if (tray) { if (tray) {
...@@ -270,6 +280,7 @@ void WebUILoginView::Observe(int type, ...@@ -270,6 +280,7 @@ void WebUILoginView::Observe(int type,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
switch (type) { switch (type) {
case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE: { case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE: {
login_visible_notification_fired_ = true;
OnLoginPromptVisible(); OnLoginPromptVisible();
registrar_.RemoveAll(); registrar_.RemoveAll();
break; break;
...@@ -342,10 +353,15 @@ void WebUILoginView::RequestMediaAccessPermission( ...@@ -342,10 +353,15 @@ void WebUILoginView::RequestMediaAccessPermission(
} }
void WebUILoginView::OnLoginPromptVisible() { void WebUILoginView::OnLoginPromptVisible() {
// If we're hidden than will generate this signal once we're shown.
if (is_hidden_ || login_prompt_visible_handled_)
return;
if (should_emit_login_prompt_visible_) { if (should_emit_login_prompt_visible_) {
chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
EmitLoginPromptVisible(); EmitLoginPromptVisible();
} }
login_prompt_visible_handled_ = true;
OobeUI* oobe_ui = static_cast<OobeUI*>(GetWebUI()->GetController()); OobeUI* oobe_ui = static_cast<OobeUI*>(GetWebUI()->GetController());
// Notify OOBE that the login frame has been rendered. Currently // Notify OOBE that the login frame has been rendered. Currently
......
...@@ -70,6 +70,11 @@ class WebUILoginView : public views::WidgetDelegateView, ...@@ -70,6 +70,11 @@ class WebUILoginView : public views::WidgetDelegateView,
// Opens proxy settings dialog. // Opens proxy settings dialog.
void OpenProxySettings(); void OpenProxySettings();
// Called when WebUI is being shown after being initilized hidden.
void OnPostponedShow();
void set_is_hidden(bool hidden) { is_hidden_ = hidden; }
// Toggles status area visibility. // Toggles status area visibility.
void SetStatusAreaVisible(bool visible); void SetStatusAreaVisible(bool visible);
...@@ -140,6 +145,15 @@ class WebUILoginView : public views::WidgetDelegateView, ...@@ -140,6 +145,15 @@ class WebUILoginView : public views::WidgetDelegateView,
// Whether the host window is frozen. // Whether the host window is frozen.
bool host_window_frozen_; bool host_window_frozen_;
// True when WebUI is being initialized hidden.
bool is_hidden_;
// True when NOTIFICATION_LOGIN_WEBUI_VISIBLE notification has fired.
bool login_visible_notification_fired_;
// True is login-prompt-visible event has been already handled.
bool login_prompt_visible_handled_;
// Should we emit the login-prompt-visible signal when the login page is // Should we emit the login-prompt-visible signal when the login page is
// displayed? // displayed?
bool should_emit_login_prompt_visible_; bool should_emit_login_prompt_visible_;
......
...@@ -1349,6 +1349,11 @@ const char kTabletUI[] = "tablet-ui"; ...@@ -1349,6 +1349,11 @@ const char kTabletUI[] = "tablet-ui";
#endif #endif
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// 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";
// Disables wallpaper boot animation (except of OOBE case). // Disables wallpaper boot animation (except of OOBE case).
const char kDisableBootAnimation[] = "disable-boot-animation"; const char kDisableBootAnimation[] = "disable-boot-animation";
......
...@@ -366,6 +366,7 @@ extern const char kTabletUI[]; ...@@ -366,6 +366,7 @@ extern const char kTabletUI[];
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// Keep switches in alphabetical order. // Keep switches in alphabetical order.
extern const char kAshWebUIInit[];
extern const char kDisableBootAnimation[]; extern const char kDisableBootAnimation[];
extern const char kDisableGData[]; extern const char kDisableGData[];
extern const char kDisableHtml5Camera[]; extern const char kDisableHtml5Camera[];
......
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