| 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/desktop_background/user_wallpaper_delegate.h" | 7 #include "ash/desktop_background/user_wallpaper_delegate.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/wm/window_animations.h" | 9 #include "ash/wm/window_animations.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 class UserWallpaperDelegate : public ash::UserWallpaperDelegate { | 39 class UserWallpaperDelegate : public ash::UserWallpaperDelegate { |
| 40 public: | 40 public: |
| 41 UserWallpaperDelegate() | 41 UserWallpaperDelegate() |
| 42 : boot_animation_finished_(false), | 42 : boot_animation_finished_(false), |
| 43 animation_duration_override_in_ms_(0) { | 43 animation_duration_override_in_ms_(0) { |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual ~UserWallpaperDelegate() { | 46 virtual ~UserWallpaperDelegate() { |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual int GetAnimationType() OVERRIDE { | 49 virtual int GetAnimationType() override { |
| 50 return ShouldShowInitialAnimation() ? | 50 return ShouldShowInitialAnimation() ? |
| 51 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE : | 51 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE : |
| 52 static_cast<int>(wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); | 52 static_cast<int>(wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual int GetAnimationDurationOverride() OVERRIDE { | 55 virtual int GetAnimationDurationOverride() override { |
| 56 return animation_duration_override_in_ms_; | 56 return animation_duration_override_in_ms_; |
| 57 } | 57 } |
| 58 | 58 |
| 59 virtual void SetAnimationDurationOverride( | 59 virtual void SetAnimationDurationOverride( |
| 60 int animation_duration_in_ms) OVERRIDE { | 60 int animation_duration_in_ms) override { |
| 61 animation_duration_override_in_ms_ = animation_duration_in_ms; | 61 animation_duration_override_in_ms_ = animation_duration_in_ms; |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual bool ShouldShowInitialAnimation() OVERRIDE { | 64 virtual bool ShouldShowInitialAnimation() override { |
| 65 if (IsNormalWallpaperChange() || boot_animation_finished_) | 65 if (IsNormalWallpaperChange() || boot_animation_finished_) |
| 66 return false; | 66 return false; |
| 67 | 67 |
| 68 // It is a first boot case now. If kDisableBootAnimation flag | 68 // It is a first boot case now. If kDisableBootAnimation flag |
| 69 // is passed, it only disables any transition after OOBE. | 69 // is passed, it only disables any transition after OOBE. |
| 70 bool is_registered = StartupUtils::IsDeviceRegistered(); | 70 bool is_registered = StartupUtils::IsDeviceRegistered(); |
| 71 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 71 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 72 bool disable_boot_animation = command_line-> | 72 bool disable_boot_animation = command_line-> |
| 73 HasSwitch(switches::kDisableBootAnimation); | 73 HasSwitch(switches::kDisableBootAnimation); |
| 74 if (is_registered && disable_boot_animation) | 74 if (is_registered && disable_boot_animation) |
| 75 return false; | 75 return false; |
| 76 | 76 |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 | 79 |
| 80 virtual void UpdateWallpaper(bool clear_cache) OVERRIDE { | 80 virtual void UpdateWallpaper(bool clear_cache) override { |
| 81 chromeos::WallpaperManager::Get()->UpdateWallpaper(clear_cache); | 81 chromeos::WallpaperManager::Get()->UpdateWallpaper(clear_cache); |
| 82 } | 82 } |
| 83 | 83 |
| 84 virtual void InitializeWallpaper() OVERRIDE { | 84 virtual void InitializeWallpaper() override { |
| 85 chromeos::WallpaperManager::Get()->InitializeWallpaper(); | 85 chromeos::WallpaperManager::Get()->InitializeWallpaper(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 virtual void OpenSetWallpaperPage() OVERRIDE { | 88 virtual void OpenSetWallpaperPage() override { |
| 89 if (CanOpenSetWallpaperPage()) | 89 if (CanOpenSetWallpaperPage()) |
| 90 wallpaper_manager_util::OpenWallpaperManager(); | 90 wallpaper_manager_util::OpenWallpaperManager(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 virtual bool CanOpenSetWallpaperPage() OVERRIDE { | 93 virtual bool CanOpenSetWallpaperPage() override { |
| 94 const LoginState* login_state = LoginState::Get(); | 94 const LoginState* login_state = LoginState::Get(); |
| 95 const LoginState::LoggedInUserType user_type = | 95 const LoginState::LoggedInUserType user_type = |
| 96 login_state->GetLoggedInUserType(); | 96 login_state->GetLoggedInUserType(); |
| 97 if (!login_state->IsUserLoggedIn()) | 97 if (!login_state->IsUserLoggedIn()) |
| 98 return false; | 98 return false; |
| 99 | 99 |
| 100 // Whitelist user types that are allowed to change their wallpaper. (Guest | 100 // Whitelist user types that are allowed to change their wallpaper. (Guest |
| 101 // users are not, see crosbug 26900.) | 101 // users are not, see crosbug 26900.) |
| 102 if (user_type != LoginState::LOGGED_IN_USER_REGULAR && | 102 if (user_type != LoginState::LOGGED_IN_USER_REGULAR && |
| 103 user_type != LoginState::LOGGED_IN_USER_OWNER && | 103 user_type != LoginState::LOGGED_IN_USER_OWNER && |
| 104 user_type != LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT && | 104 user_type != LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT && |
| 105 user_type != LoginState::LOGGED_IN_USER_SUPERVISED) { | 105 user_type != LoginState::LOGGED_IN_USER_SUPERVISED) { |
| 106 return false; | 106 return false; |
| 107 } | 107 } |
| 108 const user_manager::User* user = | 108 const user_manager::User* user = |
| 109 user_manager::UserManager::Get()->GetActiveUser(); | 109 user_manager::UserManager::Get()->GetActiveUser(); |
| 110 if (!user) | 110 if (!user) |
| 111 return false; | 111 return false; |
| 112 if (chromeos::WallpaperManager::Get()->IsPolicyControlled(user->email())) | 112 if (chromeos::WallpaperManager::Get()->IsPolicyControlled(user->email())) |
| 113 return false; | 113 return false; |
| 114 return true; | 114 return true; |
| 115 } | 115 } |
| 116 | 116 |
| 117 virtual void OnWallpaperAnimationFinished() OVERRIDE { | 117 virtual void OnWallpaperAnimationFinished() override { |
| 118 content::NotificationService::current()->Notify( | 118 content::NotificationService::current()->Notify( |
| 119 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, | 119 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, |
| 120 content::NotificationService::AllSources(), | 120 content::NotificationService::AllSources(), |
| 121 content::NotificationService::NoDetails()); | 121 content::NotificationService::NoDetails()); |
| 122 } | 122 } |
| 123 | 123 |
| 124 virtual void OnWallpaperBootAnimationFinished() OVERRIDE { | 124 virtual void OnWallpaperBootAnimationFinished() override { |
| 125 // Make sure that boot animation type is used only once. | 125 // Make sure that boot animation type is used only once. |
| 126 boot_animation_finished_ = true; | 126 boot_animation_finished_ = true; |
| 127 } | 127 } |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 bool boot_animation_finished_; | 130 bool boot_animation_finished_; |
| 131 | 131 |
| 132 // The animation duration to show a new wallpaper if an animation is required. | 132 // The animation duration to show a new wallpaper if an animation is required. |
| 133 int animation_duration_override_in_ms_; | 133 int animation_duration_override_in_ms_; |
| 134 | 134 |
| 135 DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate); | 135 DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate); |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 } // namespace | 138 } // namespace |
| 139 | 139 |
| 140 ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() { | 140 ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() { |
| 141 return new chromeos::UserWallpaperDelegate(); | 141 return new chromeos::UserWallpaperDelegate(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace chromeos | 144 } // namespace chromeos |
| OLD | NEW |