blob: 0b80157f8e87e5f0c04b73cce4099aee96fb00d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_
#define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_
#pragma once
#include "ash/ash_export.h"
#include "ash/desktop_background/desktop_background_resources.h"
#include "base/basictypes.h"
#include "base/memory/weak_ptr.h"
namespace gfx {
class ImageSkia;
}
namespace ash {
class UserWallpaperDelegate {
public:
virtual ~UserWallpaperDelegate() {}
// Gets the index of user selected wallpaper.
virtual const int GetUserWallpaperIndex() = 0;
// Opens the set wallpaper page in the browser.
virtual void OpenSetWallpaperPage() = 0;
// Returns true if user can open set wallpaper page. Only guest user returns
// false currently.
virtual bool CanOpenSetWallpaperPage() = 0;
};
// Loads selected desktop wallpaper from file system asynchronously and updates
// background layer if loaded successfully.
class ASH_EXPORT DesktopBackgroundController {
public:
enum BackgroundMode {
BACKGROUND_IMAGE,
BACKGROUND_SOLID_COLOR
};
DesktopBackgroundController();
virtual ~DesktopBackgroundController();
// Gets the desktop background mode.
BackgroundMode desktop_background_mode() const {
return desktop_background_mode_;
}
// Loads default wallpaper at |index| asynchronously and sets to current
// wallpaper after loaded.
void SetDefaultWallpaper(int index);
// Sets the user selected custom wallpaper. Called when user selected a file
// from file system or changed the layout of wallpaper.
void SetCustomWallpaper(const gfx::ImageSkia& wallpaper,
WallpaperLayout layout);
// Cancels the current wallpaper loading operation.
void CancelPendingWallpaperOperation();
// Loads logged in user wallpaper asynchronously and sets to current wallpaper
// after loaded.
void SetLoggedInUserWallpaper();
// Sets the desktop background to solid color mode and creates a solid color
// layout.
void SetDesktopBackgroundSolidColorMode();
private:
// An operation to asynchronously loads wallpaper.
class WallpaperOperation;
// Sets the desktop background to image mode and creates a new background
// widget with user selected wallpaper or default wallpaper. Deletes the old
// widget if any.
void SetDesktopBackgroundImageMode(scoped_refptr<WallpaperOperation> wo);
// Creates a new background widget and sets the background mode to image mode.
// Called after wallpaper loaded successfully.
void OnWallpaperLoadCompleted(scoped_refptr<WallpaperOperation> wo);
// Creates an empty wallpaper. Some tests require a wallpaper widget is ready
// when running. However, the wallpaper widgets are now created asynchronously
// . If loading a real wallpaper, there are cases that these tests crash
// because the required widget is not ready. This function synchronously
// creates an empty widget for those tests to prevent crashes. An example test
// is SystemGestureEventFilterTest.ThreeFingerSwipe.
void CreateEmptyWallpaper();
// Can change at runtime.
BackgroundMode desktop_background_mode_;
// The previous successfully loaded wallpaper.
int previous_index_;
scoped_refptr<WallpaperOperation> wallpaper_op_;
base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController);
};
} // namespace ash
#endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_
|