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 "chrome/browser/ui/ash/solid_color_user_wallpaper_delegate.h"
7 #include "ash/desktop_background/desktop_background_controller.h"
8 #include "ash/desktop_background/user_wallpaper_delegate.h"
10 #include "ash/wm/window_animations.h"
11 #include "base/basictypes.h"
12 #include "ui/gfx/image/image_skia.h"
16 const char kBackgroundRed = 70;
17 const char kBackgroundGreen = 70;
18 const char kBackgroundBlue = 78;
20 class UserWallpaperDelegate : public ash::UserWallpaperDelegate {
22 UserWallpaperDelegate() {
25 virtual ~UserWallpaperDelegate() {
28 virtual int GetAnimationType() OVERRIDE {
29 return ShouldShowInitialAnimation() ?
30 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE :
31 static_cast<int>(wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
34 virtual bool ShouldShowInitialAnimation() OVERRIDE {
38 virtual int GetAnimationDurationOverride() OVERRIDE {
39 // Return 0 to select the default.
43 virtual void SetAnimationDurationOverride(
44 int animation_duration_in_ms) OVERRIDE {
48 virtual void UpdateWallpaper(bool clear_cache) OVERRIDE {
50 bitmap.allocN32Pixels(16, 16);
51 bitmap.eraseARGB(255, kBackgroundRed, kBackgroundGreen, kBackgroundBlue);
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);
60 gfx::ImageSkia wallpaper = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
61 ash::Shell::GetInstance()
62 ->desktop_background_controller()
63 ->SetWallpaperImage(wallpaper, ash::WALLPAPER_LAYOUT_TILE);
66 virtual void InitializeWallpaper() OVERRIDE {
67 UpdateWallpaper(false);
70 virtual void OpenSetWallpaperPage() OVERRIDE {
73 virtual bool CanOpenSetWallpaperPage() OVERRIDE {
77 virtual void OnWallpaperAnimationFinished() OVERRIDE {
80 virtual void OnWallpaperBootAnimationFinished() OVERRIDE {
84 DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate);
89 ash::UserWallpaperDelegate* CreateSolidColorUserWallpaperDelegate() {
90 return new UserWallpaperDelegate();