| 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/base_login_display_host.h" | 5 #include "chrome/browser/chromeos/login/base_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/workspace_controller.h" // temporary until w2 is the default. | |
| 11 #include "base/bind.h" | 10 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 13 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 14 #include "base/logging.h" | 13 #include "base/logging.h" |
| 15 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
| 16 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/browser_shutdown.h" | 17 #include "chrome/browser/browser_shutdown.h" |
| 19 #include "chrome/browser/chromeos/cros/cros_library.h" | 18 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 20 #include "chrome/browser/chromeos/customization_document.h" | 19 #include "chrome/browser/chromeos/customization_document.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 50 #include "ui/compositor/layer_animation_element.h" | 49 #include "ui/compositor/layer_animation_element.h" |
| 51 #include "ui/compositor/layer_animation_sequence.h" | 50 #include "ui/compositor/layer_animation_sequence.h" |
| 52 #include "ui/compositor/layer_animator.h" | 51 #include "ui/compositor/layer_animator.h" |
| 53 #include "ui/compositor/scoped_layer_animation_settings.h" | 52 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 54 #include "ui/gfx/rect.h" | 53 #include "ui/gfx/rect.h" |
| 55 #include "ui/gfx/transform.h" | 54 #include "ui/gfx/transform.h" |
| 56 #include "ui/views/widget/widget.h" | 55 #include "ui/views/widget/widget.h" |
| 57 | 56 |
| 58 namespace { | 57 namespace { |
| 59 | 58 |
| 60 // Whether sign in transitions are enabled. | |
| 61 const bool kEnableBackgroundAnimation = false; | |
| 62 const bool kEnableBrowserWindowsOpacityAnimation = true; | |
| 63 const bool kEnableBrowserWindowsTransformAnimation = true; | |
| 64 | |
| 65 // Sign in transition timings. | |
| 66 static const int kBackgroundTransitionPauseMs = 100; | |
| 67 static const int kBackgroundTransitionDurationMs = 400; | |
| 68 static const int kBrowserTransitionPauseMs = 750; | |
| 69 static const int kBrowserTransitionDurationMs = 350; | |
| 70 | |
| 71 // Parameters for background transform transition. | |
| 72 const float kBackgroundScale = 1.05f; | |
| 73 const int kBackgroundTranslate = -50; | |
| 74 | |
| 75 // Parameters for browser transform transition. | |
| 76 const float kBrowserScale = 1.05f; | |
| 77 const int kBrowserTranslate = -50; | |
| 78 | |
| 79 // The delay of triggering initialization of the device policy subsystem | 59 // The delay of triggering initialization of the device policy subsystem |
| 80 // after the login screen is initialized. This makes sure that device policy | 60 // after the login screen is initialized. This makes sure that device policy |
| 81 // network requests are made while the system is idle waiting for user input. | 61 // network requests are made while the system is idle waiting for user input. |
| 82 const int64 kPolicyServiceInitializationDelayMilliseconds = 100; | 62 const int64 kPolicyServiceInitializationDelayMilliseconds = 100; |
| 83 | 63 |
| 84 // Determines the hardware keyboard from the given locale code | 64 // Determines the hardware keyboard from the given locale code |
| 85 // and the OEM layout information, and saves it to "Locale State". | 65 // and the OEM layout information, and saves it to "Locale State". |
| 86 // The information will be used in InputMethodUtil::GetHardwareInputMethodId(). | 66 // The information will be used in InputMethodUtil::GetHardwareInputMethodId(). |
| 87 void DetermineAndSaveHardwareKeyboard(const std::string& locale, | 67 void DetermineAndSaveHardwareKeyboard(const std::string& locale, |
| 88 const std::string& oem_layout) { | 68 const std::string& oem_layout) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 void BaseLoginDisplayHost::StartAnimation() { | 301 void BaseLoginDisplayHost::StartAnimation() { |
| 322 if (ash::Shell::GetContainer( | 302 if (ash::Shell::GetContainer( |
| 323 ash::Shell::GetPrimaryRootWindow(), | 303 ash::Shell::GetPrimaryRootWindow(), |
| 324 ash::internal::kShellWindowId_DesktopBackgroundContainer)-> | 304 ash::internal::kShellWindowId_DesktopBackgroundContainer)-> |
| 325 children().empty()) { | 305 children().empty()) { |
| 326 // If there is no background window, don't perform any animation on the | 306 // If there is no background window, don't perform any animation on the |
| 327 // default and background layer because there is nothing behind it. | 307 // default and background layer because there is nothing behind it. |
| 328 return; | 308 return; |
| 329 } | 309 } |
| 330 | 310 |
| 331 // If we've been explicitly told not to do login animations, we will skip most | 311 if (!command_line->HasSwitch(switches::kDisableLoginAnimations)) |
| 332 // of them. In particular, we'll avoid animating the background or animating | |
| 333 // the browser's transform. | |
| 334 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 335 bool disable_animations = command_line->HasSwitch( | |
| 336 switches::kDisableLoginAnimations); | |
| 337 | |
| 338 const bool do_background_animation = | |
| 339 !ash::internal::WorkspaceController::IsWorkspace2Enabled() && | |
| 340 kEnableBackgroundAnimation && !disable_animations; | |
| 341 | |
| 342 const bool do_browser_transform_animation = | |
| 343 kEnableBrowserWindowsTransformAnimation && !disable_animations; | |
| 344 | |
| 345 const bool do_browser_opacity_animation = | |
| 346 kEnableBrowserWindowsOpacityAnimation; | |
| 347 | |
| 348 // Background animation. | |
| 349 if (do_background_animation) { | |
| 350 ui::Layer* background_layer = | |
| 351 ash::Shell::GetContainer( | |
| 352 ash::Shell::GetPrimaryRootWindow(), | |
| 353 ash::internal::kShellWindowId_DesktopBackgroundContainer)-> | |
| 354 layer(); | |
| 355 | |
| 356 gfx::Transform background_transform; | |
| 357 background_transform.SetScale(kBackgroundScale, kBackgroundScale); | |
| 358 background_transform.SetTranslateX(kBackgroundTranslate); | |
| 359 background_transform.SetTranslateY(kBackgroundTranslate); | |
| 360 background_layer->SetTransform(background_transform); | |
| 361 | |
| 362 // Pause | |
| 363 ui::LayerAnimationElement::AnimatableProperties background_pause_properties; | |
| 364 background_pause_properties.insert(ui::LayerAnimationElement::TRANSFORM); | |
| 365 background_layer->GetAnimator()->StartAnimation( | |
| 366 new ui::LayerAnimationSequence( | |
| 367 ui::LayerAnimationElement::CreatePauseElement( | |
| 368 background_pause_properties, | |
| 369 base::TimeDelta::FromMilliseconds( | |
| 370 kBackgroundTransitionPauseMs)))); | |
| 371 | |
| 372 ui::ScopedLayerAnimationSettings settings(background_layer->GetAnimator()); | |
| 373 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | |
| 374 settings.SetTransitionDuration( | |
| 375 base::TimeDelta::FromMilliseconds(kBackgroundTransitionDurationMs)); | |
| 376 settings.SetTweenType(ui::Tween::EASE_OUT); | |
| 377 background_layer->SetTransform(gfx::Transform()); | |
| 378 } | |
| 379 | |
| 380 // Browser windows layer opacity and transform animation. | |
| 381 if (ash::internal::WorkspaceController::IsWorkspace2Enabled()) { | |
| 382 ash::Shell::GetInstance()->DoInitialWorkspaceAnimation(); | 312 ash::Shell::GetInstance()->DoInitialWorkspaceAnimation(); |
| 383 } else if (do_browser_transform_animation || do_browser_opacity_animation) { | |
| 384 ui::Layer* default_container_layer = | |
| 385 ash::Shell::GetContainer( | |
| 386 ash::Shell::GetPrimaryRootWindow(), | |
| 387 ash::internal::kShellWindowId_DefaultContainer)->layer(); | |
| 388 | |
| 389 ui::LayerAnimationElement::AnimatableProperties browser_pause_properties; | |
| 390 | |
| 391 // Set the initial opacity and transform. | |
| 392 if (do_browser_transform_animation) { | |
| 393 gfx::Transform browser_transform; | |
| 394 browser_transform.SetScale(kBrowserScale, kBrowserScale); | |
| 395 browser_transform.SetTranslateX(kBrowserTranslate); | |
| 396 browser_transform.SetTranslateY(kBrowserTranslate); | |
| 397 default_container_layer->SetTransform(browser_transform); | |
| 398 browser_pause_properties.insert(ui::LayerAnimationElement::TRANSFORM); | |
| 399 } | |
| 400 | |
| 401 if (do_browser_opacity_animation) { | |
| 402 default_container_layer->SetOpacity(0); | |
| 403 browser_pause_properties.insert(ui::LayerAnimationElement::OPACITY); | |
| 404 } | |
| 405 | |
| 406 // Pause. | |
| 407 default_container_layer->GetAnimator()->ScheduleAnimation( | |
| 408 new ui::LayerAnimationSequence( | |
| 409 ui::LayerAnimationElement::CreatePauseElement( | |
| 410 browser_pause_properties, | |
| 411 base::TimeDelta::FromMilliseconds(kBrowserTransitionPauseMs)))); | |
| 412 | |
| 413 ui::ScopedLayerAnimationSettings settings( | |
| 414 default_container_layer->GetAnimator()); | |
| 415 | |
| 416 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | |
| 417 settings.SetTransitionDuration( | |
| 418 base::TimeDelta::FromMilliseconds(kBrowserTransitionDurationMs)); | |
| 419 | |
| 420 if (do_browser_opacity_animation) { | |
| 421 // Should interpolate linearly. | |
| 422 default_container_layer->SetOpacity(1); | |
| 423 } | |
| 424 | |
| 425 if (do_browser_transform_animation) { | |
| 426 settings.SetTweenType(ui::Tween::EASE_OUT); | |
| 427 default_container_layer->SetTransform(gfx::Transform()); | |
| 428 } | |
| 429 } | |
| 430 } | 313 } |
| 431 | 314 |
| 432 void BaseLoginDisplayHost::OnOwnershipStatusCheckDone( | 315 void BaseLoginDisplayHost::OnOwnershipStatusCheckDone( |
| 433 DeviceSettingsService::OwnershipStatus status, | 316 DeviceSettingsService::OwnershipStatus status, |
| 434 bool current_user_is_owner) { | 317 bool current_user_is_owner) { |
| 435 if (status != DeviceSettingsService::OWNERSHIP_NONE) { | 318 if (status != DeviceSettingsService::OWNERSHIP_NONE) { |
| 436 // The device is already owned. No need for auto-enrollment checks. | 319 // The device is already owned. No need for auto-enrollment checks. |
| 437 VLOG(1) << "CheckForAutoEnrollment: device already owned"; | 320 VLOG(1) << "CheckForAutoEnrollment: device already owned"; |
| 438 return; | 321 return; |
| 439 } | 322 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 VLOG(1) << "Initial time zone: " << timezone_name; | 480 VLOG(1) << "Initial time zone: " << timezone_name; |
| 598 // Apply locale customizations only once to preserve whatever locale | 481 // Apply locale customizations only once to preserve whatever locale |
| 599 // user has changed to during OOBE. | 482 // user has changed to during OOBE. |
| 600 if (!timezone_name.empty()) { | 483 if (!timezone_name.empty()) { |
| 601 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( | 484 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( |
| 602 UTF8ToUTF16(timezone_name)); | 485 UTF8ToUTF16(timezone_name)); |
| 603 } | 486 } |
| 604 } | 487 } |
| 605 | 488 |
| 606 } // namespace chromeos | 489 } // namespace chromeos |
| OLD | NEW |