Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / ash / user_wallpaper_delegate_win.cc
blob6c1a2aece8af74bead36d4b352464efc0290666d
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 void UpdateWallpaper() OVERRIDE {
38 SkBitmap bitmap;
39 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
40 bitmap.allocPixels();
41 bitmap.eraseARGB(255, kBackgroundRed, kBackgroundGreen, kBackgroundBlue);
42 #if !defined(NDEBUG)
43 // In debug builds we generate a simple pattern that allows visually
44 // notice if transparency is broken.
46 SkAutoLockPixels alp(bitmap);
47 *bitmap.getAddr32(0,0) = SkColorSetRGB(0, 0, 0);
49 #endif
50 gfx::ImageSkia wallpaper = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
51 ash::Shell::GetInstance()->desktop_background_controller()->
52 SetCustomWallpaper(wallpaper, ash::WALLPAPER_LAYOUT_TILE);
55 virtual void InitializeWallpaper() OVERRIDE {
56 UpdateWallpaper();
59 virtual void OpenSetWallpaperPage() OVERRIDE {
62 virtual bool CanOpenSetWallpaperPage() OVERRIDE {
63 return false;
66 virtual void OnWallpaperAnimationFinished() OVERRIDE {
69 virtual void OnWallpaperBootAnimationFinished() OVERRIDE {
72 private:
73 DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate);
76 } // namespace
78 ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() {
79 return new UserWallpaperDelegate();