NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / ui / ash / user_wallpaper_delegate_win.cc
blob6a83c600893e14e5ea0c0355c62cf95d48fe6c1b
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.
5 #include "ash/desktop_background/user_wallpaper_delegate.h"
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"
13 namespace {
15 const char kBackgroundRed = 70;
16 const char kBackgroundGreen = 70;
17 const char kBackgroundBlue = 78;
19 class UserWallpaperDelegate : public ash::UserWallpaperDelegate {
20 public:
21 UserWallpaperDelegate() {
24 virtual ~UserWallpaperDelegate() {
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);
33 virtual bool ShouldShowInitialAnimation() OVERRIDE {
34 return true;
37 virtual int GetAnimationDurationOverride() OVERRIDE {
38 // Return 0 to select the default.
39 return 0;
42 virtual void SetAnimationDurationOverride(
43 int animation_duration_in_ms) OVERRIDE {
44 NOTIMPLEMENTED();
47 virtual void UpdateWallpaper() OVERRIDE {
48 SkBitmap bitmap;
49 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
50 bitmap.allocPixels();
51 bitmap.eraseARGB(255, kBackgroundRed, kBackgroundGreen, kBackgroundBlue);
52 #if !defined(NDEBUG)
53 // In debug builds we generate a simple pattern that allows visually
54 // notice if transparency is broken.
56 SkAutoLockPixels alp(bitmap);
57 *bitmap.getAddr32(0,0) = SkColorSetRGB(0, 0, 0);
59 #endif
60 gfx::ImageSkia wallpaper = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
61 ash::Shell::GetInstance()->desktop_background_controller()->
62 SetCustomWallpaper(wallpaper, ash::WALLPAPER_LAYOUT_TILE);
65 virtual void InitializeWallpaper() OVERRIDE {
66 UpdateWallpaper();
69 virtual void OpenSetWallpaperPage() OVERRIDE {
72 virtual bool CanOpenSetWallpaperPage() OVERRIDE {
73 return false;
76 virtual void OnWallpaperAnimationFinished() OVERRIDE {
79 virtual void OnWallpaperBootAnimationFinished() OVERRIDE {
82 private:
83 DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate);
86 } // namespace
88 ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() {
89 return new UserWallpaperDelegate();