Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1699)

Side by Side Diff: ash/desktop_background/desktop_background_controller.cc

Issue 9580023: Enable user change background image in settings page in Aura build. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: More refactor Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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/desktop_background_controller.h"
6 #include "ash/desktop_background/desktop_background_view.h"
7 #include "base/logging.h"
8 #include "ui/gfx/image/image.h"
9 #include "grit/ui_resources.h"
10 #include "ui/base/resource/resource_bundle.h"
11
12 namespace ash {
13
14 const int kDefaultWallpaperResources[] = {
15 IDR_AURA_WALLPAPER_1,
16 IDR_AURA_WALLPAPER_2,
17 IDR_AURA_WALLPAPER_3,
18 IDR_AURA_WALLPAPER_4,
19 IDR_AURA_WALLPAPER_5,
20 IDR_AURA_WALLPAPER_6,
21 IDR_AURA_WALLPAPER_7,
22 IDR_AURA_WALLPAPER_8,
23 IDR_AURA_WALLPAPER_9,
24 };
25
26 const int kDefaultWallpaperResourcesThumb[] = {
27 IDR_AURA_WALLPAPER_1_THUMB,
28 IDR_AURA_WALLPAPER_2_THUMB,
29 IDR_AURA_WALLPAPER_3_THUMB,
30 IDR_AURA_WALLPAPER_4_THUMB,
31 IDR_AURA_WALLPAPER_5_THUMB,
32 IDR_AURA_WALLPAPER_6_THUMB,
33 IDR_AURA_WALLPAPER_7_THUMB,
34 IDR_AURA_WALLPAPER_8_THUMB,
35 IDR_AURA_WALLPAPER_9_THUMB,
36 };
37
38 const int kDefaultWallpaperCount = arraysize(kDefaultWallpaperResources);
39
40 const SkBitmap& GetDefaultWallpaper(int index) {
41 DCHECK(index >= 0 && index < kDefaultWallpaperCount);
42 return *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
43 kDefaultWallpaperResources[index]).ToSkBitmap();
44 }
45
46 const SkBitmap& GetDefaultWallpaperThumbnail(int index) {
47 DCHECK(index >= 0 && index < kDefaultWallpaperCount);
48 return *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
49 kDefaultWallpaperResourcesThumb[index]).ToSkBitmap();
50 }
51
52 DesktopBackgroundController::DesktopBackgroundController(){
53 }
54
55 DesktopBackgroundController::~DesktopBackgroundController() {
56 }
57
58 void DesktopBackgroundController::OnDesktopBackgroundChange(int index) {
59 DCHECK(index >=0 && index < kDefaultWallpaperCount);
60 internal::DesktopBackgroundView::GetInstance()->SetWallpaper(
61 GetDefaultWallpaper(index));
62 }
63
64 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698