Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / background / ash_user_wallpaper_delegate.cc
blobf931995ebd8ec6de8df5b3191f8752572954d312
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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h"
7 #include "ash/shell.h"
8 #include "ash/desktop_background/user_wallpaper_delegate.h"
9 #include "ash/wm/window_animations.h"
10 #include "base/command_line.h"
11 #include "base/logging.h"
12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h"
14 #include "chrome/browser/chromeos/login/startup_utils.h"
15 #include "chrome/browser/chromeos/login/wallpaper_manager.h"
16 #include "chrome/browser/chromeos/login/wizard_controller.h"
17 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_finder.h"
20 #include "chrome/browser/ui/chrome_pages.h"
21 #include "chromeos/chromeos_switches.h"
22 #include "chromeos/login/login_state.h"
23 #include "content/public/browser/notification_service.h"
25 namespace chromeos {
27 namespace {
29 bool IsNormalWallpaperChange() {
30 if (chromeos::LoginState::Get()->IsUserLoggedIn() ||
31 !CommandLine::ForCurrentProcess()->HasSwitch(
32 switches::kFirstExecAfterBoot) ||
33 WizardController::IsZeroDelayEnabled() ||
34 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kLoginManager)) {
35 return true;
38 return false;
41 class UserWallpaperDelegate : public ash::UserWallpaperDelegate {
42 public:
43 UserWallpaperDelegate() : boot_animation_finished_(false) {
46 virtual ~UserWallpaperDelegate() {
49 virtual int GetAnimationType() OVERRIDE {
50 return ShouldShowInitialAnimation() ?
51 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE :
52 static_cast<int>(views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
55 virtual bool ShouldShowInitialAnimation() OVERRIDE {
56 if (IsNormalWallpaperChange() || boot_animation_finished_)
57 return false;
59 // It is a first boot case now. If kDisableBootAnimation flag
60 // is passed, it only disables any transition after OOBE.
61 // |kDisableOobeAnimation| disables OOBE animation for slow hardware.
62 bool is_registered = StartupUtils::IsDeviceRegistered();
63 const CommandLine* command_line = CommandLine::ForCurrentProcess();
64 bool disable_boot_animation = command_line->
65 HasSwitch(switches::kDisableBootAnimation);
66 bool disable_oobe_animation = command_line->
67 HasSwitch(switches::kDisableOobeAnimation);
68 if ((!is_registered && disable_oobe_animation) ||
69 (is_registered && disable_boot_animation))
70 return false;
72 return true;
75 virtual void UpdateWallpaper() OVERRIDE {
76 chromeos::WallpaperManager::Get()->UpdateWallpaper();
79 virtual void InitializeWallpaper() OVERRIDE {
80 chromeos::WallpaperManager::Get()->InitializeWallpaper();
83 virtual void OpenSetWallpaperPage() OVERRIDE {
84 wallpaper_manager_util::OpenWallpaperManager();
87 virtual bool CanOpenSetWallpaperPage() OVERRIDE {
88 return LoginState::Get()->IsUserAuthenticated();
91 virtual void OnWallpaperAnimationFinished() OVERRIDE {
92 content::NotificationService::current()->Notify(
93 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED,
94 content::NotificationService::AllSources(),
95 content::NotificationService::NoDetails());
98 virtual void OnWallpaperBootAnimationFinished() OVERRIDE {
99 // Make sure that boot animation type is used only once.
100 boot_animation_finished_ = true;
103 private:
104 bool boot_animation_finished_;
106 DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate);
109 } // namespace
111 ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() {
112 return new chromeos::UserWallpaperDelegate();
115 } // namespace chromeos