| OLD | NEW |
| 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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/desktop_background/user_wallpaper_delegate.h" | 8 #include "ash/desktop_background/user_wallpaper_delegate.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| 11 #include "ash/wm/window_animations.h" | 11 #include "ash/wm/window_animations.h" |
| 12 #include "ash/wm/window_properties.h" |
| 12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/time.h" | 16 #include "base/time.h" |
| 16 #include "base/values.h" | 17 #include "base/values.h" |
| 17 #include "chrome/browser/browser_shutdown.h" | 18 #include "chrome/browser/browser_shutdown.h" |
| 18 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 19 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
| 19 #include "chrome/browser/chromeos/login/oobe_display.h" | 20 #include "chrome/browser/chromeos/login/oobe_display.h" |
| 20 #include "chrome/browser/chromeos/login/webui_login_display.h" | 21 #include "chrome/browser/chromeos/login/webui_login_display.h" |
| 21 #include "chrome/browser/chromeos/login/webui_login_view.h" | 22 #include "chrome/browser/chromeos/login/webui_login_view.h" |
| 22 #include "chrome/browser/chromeos/login/wizard_controller.h" | 23 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 23 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 24 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 24 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 26 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/browser/web_ui.h" | 29 #include "content/public/browser/web_ui.h" |
| 29 #include "ui/aura/env.h" | 30 #include "ui/aura/env.h" |
| 31 #include "ui/aura/root_window.h" |
| 30 #include "ui/aura/window.h" | 32 #include "ui/aura/window.h" |
| 31 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
| 32 | 34 |
| 33 namespace chromeos { | 35 namespace chromeos { |
| 34 | 36 |
| 35 namespace { | 37 namespace { |
| 36 | 38 |
| 37 // URL which corresponds to the login WebUI. | 39 // URL which corresponds to the login WebUI. |
| 38 const char kLoginURL[] = "chrome://oobe/login"; | 40 const char kLoginURL[] = "chrome://oobe/login"; |
| 39 // URL which corresponds to the OOBE WebUI. | 41 // URL which corresponds to the OOBE WebUI. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 59 | 61 |
| 60 WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds) | 62 WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds) |
| 61 : BaseLoginDisplayHost(background_bounds), | 63 : BaseLoginDisplayHost(background_bounds), |
| 62 login_window_(NULL), | 64 login_window_(NULL), |
| 63 login_view_(NULL), | 65 login_view_(NULL), |
| 64 webui_login_display_(NULL), | 66 webui_login_display_(NULL), |
| 65 is_showing_login_(false), | 67 is_showing_login_(false), |
| 66 is_wallpaper_loaded_(false), | 68 is_wallpaper_loaded_(false), |
| 67 status_area_saved_visibility_(false), | 69 status_area_saved_visibility_(false), |
| 68 crash_count_(0), | 70 crash_count_(0), |
| 69 restore_path_(RESTORE_UNKNOWN) { | 71 restore_path_(RESTORE_UNKNOWN), |
| 72 old_ignore_solo_window_frame_painter_policy_value_(false) { |
| 70 bool is_registered = WizardController::IsDeviceRegistered(); | 73 bool is_registered = WizardController::IsDeviceRegistered(); |
| 71 bool zero_delay_enabled = WizardController::IsZeroDelayEnabled(); | 74 bool zero_delay_enabled = WizardController::IsZeroDelayEnabled(); |
| 72 bool disable_boot_animation = CommandLine::ForCurrentProcess()-> | 75 bool disable_boot_animation = CommandLine::ForCurrentProcess()-> |
| 73 HasSwitch(switches::kDisableBootAnimation); | 76 HasSwitch(switches::kDisableBootAnimation); |
| 74 bool disable_oobe_animation = CommandLine::ForCurrentProcess()-> | 77 bool disable_oobe_animation = CommandLine::ForCurrentProcess()-> |
| 75 HasSwitch(switches::kDisableOobeAnimation); | 78 HasSwitch(switches::kDisableOobeAnimation); |
| 76 bool new_oobe_ui = !CommandLine::ForCurrentProcess()-> | 79 bool new_oobe_ui = !CommandLine::ForCurrentProcess()-> |
| 77 HasSwitch(switches::kDisableNewOobe); | 80 HasSwitch(switches::kDisableNewOobe); |
| 78 | 81 |
| 79 waiting_for_wallpaper_load_ = | 82 waiting_for_wallpaper_load_ = |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 content::NotificationService::AllSources()); | 132 content::NotificationService::AllSources()); |
| 130 } | 133 } |
| 131 LOG(INFO) << "Login WebUI >> " | 134 LOG(INFO) << "Login WebUI >> " |
| 132 << "zero_delay: " << zero_delay_enabled | 135 << "zero_delay: " << zero_delay_enabled |
| 133 << " wait_for_wp_load_: " << waiting_for_wallpaper_load_ | 136 << " wait_for_wp_load_: " << waiting_for_wallpaper_load_ |
| 134 << " wait_for_pods_: " << waiting_for_user_pods_ | 137 << " wait_for_pods_: " << waiting_for_user_pods_ |
| 135 << " init_webui_hidden_: " << initialize_webui_hidden_; | 138 << " init_webui_hidden_: " << initialize_webui_hidden_; |
| 136 } | 139 } |
| 137 | 140 |
| 138 WebUILoginDisplayHost::~WebUILoginDisplayHost() { | 141 WebUILoginDisplayHost::~WebUILoginDisplayHost() { |
| 139 if (login_window_) | 142 ResetLoginWindowAndView(); |
| 140 login_window_->Close(); | |
| 141 } | 143 } |
| 142 | 144 |
| 143 // LoginDisplayHost implementation --------------------------------------------- | 145 // LoginDisplayHost implementation --------------------------------------------- |
| 144 | 146 |
| 145 LoginDisplay* WebUILoginDisplayHost::CreateLoginDisplay( | 147 LoginDisplay* WebUILoginDisplayHost::CreateLoginDisplay( |
| 146 LoginDisplay::Delegate* delegate) { | 148 LoginDisplay::Delegate* delegate) { |
| 147 webui_login_display_ = new WebUILoginDisplay(delegate); | 149 webui_login_display_ = new WebUILoginDisplay(delegate); |
| 148 webui_login_display_->set_background_bounds(background_bounds()); | 150 webui_login_display_->set_background_bounds(background_bounds()); |
| 149 return webui_login_display_; | 151 return webui_login_display_; |
| 150 } | 152 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 SetStatusAreaVisible(false); | 223 SetStatusAreaVisible(false); |
| 222 } | 224 } |
| 223 | 225 |
| 224 void WebUILoginDisplayHost::OnPreferencesChanged() { | 226 void WebUILoginDisplayHost::OnPreferencesChanged() { |
| 225 if (is_showing_login_) | 227 if (is_showing_login_) |
| 226 webui_login_display_->OnPreferencesChanged(); | 228 webui_login_display_->OnPreferencesChanged(); |
| 227 } | 229 } |
| 228 | 230 |
| 229 void WebUILoginDisplayHost::OnBrowserCreated() { | 231 void WebUILoginDisplayHost::OnBrowserCreated() { |
| 230 // Close lock window now so that the launched browser can receive focus. | 232 // Close lock window now so that the launched browser can receive focus. |
| 231 if (login_window_) { | 233 ResetLoginWindowAndView(); |
| 232 login_window_->Close(); | |
| 233 login_window_ = NULL; | |
| 234 login_view_ = NULL; | |
| 235 } | |
| 236 } | 234 } |
| 237 | 235 |
| 238 void WebUILoginDisplayHost::Observe( | 236 void WebUILoginDisplayHost::Observe( |
| 239 int type, | 237 int type, |
| 240 const content::NotificationSource& source, | 238 const content::NotificationSource& source, |
| 241 const content::NotificationDetails& details) { | 239 const content::NotificationDetails& details) { |
| 242 if (chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED == type) { | 240 if (chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED == type) { |
| 243 LOG(INFO) << "Login WebUI >> wp animation done"; | 241 LOG(INFO) << "Login WebUI >> wp animation done"; |
| 244 is_wallpaper_loaded_ = true; | 242 is_wallpaper_loaded_ = true; |
| 245 ash::Shell::GetInstance()->user_wallpaper_delegate()-> | 243 ash::Shell::GetInstance()->user_wallpaper_delegate()-> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 269 } | 267 } |
| 270 registrar_.Remove(this, | 268 registrar_.Remove(this, |
| 271 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, | 269 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, |
| 272 content::NotificationService::AllSources()); | 270 content::NotificationService::AllSources()); |
| 273 } else { | 271 } else { |
| 274 BaseLoginDisplayHost::Observe(type, source, details); | 272 BaseLoginDisplayHost::Observe(type, source, details); |
| 275 } | 273 } |
| 276 } | 274 } |
| 277 | 275 |
| 278 void WebUILoginDisplayHost::LoadURL(const GURL& url) { | 276 void WebUILoginDisplayHost::LoadURL(const GURL& url) { |
| 279 if (!login_window_) { | 277 InitLoginWindowAndView(); |
| 280 views::Widget::InitParams params( | |
| 281 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | |
| 282 params.bounds = background_bounds(); | |
| 283 params.show_state = ui::SHOW_STATE_FULLSCREEN; | |
| 284 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableNewOobe)) | |
| 285 params.transparent = true; | |
| 286 params.parent = | |
| 287 ash::Shell::GetContainer( | |
| 288 ash::Shell::GetPrimaryRootWindow(), | |
| 289 ash::internal::kShellWindowId_LockScreenContainer); | |
| 290 | |
| 291 login_window_ = new views::Widget; | |
| 292 login_window_->Init(params); | |
| 293 login_view_ = new WebUILoginView(); | |
| 294 | |
| 295 login_view_->Init(login_window_); | |
| 296 | |
| 297 views::corewm::SetWindowVisibilityAnimationDuration( | |
| 298 login_window_->GetNativeView(), | |
| 299 base::TimeDelta::FromMilliseconds(kLoginFadeoutTransitionDurationMs)); | |
| 300 views::corewm::SetWindowVisibilityAnimationTransition( | |
| 301 login_window_->GetNativeView(), | |
| 302 views::corewm::ANIMATE_HIDE); | |
| 303 | |
| 304 login_window_->SetContentsView(login_view_); | |
| 305 login_view_->UpdateWindowType(); | |
| 306 | |
| 307 // If WebUI is initialized in hidden state, show it only if we're no | |
| 308 // longer waiting for wallpaper animation/user images loading. Otherwise, | |
| 309 // always show it. | |
| 310 if (!initialize_webui_hidden_ || | |
| 311 (!waiting_for_wallpaper_load_ && !waiting_for_user_pods_)) { | |
| 312 LOG(INFO) << "Login WebUI >> show login wnd on create"; | |
| 313 login_window_->Show(); | |
| 314 } else { | |
| 315 LOG(INFO) << "Login WebUI >> login wnd is hidden on create"; | |
| 316 login_view_->set_is_hidden(true); | |
| 317 } | |
| 318 login_window_->GetNativeView()->SetName("WebUILoginView"); | |
| 319 login_view_->OnWindowCreated(); | |
| 320 } | |
| 321 // Subscribe to crash events. | 278 // Subscribe to crash events. |
| 322 content::WebContentsObserver::Observe(login_view_->GetWebContents()); | 279 content::WebContentsObserver::Observe(login_view_->GetWebContents()); |
| 323 login_view_->LoadURL(url); | 280 login_view_->LoadURL(url); |
| 324 } | 281 } |
| 325 | 282 |
| 326 void WebUILoginDisplayHost::RenderViewGone(base::TerminationStatus status) { | 283 void WebUILoginDisplayHost::RenderViewGone(base::TerminationStatus status) { |
| 327 // Do not try to restore on shutdown | 284 // Do not try to restore on shutdown |
| 328 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID) | 285 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID) |
| 329 return; | 286 return; |
| 330 | 287 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 break; | 353 break; |
| 397 case RESTORE_SIGN_IN: | 354 case RESTORE_SIGN_IN: |
| 398 StartSignInScreen(); | 355 StartSignInScreen(); |
| 399 break; | 356 break; |
| 400 default: | 357 default: |
| 401 NOTREACHED(); | 358 NOTREACHED(); |
| 402 break; | 359 break; |
| 403 } | 360 } |
| 404 } | 361 } |
| 405 | 362 |
| 363 void WebUILoginDisplayHost::InitLoginWindowAndView() { |
| 364 if (login_window_) |
| 365 return; |
| 366 |
| 367 views::Widget::InitParams params( |
| 368 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 369 params.bounds = background_bounds(); |
| 370 params.show_state = ui::SHOW_STATE_FULLSCREEN; |
| 371 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableNewOobe)) |
| 372 params.transparent = true; |
| 373 params.parent = |
| 374 ash::Shell::GetContainer( |
| 375 ash::Shell::GetPrimaryRootWindow(), |
| 376 ash::internal::kShellWindowId_LockScreenContainer); |
| 377 |
| 378 login_window_ = new views::Widget; |
| 379 login_window_->Init(params); |
| 380 if (login_window_->GetNativeWindow()) { |
| 381 aura::RootWindow* root = login_window_->GetNativeWindow()->GetRootWindow(); |
| 382 if (root) { |
| 383 old_ignore_solo_window_frame_painter_policy_value_ = |
| 384 root->GetProperty(ash::internal::kIgnoreSoloWindowFramePainterPolicy); |
| 385 root->SetProperty(ash::internal::kIgnoreSoloWindowFramePainterPolicy, |
| 386 true); |
| 387 } |
| 388 } |
| 389 login_view_ = new WebUILoginView(); |
| 390 |
| 391 login_view_->Init(login_window_); |
| 392 |
| 393 views::corewm::SetWindowVisibilityAnimationDuration( |
| 394 login_window_->GetNativeView(), |
| 395 base::TimeDelta::FromMilliseconds(kLoginFadeoutTransitionDurationMs)); |
| 396 views::corewm::SetWindowVisibilityAnimationTransition( |
| 397 login_window_->GetNativeView(), |
| 398 views::corewm::ANIMATE_HIDE); |
| 399 |
| 400 login_window_->SetContentsView(login_view_); |
| 401 login_view_->UpdateWindowType(); |
| 402 |
| 403 // If WebUI is initialized in hidden state, show it only if we're no |
| 404 // longer waiting for wallpaper animation/user images loading. Otherwise, |
| 405 // always show it. |
| 406 if (!initialize_webui_hidden_ || |
| 407 (!waiting_for_wallpaper_load_ && !waiting_for_user_pods_)) { |
| 408 LOG(INFO) << "Login WebUI >> show login wnd on create"; |
| 409 login_window_->Show(); |
| 410 } else { |
| 411 LOG(INFO) << "Login WebUI >> login wnd is hidden on create"; |
| 412 login_view_->set_is_hidden(true); |
| 413 } |
| 414 login_window_->GetNativeView()->SetName("WebUILoginView"); |
| 415 login_view_->OnWindowCreated(); |
| 416 } |
| 417 |
| 418 void WebUILoginDisplayHost::ResetLoginWindowAndView() { |
| 419 if (!login_window_) |
| 420 return; |
| 421 |
| 422 if (login_window_->GetNativeWindow()) { |
| 423 aura::RootWindow* root = login_window_->GetNativeWindow()->GetRootWindow(); |
| 424 if (root) { |
| 425 root->SetProperty(ash::internal::kIgnoreSoloWindowFramePainterPolicy, |
| 426 old_ignore_solo_window_frame_painter_policy_value_); |
| 427 } |
| 428 } |
| 429 login_window_->Close(); |
| 430 login_window_ = NULL; |
| 431 login_view_ = NULL; |
| 432 } |
| 433 |
| 406 } // namespace chromeos | 434 } // namespace chromeos |
| OLD | NEW |