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/background/ash_user_wallpaper_delegate.h" | 5 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/desktop_background/desktop_background_controller.h" | 8 #include "ash/desktop_background/desktop_background_controller.h" |
9 #include "ash/desktop_background/desktop_background_resources.h" | 9 #include "ash/desktop_background/desktop_background_resources.h" |
10 #include "ash/wm/window_animations.h" | 10 #include "ash/wm/window_animations.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h" | 13 #include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h" |
14 #include "chrome/browser/chromeos/login/user_manager.h" | 14 #include "chrome/browser/chromeos/login/user_manager.h" |
15 #include "chrome/browser/chromeos/login/wizard_controller.h" | 15 #include "chrome/browser/chromeos/login/wizard_controller.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
19 #include "chrome/browser/ui/chrome_pages.h" | 19 #include "chrome/browser/ui/chrome_pages.h" |
20 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
23 | 23 |
24 namespace chromeos { | 24 namespace chromeos { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 class UserWallpaperDelegate: public ash::UserWallpaperDelegate { | 28 bool IsNormalWallpaperChange() { |
| 29 if (chromeos::UserManager::Get()->IsUserLoggedIn() || |
| 30 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableNewOobe) || |
| 31 WizardController::IsZeroDelayEnabled() || |
| 32 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kLoginManager)) { |
| 33 return true; |
| 34 } |
| 35 |
| 36 return false; |
| 37 } |
| 38 |
| 39 class UserWallpaperDelegate : public ash::UserWallpaperDelegate { |
29 public: | 40 public: |
30 UserWallpaperDelegate() { | 41 UserWallpaperDelegate() : boot_animation_finished_(false) { |
31 } | 42 } |
32 | 43 |
33 virtual ~UserWallpaperDelegate() { | 44 virtual ~UserWallpaperDelegate() { |
34 } | 45 } |
35 | 46 |
36 virtual ash::WindowVisibilityAnimationType GetAnimationType() OVERRIDE { | 47 virtual ash::WindowVisibilityAnimationType GetAnimationType() OVERRIDE { |
37 if (CommandLine::ForCurrentProcess()->HasSwitch( | 48 if (IsNormalWallpaperChange() || boot_animation_finished_) |
38 switches::kDisableNewOobe) || | |
39 WizardController::IsZeroDelayEnabled()) { | |
40 return ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE; | 49 return ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE; |
41 } | |
42 | 50 |
| 51 // It is a first boot case now. If kDisableBootAnimation flag |
| 52 // is passed, it only disables any transition after OOBE. |
43 bool is_registered = WizardController::IsDeviceRegistered(); | 53 bool is_registered = WizardController::IsDeviceRegistered(); |
44 // TODO(nkostylev): Figure out whether this would affect autotests as well. | 54 bool disable_boot_animation = CommandLine::ForCurrentProcess()-> |
45 if (is_registered) | 55 HasSwitch(switches::kDisableBootAnimation); |
| 56 if (is_registered && disable_boot_animation) |
46 return ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE; | 57 return ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE; |
47 else | 58 |
48 return ash::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE; | 59 return ash::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE; |
49 } | 60 } |
50 | 61 |
51 virtual void InitializeWallpaper() OVERRIDE { | 62 virtual void InitializeWallpaper() OVERRIDE { |
52 chromeos::UserManager::Get()->InitializeWallpaper(); | 63 chromeos::UserManager::Get()->InitializeWallpaper(); |
53 } | 64 } |
54 | 65 |
55 virtual void OpenSetWallpaperPage() OVERRIDE { | 66 virtual void OpenSetWallpaperPage() OVERRIDE { |
56 wallpaper_manager_util::OpenWallpaperManager(); | 67 wallpaper_manager_util::OpenWallpaperManager(); |
57 } | 68 } |
58 | 69 |
59 virtual bool CanOpenSetWallpaperPage() OVERRIDE { | 70 virtual bool CanOpenSetWallpaperPage() OVERRIDE { |
60 return !chromeos::UserManager::Get()->IsLoggedInAsGuest(); | 71 return !chromeos::UserManager::Get()->IsLoggedInAsGuest(); |
61 } | 72 } |
62 | 73 |
63 virtual void OnWallpaperAnimationFinished() OVERRIDE { | 74 virtual void OnWallpaperAnimationFinished() OVERRIDE { |
64 content::NotificationService::current()->Notify( | 75 content::NotificationService::current()->Notify( |
65 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, | 76 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, |
66 content::NotificationService::AllSources(), | 77 content::NotificationService::AllSources(), |
67 content::NotificationService::NoDetails()); | 78 content::NotificationService::NoDetails()); |
68 } | 79 } |
69 | 80 |
| 81 virtual void OnWallpaperBootAnimationFinished() OVERRIDE { |
| 82 // Make sure that boot animation type is used only once. |
| 83 boot_animation_finished_ = true; |
| 84 } |
| 85 |
70 private: | 86 private: |
| 87 bool boot_animation_finished_; |
| 88 |
71 DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate); | 89 DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate); |
72 }; | 90 }; |
73 | 91 |
74 } // namespace | 92 } // namespace |
75 | 93 |
76 ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() { | 94 ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() { |
77 return new chromeos::UserWallpaperDelegate(); | 95 return new chromeos::UserWallpaperDelegate(); |
78 } | 96 } |
79 | 97 |
80 } // namespace chromeos | 98 } // namespace chromeos |
OLD | NEW |