Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: chrome/browser/chromeos/login/webui_login_display_host.cc

Issue 10824203: Initialize OOBE/login WebUI in hidden state in parallel with wallpaper animation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix how login prompt-visible is emitted Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/login/webui_login_display_host.h" 5 #include "chrome/browser/chromeos/login/webui_login_display_host.h"
6 6
7 #include "ash/desktop_background/desktop_background_controller.h" 7 #include "ash/desktop_background/desktop_background_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/wm/window_animations.h" 10 #include "ash/wm/window_animations.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/browser_shutdown.h" 16 #include "chrome/browser/browser_shutdown.h"
17 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" 17 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
18 #include "chrome/browser/chromeos/login/oobe_display.h" 18 #include "chrome/browser/chromeos/login/oobe_display.h"
19 #include "chrome/browser/chromeos/login/webui_login_display.h" 19 #include "chrome/browser/chromeos/login/webui_login_display.h"
20 #include "chrome/browser/chromeos/login/webui_login_view.h" 20 #include "chrome/browser/chromeos/login/webui_login_view.h"
21 #include "chrome/browser/chromeos/login/wizard_controller.h" 21 #include "chrome/browser/chromeos/login/wizard_controller.h"
22 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 22 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
23 #include "chrome/common/chrome_notification_types.h" 23 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
25 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_ui.h" 27 #include "content/public/browser/web_ui.h"
27 #include "ui/aura/env.h" 28 #include "ui/aura/env.h"
28 #include "ui/aura/window.h" 29 #include "ui/aura/window.h"
29 #include "ui/views/widget/widget.h" 30 #include "ui/views/widget/widget.h"
30 31
31 namespace chromeos { 32 namespace chromeos {
32 33
33 namespace { 34 namespace {
34 35
35 // URL which corresponds to the login WebUI. 36 // URL which corresponds to the login WebUI.
36 const char kLoginURL[] = "chrome://oobe/login"; 37 const char kLoginURL[] = "chrome://oobe/login";
37 // URL which corresponds to the OOBE WebUI. 38 // URL which corresponds to the OOBE WebUI.
38 const char kOobeURL[] = "chrome://oobe"; 39 const char kOobeURL[] = "chrome://oobe";
39 40
40 // Duration of sign-in transition animation. 41 // Duration of sign-in transition animation.
41 const int kLoginFadeoutTransitionDurationMs = 700; 42 const int kLoginFadeoutTransitionDurationMs = 700;
42 43
43 // Number of times we try to reload OOBE/login WebUI if it crashes. 44 // Number of times we try to reload OOBE/login WebUI if it crashes.
44 const int kCrashCountLimit = 5; 45 const int kCrashCountLimit = 5;
45 46
47 // When wallpaper animation is not disabled (no flag --disable-boot-animation)
48 // initialize OOBE/sign in WebUI in hidden state in parallel with
49 // wallpaper animation.
50 const bool kInitializeWebUIInParallelDefault = true;
51
52 // Switch values that might be used to override WebUI init type.
53 const char kWebUIInitParallel[] = "parallel";
54 const char kWebUIInitPostpone[] = "postpone";
55
46 } // namespace 56 } // namespace
47 57
48 // WebUILoginDisplayHost ------------------------------------------------------- 58 // WebUILoginDisplayHost -------------------------------------------------------
49 59
50 WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds) 60 WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds)
51 : BaseLoginDisplayHost(background_bounds), 61 : BaseLoginDisplayHost(background_bounds),
52 login_window_(NULL), 62 login_window_(NULL),
53 login_view_(NULL), 63 login_view_(NULL),
54 webui_login_display_(NULL), 64 webui_login_display_(NULL),
55 is_showing_login_(false), 65 is_showing_login_(false),
56 is_wallpaper_loaded_(false), 66 is_wallpaper_loaded_(false),
67 initialize_webui_in_parallel_(kInitializeWebUIInParallelDefault),
68 status_area_saved_visibility_(false),
57 crash_count_(0), 69 crash_count_(0),
58 restore_path_(RESTORE_UNKNOWN) { 70 restore_path_(RESTORE_UNKNOWN) {
59 bool is_registered = WizardController::IsDeviceRegistered(); 71 bool is_registered = WizardController::IsDeviceRegistered();
60 // TODO(nkostylev): Add switch to disable wallpaper transition on OOBE. 72 // TODO(nkostylev): Add switch to disable wallpaper transition on OOBE.
61 // Should be used on test images so that they are not slowed down. 73 // Should be used on test images so that they are not slowed down.
62 bool zero_delay_enabled = WizardController::IsZeroDelayEnabled(); 74 bool zero_delay_enabled = WizardController::IsZeroDelayEnabled();
63 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableNewOobe) && 75 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableNewOobe) &&
64 !zero_delay_enabled) { 76 !zero_delay_enabled) {
65 bool disable_boot_animation = CommandLine::ForCurrentProcess()-> 77 bool disable_boot_animation = CommandLine::ForCurrentProcess()->
66 HasSwitch(switches::kDisableBootAnimation); 78 HasSwitch(switches::kDisableBootAnimation);
67 waiting_for_wallpaper_load_ = !is_registered || !disable_boot_animation; 79 waiting_for_wallpaper_load_ = !is_registered || !disable_boot_animation;
68 } else { 80 } else {
69 waiting_for_wallpaper_load_ = false; 81 waiting_for_wallpaper_load_ = false;
70 } 82 }
71 83
72 if (waiting_for_wallpaper_load_) { 84 if (waiting_for_wallpaper_load_) {
73 registrar_.Add(this, chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, 85 registrar_.Add(this, chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED,
74 content::NotificationService::AllSources()); 86 content::NotificationService::AllSources());
75 // Prevents white flashing on OOBE (http://crbug.com/131569). 87 // Prevents white flashing on OOBE (http://crbug.com/131569).
76 aura::Env::GetInstance()->set_render_white_bg(false); 88 aura::Env::GetInstance()->set_render_white_bg(false);
89
90 // Check if WebUI init type is overriden.
91 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshWebUIInit)) {
92 const std::string override_type = CommandLine::ForCurrentProcess()->
93 GetSwitchValueASCII(switches::kAshWebUIInit);
94 if (override_type == kWebUIInitParallel)
95 initialize_webui_in_parallel_ = true;
96 else if (override_type == kWebUIInitPostpone)
97 initialize_webui_in_parallel_ = false;
98 }
77 } 99 }
100 // In case if we're not waiting for wallpaper load,
101 // |initialize_webui_in_parallel_| value is ignored through the code flow.
78 } 102 }
79 103
80 WebUILoginDisplayHost::~WebUILoginDisplayHost() { 104 WebUILoginDisplayHost::~WebUILoginDisplayHost() {
81 if (login_window_) 105 if (login_window_)
82 login_window_->Close(); 106 login_window_->Close();
83 } 107 }
84 108
85 // LoginDisplayHost implementation --------------------------------------------- 109 // LoginDisplayHost implementation ---------------------------------------------
86 110
87 LoginDisplay* WebUILoginDisplayHost::CreateLoginDisplay( 111 LoginDisplay* WebUILoginDisplayHost::CreateLoginDisplay(
(...skipping 17 matching lines...) Expand all
105 } 129 }
106 130
107 void WebUILoginDisplayHost::SetOobeProgressBarVisible(bool visible) { 131 void WebUILoginDisplayHost::SetOobeProgressBarVisible(bool visible) {
108 GetOobeUI()->ShowOobeUI(visible); 132 GetOobeUI()->ShowOobeUI(visible);
109 } 133 }
110 134
111 void WebUILoginDisplayHost::SetShutdownButtonEnabled(bool enable) { 135 void WebUILoginDisplayHost::SetShutdownButtonEnabled(bool enable) {
112 } 136 }
113 137
114 void WebUILoginDisplayHost::SetStatusAreaVisible(bool visible) { 138 void WebUILoginDisplayHost::SetStatusAreaVisible(bool visible) {
115 if (login_view_) 139 if (waiting_for_wallpaper_load_ && initialize_webui_in_parallel_)
140 status_area_saved_visibility_ = visible;
141 else if (login_view_)
116 login_view_->SetStatusAreaVisible(visible); 142 login_view_->SetStatusAreaVisible(visible);
117 } 143 }
118 144
119 void WebUILoginDisplayHost::StartWizard(const std::string& first_screen_name, 145 void WebUILoginDisplayHost::StartWizard(const std::string& first_screen_name,
120 DictionaryValue* screen_parameters) { 146 DictionaryValue* screen_parameters) {
121 // Keep parameters to restore if renderer crashes. 147 // Keep parameters to restore if renderer crashes.
122 restore_path_ = RESTORE_WIZARD; 148 restore_path_ = RESTORE_WIZARD;
123 wizard_first_screen_name_ = first_screen_name; 149 wizard_first_screen_name_ = first_screen_name;
124 if (screen_parameters) 150 if (screen_parameters)
125 wizard_screen_parameters_.reset(screen_parameters->DeepCopy()); 151 wizard_screen_parameters_.reset(screen_parameters->DeepCopy());
126 else 152 else
127 wizard_screen_parameters_.reset(NULL); 153 wizard_screen_parameters_.reset(NULL);
128 is_showing_login_ = false; 154 is_showing_login_ = false;
129 scoped_ptr<DictionaryValue> scoped_parameters(screen_parameters); 155 scoped_ptr<DictionaryValue> scoped_parameters(screen_parameters);
130 156
131 if (waiting_for_wallpaper_load_) 157 if (waiting_for_wallpaper_load_ && !initialize_webui_in_parallel_)
132 return; 158 return;
133 159
134 if (!login_window_) 160 if (!login_window_)
135 LoadURL(GURL(kOobeURL)); 161 LoadURL(GURL(kOobeURL));
136 162
137 BaseLoginDisplayHost::StartWizard(first_screen_name, 163 BaseLoginDisplayHost::StartWizard(first_screen_name,
138 scoped_parameters.release()); 164 scoped_parameters.release());
139 } 165 }
140 166
141 void WebUILoginDisplayHost::StartSignInScreen() { 167 void WebUILoginDisplayHost::StartSignInScreen() {
142 restore_path_ = RESTORE_SIGN_IN; 168 restore_path_ = RESTORE_SIGN_IN;
143 is_showing_login_ = true; 169 is_showing_login_ = true;
144 170
145 if (waiting_for_wallpaper_load_) 171 if (waiting_for_wallpaper_load_ && !initialize_webui_in_parallel_)
146 return; 172 return;
147 173
148 if (!login_window_) 174 if (!login_window_)
149 LoadURL(GURL(kLoginURL)); 175 LoadURL(GURL(kLoginURL));
150 176
151 BaseLoginDisplayHost::StartSignInScreen(); 177 BaseLoginDisplayHost::StartSignInScreen();
152 CHECK(webui_login_display_); 178 CHECK(webui_login_display_);
153 GetOobeUI()->ShowSigninScreen(webui_login_display_); 179 GetOobeUI()->ShowSigninScreen(webui_login_display_);
154 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) 180 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled())
155 SetStatusAreaVisible(false); 181 SetStatusAreaVisible(false);
(...skipping 15 matching lines...) Expand all
171 197
172 void WebUILoginDisplayHost::Observe( 198 void WebUILoginDisplayHost::Observe(
173 int type, 199 int type,
174 const content::NotificationSource& source, 200 const content::NotificationSource& source,
175 const content::NotificationDetails& details) { 201 const content::NotificationDetails& details) {
176 BaseLoginDisplayHost::Observe(type, source, details); 202 BaseLoginDisplayHost::Observe(type, source, details);
177 if (chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED == type) { 203 if (chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED == type) {
178 is_wallpaper_loaded_ = true; 204 is_wallpaper_loaded_ = true;
179 ash::Shell::GetInstance()->user_wallpaper_delegate()-> 205 ash::Shell::GetInstance()->user_wallpaper_delegate()->
180 OnWallpaperBootAnimationFinished(); 206 OnWallpaperBootAnimationFinished();
181 if (waiting_for_wallpaper_load_) 207 if (waiting_for_wallpaper_load_) {
182 StartPostponedWebUI(); 208 if (initialize_webui_in_parallel_)
209 ShowWebUI();
210 else
211 StartPostponedWebUI();
212 }
183 registrar_.Remove(this, 213 registrar_.Remove(this,
184 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, 214 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED,
185 content::NotificationService::AllSources()); 215 content::NotificationService::AllSources());
186 } 216 }
187 } 217 }
188 218
189 void WebUILoginDisplayHost::LoadURL(const GURL& url) { 219 void WebUILoginDisplayHost::LoadURL(const GURL& url) {
190 if (!login_window_) { 220 if (!login_window_) {
191 views::Widget::InitParams params( 221 views::Widget::InitParams params(
192 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 222 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
(...skipping 15 matching lines...) Expand all
208 ash::SetWindowVisibilityAnimationDuration( 238 ash::SetWindowVisibilityAnimationDuration(
209 login_window_->GetNativeView(), 239 login_window_->GetNativeView(),
210 base::TimeDelta::FromMilliseconds(kLoginFadeoutTransitionDurationMs)); 240 base::TimeDelta::FromMilliseconds(kLoginFadeoutTransitionDurationMs));
211 ash::SetWindowVisibilityAnimationTransition( 241 ash::SetWindowVisibilityAnimationTransition(
212 login_window_->GetNativeView(), 242 login_window_->GetNativeView(),
213 ash::ANIMATE_HIDE); 243 ash::ANIMATE_HIDE);
214 244
215 login_window_->SetContentsView(login_view_); 245 login_window_->SetContentsView(login_view_);
216 login_view_->UpdateWindowType(); 246 login_view_->UpdateWindowType();
217 247
218 login_window_->Show(); 248 // When not waiting for wallpaper any request to load a URL in WebUI
249 // should trigger window visibility as well.
250 // Otherwise, when we're waiting for wallpaper load then show WebUI
251 // right away only if it is not initialized in parallel i.e. was postponed.
252 // In case of WebUI being initialized in parallel with wallpaper load
253 // it will be hidden initially.
254 if (!waiting_for_wallpaper_load_ || !initialize_webui_in_parallel_)
255 login_window_->Show();
256 else
257 login_view_->set_is_hidden(true);
219 login_window_->GetNativeView()->SetName("WebUILoginView"); 258 login_window_->GetNativeView()->SetName("WebUILoginView");
220 login_view_->OnWindowCreated(); 259 login_view_->OnWindowCreated();
221 } 260 }
222 // Subscribe to crash events. 261 // Subscribe to crash events.
223 content::WebContentsObserver::Observe(login_view_->GetWebContents()); 262 content::WebContentsObserver::Observe(login_view_->GetWebContents());
224 login_view_->LoadURL(url); 263 login_view_->LoadURL(url);
225 } 264 }
226 265
227 void WebUILoginDisplayHost::RenderViewGone(base::TerminationStatus status) { 266 void WebUILoginDisplayHost::RenderViewGone(base::TerminationStatus status) {
228 // Do not try to restore on shutdown 267 // Do not try to restore on shutdown
(...skipping 27 matching lines...) Expand all
256 return NULL; 295 return NULL;
257 return static_cast<OobeUI*>(login_view_->GetWebUI()->GetController()); 296 return static_cast<OobeUI*>(login_view_->GetWebUI()->GetController());
258 } 297 }
259 298
260 WizardController* WebUILoginDisplayHost::CreateWizardController() { 299 WizardController* WebUILoginDisplayHost::CreateWizardController() {
261 // TODO(altimofeev): ensure that WebUI is ready. 300 // TODO(altimofeev): ensure that WebUI is ready.
262 OobeDisplay* oobe_display = GetOobeUI(); 301 OobeDisplay* oobe_display = GetOobeUI();
263 return new WizardController(this, oobe_display); 302 return new WizardController(this, oobe_display);
264 } 303 }
265 304
305 void WebUILoginDisplayHost::ShowWebUI() {
306 if (!login_window_ || !login_view_) {
307 NOTREACHED();
308 return;
309 }
310 login_window_->Show();
311 login_view_->GetWebContents()->Focus();
312 login_view_->SetStatusAreaVisible(status_area_saved_visibility_);
313 login_view_->OnPostponedShow();
314 }
315
266 void WebUILoginDisplayHost::StartPostponedWebUI() { 316 void WebUILoginDisplayHost::StartPostponedWebUI() {
267 if (!waiting_for_wallpaper_load_ || !is_wallpaper_loaded_) { 317 if (!waiting_for_wallpaper_load_ || !is_wallpaper_loaded_) {
268 NOTREACHED(); 318 NOTREACHED();
269 return; 319 return;
270 } 320 }
271 321
272 // StartWizard / StartSignInScreen could be called multiple times through 322 // StartWizard / StartSignInScreen could be called multiple times through
273 // the lifetime of host. Make sure that subsequent calls are not postponed. 323 // the lifetime of host. Make sure that subsequent calls are not postponed.
274 waiting_for_wallpaper_load_ = false; 324 waiting_for_wallpaper_load_ = false;
275 325
(...skipping 13 matching lines...) Expand all
289 case RESTORE_SIGN_IN: 339 case RESTORE_SIGN_IN:
290 StartSignInScreen(); 340 StartSignInScreen();
291 break; 341 break;
292 default: 342 default:
293 NOTREACHED(); 343 NOTREACHED();
294 break; 344 break;
295 } 345 }
296 } 346 }
297 347
298 } // namespace chromeos 348 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/webui_login_display_host.h ('k') | chrome/browser/chromeos/login/webui_login_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698