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

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: Subscription fixes 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 enable tnitializing WebUI in hidden state (see
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 bool new_oobe_ui = !CommandLine::ForCurrentProcess()->
78 HasSwitch(switches::kDisableBootAnimation); 76 HasSwitch(switches::kDisableNewOobe);
79 waiting_for_wallpaper_load_ = !is_registered || !disable_boot_animation; 77
80 } else { 78 waiting_for_wallpaper_load_ =
81 waiting_for_wallpaper_load_ = false; 79 new_oobe_ui &&
80 !zero_delay_enabled &&
81 (is_registered || !disable_oobe_animation) &&
82 (!is_registered || !disable_boot_animation);
83
84 waiting_for_user_pods_ =
85 new_oobe_ui && !zero_delay_enabled && !waiting_for_wallpaper_load_;
86
87 initialize_webui_hidden_ = kHiddenWebUIInitializationDefault &&
88 (waiting_for_user_pods_ || waiting_for_wallpaper_load_);
89
90 // Prevents white flashing on OOBE (http://crbug.com/131569).
91 aura::Env::GetInstance()->set_render_white_bg(false);
92
93 // Check if WebUI init type is overriden.
94 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshWebUIInit)) {
95 const std::string override_type = CommandLine::ForCurrentProcess()->
96 GetSwitchValueASCII(switches::kAshWebUIInit);
97 if (override_type == kWebUIInitParallel)
98 initialize_webui_hidden_ = true;
99 else if (override_type == kWebUIInitPostpone)
100 initialize_webui_hidden_ = false;
82 } 101 }
83 102
103 // Always postpone WebUI initialization on first boot, otherwise we miss
104 // initial animation.
105 if (!WizardController::IsOobeCompleted())
106 initialize_webui_hidden_ = false;
107
84 if (waiting_for_wallpaper_load_) { 108 if (waiting_for_wallpaper_load_) {
85 registrar_.Add(this, chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, 109 registrar_.Add(this, chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED,
86 content::NotificationService::AllSources()); 110 content::NotificationService::AllSources());
87 // Prevents white flashing on OOBE (http://crbug.com/131569). 111 }
88 aura::Env::GetInstance()->set_render_white_bg(false);
89 112
90 // Check if WebUI init type is overriden. 113 if (waiting_for_user_pods_ && initialize_webui_hidden_) {
91 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshWebUIInit)) { 114 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE,
92 const std::string override_type = CommandLine::ForCurrentProcess()-> 115 content::NotificationService::AllSources());
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 }
99
100 // Don't postpone WebUI initialization on first boot, otherwise we miss
101 // initial animation.
102 if (!WizardController::IsOobeCompleted())
103 initialize_webui_in_parallel_ = false;
104 } 116 }
105 // In case if we're not waiting for wallpaper load,
106 // |initialize_webui_in_parallel_| value is ignored through the code flow.
107 } 117 }
108 118
109 WebUILoginDisplayHost::~WebUILoginDisplayHost() { 119 WebUILoginDisplayHost::~WebUILoginDisplayHost() {
110 if (login_window_) 120 if (login_window_)
111 login_window_->Close(); 121 login_window_->Close();
112 } 122 }
113 123
114 // LoginDisplayHost implementation --------------------------------------------- 124 // LoginDisplayHost implementation ---------------------------------------------
115 125
116 LoginDisplay* WebUILoginDisplayHost::CreateLoginDisplay( 126 LoginDisplay* WebUILoginDisplayHost::CreateLoginDisplay(
(...skipping 17 matching lines...) Expand all
134 } 144 }
135 145
136 void WebUILoginDisplayHost::SetOobeProgressBarVisible(bool visible) { 146 void WebUILoginDisplayHost::SetOobeProgressBarVisible(bool visible) {
137 GetOobeUI()->ShowOobeUI(visible); 147 GetOobeUI()->ShowOobeUI(visible);
138 } 148 }
139 149
140 void WebUILoginDisplayHost::SetShutdownButtonEnabled(bool enable) { 150 void WebUILoginDisplayHost::SetShutdownButtonEnabled(bool enable) {
141 } 151 }
142 152
143 void WebUILoginDisplayHost::SetStatusAreaVisible(bool visible) { 153 void WebUILoginDisplayHost::SetStatusAreaVisible(bool visible) {
144 if (waiting_for_wallpaper_load_ && initialize_webui_in_parallel_) 154 if (initialize_webui_hidden_)
145 status_area_saved_visibility_ = visible; 155 status_area_saved_visibility_ = visible;
146 else if (login_view_) 156 else if (login_view_)
147 login_view_->SetStatusAreaVisible(visible); 157 login_view_->SetStatusAreaVisible(visible);
148 } 158 }
149 159
150 void WebUILoginDisplayHost::StartWizard(const std::string& first_screen_name, 160 void WebUILoginDisplayHost::StartWizard(const std::string& first_screen_name,
151 DictionaryValue* screen_parameters) { 161 DictionaryValue* screen_parameters) {
152 // Keep parameters to restore if renderer crashes. 162 // Keep parameters to restore if renderer crashes.
153 restore_path_ = RESTORE_WIZARD; 163 restore_path_ = RESTORE_WIZARD;
154 wizard_first_screen_name_ = first_screen_name; 164 wizard_first_screen_name_ = first_screen_name;
155 if (screen_parameters) 165 if (screen_parameters)
156 wizard_screen_parameters_.reset(screen_parameters->DeepCopy()); 166 wizard_screen_parameters_.reset(screen_parameters->DeepCopy());
157 else 167 else
158 wizard_screen_parameters_.reset(NULL); 168 wizard_screen_parameters_.reset(NULL);
159 is_showing_login_ = false; 169 is_showing_login_ = false;
160 scoped_ptr<DictionaryValue> scoped_parameters(screen_parameters); 170 scoped_ptr<DictionaryValue> scoped_parameters(screen_parameters);
161 171
162 if (waiting_for_wallpaper_load_ && !initialize_webui_in_parallel_) 172 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_)
163 return; 173 return;
164 174
165 if (!login_window_) 175 if (!login_window_)
166 LoadURL(GURL(kOobeURL)); 176 LoadURL(GURL(kOobeURL));
167 177
168 BaseLoginDisplayHost::StartWizard(first_screen_name, 178 BaseLoginDisplayHost::StartWizard(first_screen_name,
169 scoped_parameters.release()); 179 scoped_parameters.release());
170 } 180 }
171 181
172 void WebUILoginDisplayHost::StartSignInScreen() { 182 void WebUILoginDisplayHost::StartSignInScreen() {
173 restore_path_ = RESTORE_SIGN_IN; 183 restore_path_ = RESTORE_SIGN_IN;
174 is_showing_login_ = true; 184 is_showing_login_ = true;
175 185
176 if (waiting_for_wallpaper_load_ && !initialize_webui_in_parallel_) 186 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_)
177 return; 187 return;
178 188
179 if (!login_window_) 189 if (!login_window_)
180 LoadURL(GURL(kLoginURL)); 190 LoadURL(GURL(kLoginURL));
181 191
182 BaseLoginDisplayHost::StartSignInScreen(); 192 BaseLoginDisplayHost::StartSignInScreen();
183 CHECK(webui_login_display_); 193 CHECK(webui_login_display_);
184 GetOobeUI()->ShowSigninScreen(webui_login_display_); 194 GetOobeUI()->ShowSigninScreen(webui_login_display_);
185 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) 195 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled())
186 SetStatusAreaVisible(false); 196 SetStatusAreaVisible(false);
(...skipping 20 matching lines...) Expand all
207 BaseLoginDisplayHost::Observe(type, source, details); 217 BaseLoginDisplayHost::Observe(type, source, details);
208 if (chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED == type) { 218 if (chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED == type) {
209 is_wallpaper_loaded_ = true; 219 is_wallpaper_loaded_ = true;
210 ash::Shell::GetInstance()->user_wallpaper_delegate()-> 220 ash::Shell::GetInstance()->user_wallpaper_delegate()->
211 OnWallpaperBootAnimationFinished(); 221 OnWallpaperBootAnimationFinished();
212 if (waiting_for_wallpaper_load_) { 222 if (waiting_for_wallpaper_load_) {
213 // StartWizard / StartSignInScreen could be called multiple times through 223 // StartWizard / StartSignInScreen could be called multiple times through
214 // the lifetime of host. 224 // the lifetime of host.
215 // Make sure that subsequent calls are not postponed. 225 // Make sure that subsequent calls are not postponed.
216 waiting_for_wallpaper_load_ = false; 226 waiting_for_wallpaper_load_ = false;
217 if (initialize_webui_in_parallel_) 227 if (initialize_webui_hidden_)
218 ShowWebUI(); 228 ShowWebUI();
219 else 229 else
220 StartPostponedWebUI(); 230 StartPostponedWebUI();
221 } 231 }
222 registrar_.Remove(this, 232 registrar_.Remove(this,
223 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, 233 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED,
224 content::NotificationService::AllSources()); 234 content::NotificationService::AllSources());
235 } else if (chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE == type) {
236 if (waiting_for_user_pods_ && initialize_webui_hidden_) {
237 waiting_for_user_pods_ = false;
238 ShowWebUI();
239 }
240 registrar_.Remove(this,
241 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE,
242 content::NotificationService::AllSources());
243 } else {
244 NOTREACHED();
225 } 245 }
226 } 246 }
227 247
228 void WebUILoginDisplayHost::LoadURL(const GURL& url) { 248 void WebUILoginDisplayHost::LoadURL(const GURL& url) {
229 if (!login_window_) { 249 if (!login_window_) {
230 views::Widget::InitParams params( 250 views::Widget::InitParams params(
231 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 251 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
232 params.bounds = background_bounds(); 252 params.bounds = background_bounds();
233 params.show_state = ui::SHOW_STATE_FULLSCREEN; 253 params.show_state = ui::SHOW_STATE_FULLSCREEN;
234 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableNewOobe)) 254 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableNewOobe))
(...skipping 12 matching lines...) Expand all
247 ash::SetWindowVisibilityAnimationDuration( 267 ash::SetWindowVisibilityAnimationDuration(
248 login_window_->GetNativeView(), 268 login_window_->GetNativeView(),
249 base::TimeDelta::FromMilliseconds(kLoginFadeoutTransitionDurationMs)); 269 base::TimeDelta::FromMilliseconds(kLoginFadeoutTransitionDurationMs));
250 ash::SetWindowVisibilityAnimationTransition( 270 ash::SetWindowVisibilityAnimationTransition(
251 login_window_->GetNativeView(), 271 login_window_->GetNativeView(),
252 ash::ANIMATE_HIDE); 272 ash::ANIMATE_HIDE);
253 273
254 login_window_->SetContentsView(login_view_); 274 login_window_->SetContentsView(login_view_);
255 login_view_->UpdateWindowType(); 275 login_view_->UpdateWindowType();
256 276
257 // When not waiting for wallpaper any request to load a URL in WebUI 277 // If WebUI is initialized in hidden state, show it only if we're no
258 // should trigger window visibility as well. 278 // longer waiting for wallpaper animation/user images loading. Otherwise,
259 // Otherwise, when we're waiting for wallpaper load then show WebUI 279 // always show it.
260 // right away only if it is not initialized in parallel i.e. was postponed. 280 if (!initialize_webui_hidden_ ||
261 // In case of WebUI being initialized in parallel with wallpaper load 281 (!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(); 282 login_window_->Show();
265 else 283 } else {
266 login_view_->set_is_hidden(true); 284 login_view_->set_is_hidden(true);
285 }
267 login_window_->GetNativeView()->SetName("WebUILoginView"); 286 login_window_->GetNativeView()->SetName("WebUILoginView");
268 login_view_->OnWindowCreated(); 287 login_view_->OnWindowCreated();
269 } 288 }
270 // Subscribe to crash events. 289 // Subscribe to crash events.
271 content::WebContentsObserver::Observe(login_view_->GetWebContents()); 290 content::WebContentsObserver::Observe(login_view_->GetWebContents());
272 login_view_->LoadURL(url); 291 login_view_->LoadURL(url);
273 } 292 }
274 293
275 void WebUILoginDisplayHost::RenderViewGone(base::TerminationStatus status) { 294 void WebUILoginDisplayHost::RenderViewGone(base::TerminationStatus status) {
276 // Do not try to restore on shutdown 295 // Do not try to restore on shutdown
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 case RESTORE_SIGN_IN: 363 case RESTORE_SIGN_IN:
345 StartSignInScreen(); 364 StartSignInScreen();
346 break; 365 break;
347 default: 366 default:
348 NOTREACHED(); 367 NOTREACHED();
349 break; 368 break;
350 } 369 }
351 } 370 }
352 371
353 } // namespace chromeos 372 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/webui_login_display_host.h ('k') | chrome/browser/resources/chromeos/login/display_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698