- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / ash / user_wallpaper_delegate_win.cc
1 // Copyright (c) 2013 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.
4
5 #include "ash/desktop_background/user_wallpaper_delegate.h"
6
7 #include "ash/desktop_background/desktop_background_controller.h"
8 #include "ash/shell.h"
9 #include "ash/wm/window_animations.h"
10 #include "base/basictypes.h"
11 #include "ui/gfx/image/image_skia.h"
12
13 namespace {
14
15 const char kBackgroundRed   = 70;
16 const char kBackgroundGreen = 70;
17 const char kBackgroundBlue  = 78;
18
19 class UserWallpaperDelegate : public ash::UserWallpaperDelegate {
20  public:
21   UserWallpaperDelegate() {
22   }
23
24   virtual ~UserWallpaperDelegate() {
25   }
26
27   virtual int GetAnimationType() OVERRIDE {
28     return ShouldShowInitialAnimation() ?
29         ash::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE :
30         static_cast<int>(views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
31   }
32
33   virtual bool ShouldShowInitialAnimation() OVERRIDE {
34     return true;
35   }
36
37   virtual void UpdateWallpaper() OVERRIDE {
38   }
39
40   virtual void InitializeWallpaper() OVERRIDE {
41     SkBitmap bitmap;
42     bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
43     bitmap.allocPixels();
44     bitmap.eraseARGB(255, kBackgroundRed, kBackgroundGreen, kBackgroundBlue);
45     gfx::ImageSkia wallpaper =
46         gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
47     ash::Shell::GetInstance()->desktop_background_controller()->
48         SetCustomWallpaper(wallpaper, ash::WALLPAPER_LAYOUT_TILE);
49   }
50
51   virtual void OpenSetWallpaperPage() OVERRIDE {
52   }
53
54   virtual bool CanOpenSetWallpaperPage() OVERRIDE {
55     return false;
56   }
57
58   virtual void OnWallpaperAnimationFinished() OVERRIDE {
59   }
60
61   virtual void OnWallpaperBootAnimationFinished() OVERRIDE {
62   }
63
64  private:
65   DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate);
66 };
67
68 }  // namespace
69
70 ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() {
71   return new UserWallpaperDelegate();
72 }