Index: chrome/browser/chromeos/login/webui_login_display_host.cc |
diff --git a/chrome/browser/chromeos/login/webui_login_display_host.cc b/chrome/browser/chromeos/login/webui_login_display_host.cc |
index 8cb20bd4accf8454a572611224b5009debbe2856..f244ac1b5f7ee202eb3f3d1ad1487a1953cade75 100644 |
--- a/chrome/browser/chromeos/login/webui_login_display_host.cc |
+++ b/chrome/browser/chromeos/login/webui_login_display_host.cc |
@@ -23,6 +23,7 @@ |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/chrome_switches.h" |
#include "content/public/browser/notification_service.h" |
+#include "content/public/browser/web_contents.h" |
#include "content/public/browser/web_ui.h" |
#include "ui/aura/env.h" |
#include "ui/aura/window.h" |
@@ -43,6 +44,15 @@ const int kLoginFadeoutTransitionDurationMs = 700; |
// Number of times we try to reload OOBE/login WebUI if it crashes. |
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 |
// WebUILoginDisplayHost ------------------------------------------------------- |
@@ -54,6 +64,8 @@ WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds) |
webui_login_display_(NULL), |
is_showing_login_(false), |
is_wallpaper_loaded_(false), |
+ initialize_webui_in_parallel_(kInitializeWebUIInParallelDefault), |
+ status_area_saved_visibility_(false), |
crash_count_(0), |
restore_path_(RESTORE_UNKNOWN) { |
bool is_registered = WizardController::IsDeviceRegistered(); |
@@ -74,7 +86,19 @@ WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds) |
content::NotificationService::AllSources()); |
// Prevents white flashing on OOBE (http://crbug.com/131569). |
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() { |
@@ -112,7 +136,9 @@ void WebUILoginDisplayHost::SetShutdownButtonEnabled(bool enable) { |
} |
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); |
} |
@@ -128,7 +154,7 @@ void WebUILoginDisplayHost::StartWizard(const std::string& first_screen_name, |
is_showing_login_ = false; |
scoped_ptr<DictionaryValue> scoped_parameters(screen_parameters); |
- if (waiting_for_wallpaper_load_) |
+ if (waiting_for_wallpaper_load_ && !initialize_webui_in_parallel_) |
return; |
if (!login_window_) |
@@ -142,7 +168,7 @@ void WebUILoginDisplayHost::StartSignInScreen() { |
restore_path_ = RESTORE_SIGN_IN; |
is_showing_login_ = true; |
- if (waiting_for_wallpaper_load_) |
+ if (waiting_for_wallpaper_load_ && !initialize_webui_in_parallel_) |
return; |
if (!login_window_) |
@@ -178,8 +204,12 @@ void WebUILoginDisplayHost::Observe( |
is_wallpaper_loaded_ = true; |
ash::Shell::GetInstance()->user_wallpaper_delegate()-> |
OnWallpaperBootAnimationFinished(); |
- if (waiting_for_wallpaper_load_) |
- StartPostponedWebUI(); |
+ if (waiting_for_wallpaper_load_) { |
+ if (initialize_webui_in_parallel_) |
+ ShowWebUI(); |
+ else |
+ StartPostponedWebUI(); |
+ } |
registrar_.Remove(this, |
chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, |
content::NotificationService::AllSources()); |
@@ -215,7 +245,16 @@ void WebUILoginDisplayHost::LoadURL(const GURL& url) { |
login_window_->SetContentsView(login_view_); |
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_view_->OnWindowCreated(); |
} |
@@ -263,6 +302,17 @@ WizardController* WebUILoginDisplayHost::CreateWizardController() { |
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() { |
if (!waiting_for_wallpaper_load_ || !is_wallpaper_loaded_) { |
NOTREACHED(); |