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 ~UserWallpaperDelegate() override {}
27 int GetAnimationType() override {
28 return ShouldShowInitialAnimation() ?
29 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE :
30 static_cast<int>(wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
33 bool ShouldShowInitialAnimation() override { return true; }
35 int GetAnimationDurationOverride() override {
36 // Return 0 to select the default.
40 void SetAnimationDurationOverride(int animation_duration_in_ms) override {
44 void UpdateWallpaper(bool clear_cache) override {
46 bitmap.allocN32Pixels(16, 16);
47 bitmap.eraseARGB(255, kBackgroundRed, kBackgroundGreen, kBackgroundBlue);
49 // In debug builds we generate a simple pattern that allows visually
50 // notice if transparency is broken.
52 SkAutoLockPixels alp(bitmap);
53 *bitmap.getAddr32(0,0) = SkColorSetRGB(0, 0, 0);
56 gfx::ImageSkia wallpaper = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
57 ash::Shell::GetInstance()
58 ->desktop_background_controller()
59 ->SetWallpaperImage(wallpaper, ash::WALLPAPER_LAYOUT_TILE);
62 void InitializeWallpaper() override { UpdateWallpaper(false); }
64 void OpenSetWallpaperPage() override {}
66 bool CanOpenSetWallpaperPage() override { return false; }
68 void OnWallpaperAnimationFinished() override {}
70 void OnWallpaperBootAnimationFinished() override {}
73 DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate);
78 ash::UserWallpaperDelegate* CreateSolidColorUserWallpaperDelegate() {
79 return new UserWallpaperDelegate();