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 30 matching lines...) Expand all Loading... | |
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. | 59 // Whether sign in transitions are enabled. |
61 const bool kEnableBackgroundAnimation = false; | 60 const bool kEnableBackgroundAnimation = false; |
Nikita (slow)
2012/10/17 14:43:11
You could remove these too.
| |
62 const bool kEnableBrowserWindowsOpacityAnimation = true; | 61 const bool kEnableBrowserWindowsOpacityAnimation = true; |
63 const bool kEnableBrowserWindowsTransformAnimation = true; | 62 const bool kEnableBrowserWindowsTransformAnimation = true; |
64 | 63 |
65 // Sign in transition timings. | 64 // Sign in transition timings. |
66 static const int kBackgroundTransitionPauseMs = 100; | 65 static const int kBackgroundTransitionPauseMs = 100; |
Nikita (slow)
2012/10/17 14:43:11
These constants are not needed.
| |
67 static const int kBackgroundTransitionDurationMs = 400; | 66 static const int kBackgroundTransitionDurationMs = 400; |
68 static const int kBrowserTransitionPauseMs = 750; | 67 static const int kBrowserTransitionPauseMs = 750; |
69 static const int kBrowserTransitionDurationMs = 350; | 68 static const int kBrowserTransitionDurationMs = 350; |
70 | 69 |
71 // Parameters for background transform transition. | 70 // Parameters for background transform transition. |
72 const float kBackgroundScale = 1.05f; | 71 const float kBackgroundScale = 1.05f; |
73 const int kBackgroundTranslate = -50; | 72 const int kBackgroundTranslate = -50; |
74 | 73 |
75 // Parameters for browser transform transition. | 74 // Parameters for browser transform transition. |
76 const float kBrowserScale = 1.05f; | 75 const float kBrowserScale = 1.05f; |
77 const int kBrowserTranslate = -50; | 76 const int kBrowserTranslate = -50; |
Nikita (slow)
2012/10/17 14:43:11
And these too.
| |
78 | 77 |
79 // The delay of triggering initialization of the device policy subsystem | 78 // The delay of triggering initialization of the device policy subsystem |
80 // after the login screen is initialized. This makes sure that device policy | 79 // 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. | 80 // network requests are made while the system is idle waiting for user input. |
82 const int64 kPolicyServiceInitializationDelayMilliseconds = 100; | 81 const int64 kPolicyServiceInitializationDelayMilliseconds = 100; |
83 | 82 |
84 // Determines the hardware keyboard from the given locale code | 83 // Determines the hardware keyboard from the given locale code |
85 // and the OEM layout information, and saves it to "Locale State". | 84 // and the OEM layout information, and saves it to "Locale State". |
86 // The information will be used in InputMethodUtil::GetHardwareInputMethodId(). | 85 // The information will be used in InputMethodUtil::GetHardwareInputMethodId(). |
87 void DetermineAndSaveHardwareKeyboard(const std::string& locale, | 86 void DetermineAndSaveHardwareKeyboard(const std::string& locale, |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 void BaseLoginDisplayHost::StartAnimation() { | 320 void BaseLoginDisplayHost::StartAnimation() { |
322 if (ash::Shell::GetContainer( | 321 if (ash::Shell::GetContainer( |
323 ash::Shell::GetPrimaryRootWindow(), | 322 ash::Shell::GetPrimaryRootWindow(), |
324 ash::internal::kShellWindowId_DesktopBackgroundContainer)-> | 323 ash::internal::kShellWindowId_DesktopBackgroundContainer)-> |
325 children().empty()) { | 324 children().empty()) { |
326 // If there is no background window, don't perform any animation on the | 325 // If there is no background window, don't perform any animation on the |
327 // default and background layer because there is nothing behind it. | 326 // default and background layer because there is nothing behind it. |
328 return; | 327 return; |
329 } | 328 } |
330 | 329 |
331 // If we've been explicitly told not to do login animations, we will skip most | |
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( | |
Nikita (slow)
2012/10/17 14:43:11
Is this switch to disable login animations honored
sky
2012/10/17 14:56:02
Doesn't look like that code path was wired up for
| |
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. | 330 // Browser windows layer opacity and transform animation. |
381 if (ash::internal::WorkspaceController::IsWorkspace2Enabled()) { | 331 ash::Shell::GetInstance()->DoInitialWorkspaceAnimation(); |
382 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 } | 332 } |
431 | 333 |
432 void BaseLoginDisplayHost::OnOwnershipStatusCheckDone( | 334 void BaseLoginDisplayHost::OnOwnershipStatusCheckDone( |
433 DeviceSettingsService::OwnershipStatus status, | 335 DeviceSettingsService::OwnershipStatus status, |
434 bool current_user_is_owner) { | 336 bool current_user_is_owner) { |
435 if (status != DeviceSettingsService::OWNERSHIP_NONE) { | 337 if (status != DeviceSettingsService::OWNERSHIP_NONE) { |
436 // The device is already owned. No need for auto-enrollment checks. | 338 // The device is already owned. No need for auto-enrollment checks. |
437 VLOG(1) << "CheckForAutoEnrollment: device already owned"; | 339 VLOG(1) << "CheckForAutoEnrollment: device already owned"; |
438 return; | 340 return; |
439 } | 341 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
597 VLOG(1) << "Initial time zone: " << timezone_name; | 499 VLOG(1) << "Initial time zone: " << timezone_name; |
598 // Apply locale customizations only once to preserve whatever locale | 500 // Apply locale customizations only once to preserve whatever locale |
599 // user has changed to during OOBE. | 501 // user has changed to during OOBE. |
600 if (!timezone_name.empty()) { | 502 if (!timezone_name.empty()) { |
601 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( | 503 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( |
602 UTF8ToUTF16(timezone_name)); | 504 UTF8ToUTF16(timezone_name)); |
603 } | 505 } |
604 } | 506 } |
605 | 507 |
606 } // namespace chromeos | 508 } // namespace chromeos |
OLD | NEW |