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

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

Issue 10889024: [cros] Initialize OOBE in parallel when boot animation is disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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"
(...skipping 26 matching lines...) Expand all
37 const char kLoginURL[] = "chrome://oobe/login"; 37 const char kLoginURL[] = "chrome://oobe/login";
38 // URL which corresponds to the OOBE WebUI. 38 // URL which corresponds to the OOBE WebUI.
39 const char kOobeURL[] = "chrome://oobe"; 39 const char kOobeURL[] = "chrome://oobe";
40 40
41 // Duration of sign-in transition animation. 41 // Duration of sign-in transition animation.
42 const int kLoginFadeoutTransitionDurationMs = 700; 42 const int kLoginFadeoutTransitionDurationMs = 700;
43 43
44 // 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.
45 const int kCrashCountLimit = 5; 45 const int kCrashCountLimit = 5;
46 46
47 // When wallpaper animation is not disabled (no flag --disable-boot-animation) 47 // Whether to enablwe tnitializing WebUI in hidden state (see
Nikita (slow) 2012/08/29 14:10:01 nit: enable initializing
Ivan Korotkov 2012/08/30 12:26:06 Done.
48 // initialize OOBE/sign in WebUI in hidden state in parallel with 48 // |initialize_webui_hidden_|) by default.
49 // wallpaper animation. 49 const bool kHiddenWebUIInitializationDefault = true;
50 const bool kInitializeWebUIInParallelDefault = true;
51 50
52 // Switch values that might be used to override WebUI init type. 51 // Switch values that might be used to override WebUI init type.
53 const char kWebUIInitParallel[] = "parallel"; 52 const char kWebUIInitParallel[] = "parallel";
54 const char kWebUIInitPostpone[] = "postpone"; 53 const char kWebUIInitPostpone[] = "postpone";
55 54
56 } // namespace 55 } // namespace
57 56
58 // WebUILoginDisplayHost ------------------------------------------------------- 57 // WebUILoginDisplayHost -------------------------------------------------------
59 58
60 WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds) 59 WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds)
61 : BaseLoginDisplayHost(background_bounds), 60 : BaseLoginDisplayHost(background_bounds),
62 login_window_(NULL), 61 login_window_(NULL),
63 login_view_(NULL), 62 login_view_(NULL),
64 webui_login_display_(NULL), 63 webui_login_display_(NULL),
65 is_showing_login_(false), 64 is_showing_login_(false),
66 is_wallpaper_loaded_(false), 65 is_wallpaper_loaded_(false),
67 initialize_webui_in_parallel_(kInitializeWebUIInParallelDefault),
68 status_area_saved_visibility_(false), 66 status_area_saved_visibility_(false),
69 crash_count_(0), 67 crash_count_(0),
70 restore_path_(RESTORE_UNKNOWN) { 68 restore_path_(RESTORE_UNKNOWN) {
71 bool is_registered = WizardController::IsDeviceRegistered(); 69 bool is_registered = WizardController::IsDeviceRegistered();
72 bool zero_delay_enabled = WizardController::IsZeroDelayEnabled(); 70 bool zero_delay_enabled = WizardController::IsZeroDelayEnabled();
73 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableNewOobe) && 71 bool disable_boot_animation = CommandLine::ForCurrentProcess()->
74 !CommandLine::ForCurrentProcess()->HasSwitch( 72 HasSwitch(switches::kDisableBootAnimation);
75 switches::kDisableOobeAnimation) && 73 bool disable_oobe_animation = CommandLine::ForCurrentProcess()->
76 !zero_delay_enabled) { 74 HasSwitch(switches::kDisableOobeAnimation);
77 bool disable_boot_animation = CommandLine::ForCurrentProcess()-> 75
78 HasSwitch(switches::kDisableBootAnimation); 76 waiting_for_wallpaper_load_ =
79 waiting_for_wallpaper_load_ = !is_registered || !disable_boot_animation; 77 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableNewOobe) &&
Nikita (slow) 2012/08/29 14:10:01 nit: extract this flag value too
Ivan Korotkov 2012/08/30 12:26:06 Done.
80 } else { 78 !zero_delay_enabled &&
81 waiting_for_wallpaper_load_ = false; 79 (is_registered || !disable_oobe_animation) &&
82 } 80 (!is_registered || !disable_boot_animation);
81
82 waiting_for_user_pods_ =
Nikita (slow) 2012/08/29 14:10:01 How is this handled for OOBE when technically we d
Ivan Korotkov 2012/08/30 12:26:06 initialize_webui_hidden_ is set to false below in
Nikita (slow) 2012/08/30 12:41:37 Still it feels that would be cleaner not subscribe
Ivan Korotkov 2012/08/30 14:54:52 Ok, makes sense.
83 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableNewOobe) &&
84 !zero_delay_enabled &&
85 !waiting_for_wallpaper_load_;
86
87 initialize_webui_hidden_ = kHiddenWebUIInitializationDefault &&
88 (waiting_for_user_pods_ || waiting_for_wallpaper_load_);
83 89
84 if (waiting_for_wallpaper_load_) { 90 if (waiting_for_wallpaper_load_) {
85 registrar_.Add(this, chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, 91 registrar_.Add(this, chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED,
86 content::NotificationService::AllSources()); 92 content::NotificationService::AllSources());
93 }
94
95 if (waiting_for_user_pods_) {
96 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE,
97 content::NotificationService::AllSources());
98 }
99
100 if (waiting_for_wallpaper_load_ || waiting_for_user_pods_) {
87 // Prevents white flashing on OOBE (http://crbug.com/131569). 101 // Prevents white flashing on OOBE (http://crbug.com/131569).
88 aura::Env::GetInstance()->set_render_white_bg(false); 102 aura::Env::GetInstance()->set_render_white_bg(false);
103 }
89 104
90 // Check if WebUI init type is overriden. 105 // Check if WebUI init type is overriden.
91 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshWebUIInit)) { 106 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshWebUIInit)) {
92 const std::string override_type = CommandLine::ForCurrentProcess()-> 107 const std::string override_type = CommandLine::ForCurrentProcess()->
93 GetSwitchValueASCII(switches::kAshWebUIInit); 108 GetSwitchValueASCII(switches::kAshWebUIInit);
94 if (override_type == kWebUIInitParallel) 109 if (override_type == kWebUIInitParallel)
95 initialize_webui_in_parallel_ = true; 110 initialize_webui_hidden_ = true;
96 else if (override_type == kWebUIInitPostpone) 111 else if (override_type == kWebUIInitPostpone)
97 initialize_webui_in_parallel_ = false; 112 initialize_webui_hidden_ = false;
98 } 113 }
99 114
100 // Don't postpone WebUI initialization on first boot, otherwise we miss 115 // Always postpone WebUI initialization on first boot, otherwise we miss
101 // initial animation. 116 // initial animation.
102 if (!WizardController::IsOobeCompleted()) 117 if (!WizardController::IsOobeCompleted())
103 initialize_webui_in_parallel_ = false; 118 initialize_webui_hidden_ = false;
104 }
105 // In case if we're not waiting for wallpaper load,
106 // |initialize_webui_in_parallel_| value is ignored through the code flow.
107 } 119 }
108 120
109 WebUILoginDisplayHost::~WebUILoginDisplayHost() { 121 WebUILoginDisplayHost::~WebUILoginDisplayHost() {
110 if (login_window_) 122 if (login_window_)
111 login_window_->Close(); 123 login_window_->Close();
112 } 124 }
113 125
114 // LoginDisplayHost implementation --------------------------------------------- 126 // LoginDisplayHost implementation ---------------------------------------------
115 127
116 LoginDisplay* WebUILoginDisplayHost::CreateLoginDisplay( 128 LoginDisplay* WebUILoginDisplayHost::CreateLoginDisplay(
(...skipping 17 matching lines...) Expand all
134 } 146 }
135 147
136 void WebUILoginDisplayHost::SetOobeProgressBarVisible(bool visible) { 148 void WebUILoginDisplayHost::SetOobeProgressBarVisible(bool visible) {
137 GetOobeUI()->ShowOobeUI(visible); 149 GetOobeUI()->ShowOobeUI(visible);
138 } 150 }
139 151
140 void WebUILoginDisplayHost::SetShutdownButtonEnabled(bool enable) { 152 void WebUILoginDisplayHost::SetShutdownButtonEnabled(bool enable) {
141 } 153 }
142 154
143 void WebUILoginDisplayHost::SetStatusAreaVisible(bool visible) { 155 void WebUILoginDisplayHost::SetStatusAreaVisible(bool visible) {
144 if (waiting_for_wallpaper_load_ && initialize_webui_in_parallel_) 156 if (initialize_webui_hidden_)
145 status_area_saved_visibility_ = visible; 157 status_area_saved_visibility_ = visible;
146 else if (login_view_) 158 else if (login_view_)
147 login_view_->SetStatusAreaVisible(visible); 159 login_view_->SetStatusAreaVisible(visible);
148 } 160 }
149 161
150 void WebUILoginDisplayHost::StartWizard(const std::string& first_screen_name, 162 void WebUILoginDisplayHost::StartWizard(const std::string& first_screen_name,
151 DictionaryValue* screen_parameters) { 163 DictionaryValue* screen_parameters) {
152 // Keep parameters to restore if renderer crashes. 164 // Keep parameters to restore if renderer crashes.
153 restore_path_ = RESTORE_WIZARD; 165 restore_path_ = RESTORE_WIZARD;
154 wizard_first_screen_name_ = first_screen_name; 166 wizard_first_screen_name_ = first_screen_name;
155 if (screen_parameters) 167 if (screen_parameters)
156 wizard_screen_parameters_.reset(screen_parameters->DeepCopy()); 168 wizard_screen_parameters_.reset(screen_parameters->DeepCopy());
157 else 169 else
158 wizard_screen_parameters_.reset(NULL); 170 wizard_screen_parameters_.reset(NULL);
159 is_showing_login_ = false; 171 is_showing_login_ = false;
160 scoped_ptr<DictionaryValue> scoped_parameters(screen_parameters); 172 scoped_ptr<DictionaryValue> scoped_parameters(screen_parameters);
161 173
162 if (waiting_for_wallpaper_load_ && !initialize_webui_in_parallel_) 174 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_)
163 return; 175 return;
164 176
165 if (!login_window_) 177 if (!login_window_)
166 LoadURL(GURL(kOobeURL)); 178 LoadURL(GURL(kOobeURL));
167 179
168 BaseLoginDisplayHost::StartWizard(first_screen_name, 180 BaseLoginDisplayHost::StartWizard(first_screen_name,
169 scoped_parameters.release()); 181 scoped_parameters.release());
170 } 182 }
171 183
172 void WebUILoginDisplayHost::StartSignInScreen() { 184 void WebUILoginDisplayHost::StartSignInScreen() {
173 restore_path_ = RESTORE_SIGN_IN; 185 restore_path_ = RESTORE_SIGN_IN;
174 is_showing_login_ = true; 186 is_showing_login_ = true;
175 187
176 if (waiting_for_wallpaper_load_ && !initialize_webui_in_parallel_) 188 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_)
177 return; 189 return;
178 190
179 if (!login_window_) 191 if (!login_window_)
180 LoadURL(GURL(kLoginURL)); 192 LoadURL(GURL(kLoginURL));
181 193
182 BaseLoginDisplayHost::StartSignInScreen(); 194 BaseLoginDisplayHost::StartSignInScreen();
183 CHECK(webui_login_display_); 195 CHECK(webui_login_display_);
184 GetOobeUI()->ShowSigninScreen(webui_login_display_); 196 GetOobeUI()->ShowSigninScreen(webui_login_display_);
185 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) 197 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled())
186 SetStatusAreaVisible(false); 198 SetStatusAreaVisible(false);
(...skipping 20 matching lines...) Expand all
207 BaseLoginDisplayHost::Observe(type, source, details); 219 BaseLoginDisplayHost::Observe(type, source, details);
208 if (chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED == type) { 220 if (chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED == type) {
209 is_wallpaper_loaded_ = true; 221 is_wallpaper_loaded_ = true;
210 ash::Shell::GetInstance()->user_wallpaper_delegate()-> 222 ash::Shell::GetInstance()->user_wallpaper_delegate()->
211 OnWallpaperBootAnimationFinished(); 223 OnWallpaperBootAnimationFinished();
212 if (waiting_for_wallpaper_load_) { 224 if (waiting_for_wallpaper_load_) {
213 // StartWizard / StartSignInScreen could be called multiple times through 225 // StartWizard / StartSignInScreen could be called multiple times through
214 // the lifetime of host. 226 // the lifetime of host.
215 // Make sure that subsequent calls are not postponed. 227 // Make sure that subsequent calls are not postponed.
216 waiting_for_wallpaper_load_ = false; 228 waiting_for_wallpaper_load_ = false;
217 if (initialize_webui_in_parallel_) 229 if (initialize_webui_hidden_)
218 ShowWebUI(); 230 ShowWebUI();
219 else 231 else
220 StartPostponedWebUI(); 232 StartPostponedWebUI();
221 } 233 }
222 registrar_.Remove(this, 234 registrar_.Remove(this,
223 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, 235 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED,
224 content::NotificationService::AllSources()); 236 content::NotificationService::AllSources());
237 } else if (chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE == type) {
238 if (waiting_for_user_pods_ && initialize_webui_hidden_) {
239 waiting_for_user_pods_ = false;
240 ShowWebUI();
241 }
242 registrar_.Remove(this,
243 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE,
244 content::NotificationService::AllSources());
245 } else {
246 NOTREACHED();
225 } 247 }
226 } 248 }
227 249
228 void WebUILoginDisplayHost::LoadURL(const GURL& url) { 250 void WebUILoginDisplayHost::LoadURL(const GURL& url) {
229 if (!login_window_) { 251 if (!login_window_) {
230 views::Widget::InitParams params( 252 views::Widget::InitParams params(
231 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 253 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
232 params.bounds = background_bounds(); 254 params.bounds = background_bounds();
233 params.show_state = ui::SHOW_STATE_FULLSCREEN; 255 params.show_state = ui::SHOW_STATE_FULLSCREEN;
234 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableNewOobe)) 256 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableNewOobe))
(...skipping 12 matching lines...) Expand all
247 ash::SetWindowVisibilityAnimationDuration( 269 ash::SetWindowVisibilityAnimationDuration(
248 login_window_->GetNativeView(), 270 login_window_->GetNativeView(),
249 base::TimeDelta::FromMilliseconds(kLoginFadeoutTransitionDurationMs)); 271 base::TimeDelta::FromMilliseconds(kLoginFadeoutTransitionDurationMs));
250 ash::SetWindowVisibilityAnimationTransition( 272 ash::SetWindowVisibilityAnimationTransition(
251 login_window_->GetNativeView(), 273 login_window_->GetNativeView(),
252 ash::ANIMATE_HIDE); 274 ash::ANIMATE_HIDE);
253 275
254 login_window_->SetContentsView(login_view_); 276 login_window_->SetContentsView(login_view_);
255 login_view_->UpdateWindowType(); 277 login_view_->UpdateWindowType();
256 278
257 // When not waiting for wallpaper any request to load a URL in WebUI 279 // If WebUI is initialized in hidden state, show it only if we're no
258 // should trigger window visibility as well. 280 // longer waiting for wallpaper animation/user images loading. Otherwise,
259 // Otherwise, when we're waiting for wallpaper load then show WebUI 281 // always show it.
260 // right away only if it is not initialized in parallel i.e. was postponed. 282 if (!initialize_webui_hidden_ ||
261 // In case of WebUI being initialized in parallel with wallpaper load 283 (!waiting_for_wallpaper_load_ && !waiting_for_user_pods_)) {
262 // it will be hidden initially.
263 if (!waiting_for_wallpaper_load_ || !initialize_webui_in_parallel_)
264 login_window_->Show(); 284 login_window_->Show();
265 else 285 } else {
266 login_view_->set_is_hidden(true); 286 login_view_->set_is_hidden(true);
287 }
267 login_window_->GetNativeView()->SetName("WebUILoginView"); 288 login_window_->GetNativeView()->SetName("WebUILoginView");
268 login_view_->OnWindowCreated(); 289 login_view_->OnWindowCreated();
269 } 290 }
270 // Subscribe to crash events. 291 // Subscribe to crash events.
271 content::WebContentsObserver::Observe(login_view_->GetWebContents()); 292 content::WebContentsObserver::Observe(login_view_->GetWebContents());
272 login_view_->LoadURL(url); 293 login_view_->LoadURL(url);
273 } 294 }
274 295
275 void WebUILoginDisplayHost::RenderViewGone(base::TerminationStatus status) { 296 void WebUILoginDisplayHost::RenderViewGone(base::TerminationStatus status) {
276 // Do not try to restore on shutdown 297 // Do not try to restore on shutdown
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 case RESTORE_SIGN_IN: 365 case RESTORE_SIGN_IN:
345 StartSignInScreen(); 366 StartSignInScreen();
346 break; 367 break;
347 default: 368 default:
348 NOTREACHED(); 369 NOTREACHED();
349 break; 370 break;
350 } 371 }
351 } 372 }
352 373
353 } // namespace chromeos 374 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698