OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged | 63 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged |
64 // in, uses a solid color wallpaper. If logged in as a stub user, uses an | 64 // in, uses a solid color wallpaper. If logged in as a stub user, uses an |
65 // empty wallpaper. | 65 // empty wallpaper. |
66 void InitializeWallpaper() override; | 66 void InitializeWallpaper() override; |
67 | 67 |
68 // NotificationObserver overrides: | 68 // NotificationObserver overrides: |
69 void Observe(int type, | 69 void Observe(int type, |
70 const content::NotificationSource& source, | 70 const content::NotificationSource& source, |
71 const content::NotificationDetails& details) override; | 71 const content::NotificationDetails& details) override; |
72 | 72 |
73 // Removes all |user_id| related wallpaper info and saved wallpapers. | 73 // Removes all |account_id| related wallpaper info and saved wallpapers. |
74 void RemoveUserWallpaperInfo(const std::string& user_id) override; | 74 void RemoveUserWallpaperInfo(const AccountId& account_id) override; |
75 | 75 |
76 // Called when the policy-set wallpaper has been fetched. Initiates decoding | 76 // Called when the policy-set wallpaper has been fetched. Initiates decoding |
77 // of the JPEG |data| with a callback to SetPolicyControlledWallpaper(). | 77 // of the JPEG |data| with a callback to SetPolicyControlledWallpaper(). |
78 void OnPolicyFetched(const std::string& policy, | 78 void OnPolicyFetched(const std::string& policy, |
79 const std::string& user_id, | 79 const AccountId& account_id, |
80 scoped_ptr<std::string> data) override; | 80 scoped_ptr<std::string> data) override; |
81 | 81 |
82 // Saves custom wallpaper to file, post task to generate thumbnail and updates | 82 // Saves custom wallpaper to file, post task to generate thumbnail and updates |
83 // local state preferences. If |update_wallpaper| is false, don't change | 83 // local state preferences. If |update_wallpaper| is false, don't change |
84 // wallpaper but only update cache. | 84 // wallpaper but only update cache. |
85 void SetCustomWallpaper(const std::string& user_id, | 85 void SetCustomWallpaper(const AccountId& account_id, |
86 const std::string& user_id_hash, | 86 const std::string& user_id_hash, |
87 const std::string& file, | 87 const std::string& file, |
88 wallpaper::WallpaperLayout layout, | 88 wallpaper::WallpaperLayout layout, |
89 user_manager::User::WallpaperType type, | 89 user_manager::User::WallpaperType type, |
90 const gfx::ImageSkia& image, | 90 const gfx::ImageSkia& image, |
91 bool update_wallpaper) override; | 91 bool update_wallpaper) override; |
92 | 92 |
93 // Sets wallpaper to default wallpaper (asynchronously with zero delay). | 93 // Sets wallpaper to default wallpaper (asynchronously with zero delay). |
94 void SetDefaultWallpaperNow(const std::string& user_id) override; | 94 void SetDefaultWallpaperNow(const AccountId& account_id) override; |
95 | 95 |
96 // Sets wallpaper to default wallpaper (asynchronously with default delay). | 96 // Sets wallpaper to default wallpaper (asynchronously with default delay). |
97 void SetDefaultWallpaperDelayed(const std::string& user_id) override; | 97 void SetDefaultWallpaperDelayed(const AccountId& account_id) override; |
98 | 98 |
99 // Sets wallpaper to default. | 99 // Sets wallpaper to default. |
100 void DoSetDefaultWallpaper( | 100 void DoSetDefaultWallpaper( |
101 const std::string& user_id, | 101 const AccountId& account_id, |
102 wallpaper::MovableOnDestroyCallbackHolder on_finish) override; | 102 wallpaper::MovableOnDestroyCallbackHolder on_finish) override; |
103 | 103 |
104 // Sets selected wallpaper information for |user_id| and saves it to Local | 104 // Sets selected wallpaper information for |account_id| and saves it to Local |
105 // State if |is_persistent| is true. | 105 // State if |is_persistent| is true. |
106 void SetUserWallpaperInfo(const std::string& user_id, | 106 void SetUserWallpaperInfo(const AccountId& account_id, |
107 const wallpaper::WallpaperInfo& info, | 107 const wallpaper::WallpaperInfo& info, |
108 bool is_persistent) override; | 108 bool is_persistent) override; |
109 | 109 |
110 // Creates new PendingWallpaper request (or updates currently pending). | 110 // Creates new PendingWallpaper request (or updates currently pending). |
111 void ScheduleSetUserWallpaper(const std::string& user_id, | 111 void ScheduleSetUserWallpaper(const AccountId& account_id, |
112 bool delayed) override; | 112 bool delayed) override; |
113 | 113 |
114 // Sets wallpaper to |image| (asynchronously with zero delay). If | 114 // Sets wallpaper to |image| (asynchronously with zero delay). If |
115 // |update_wallpaper| is false, skip change wallpaper but only update cache. | 115 // |update_wallpaper| is false, skip change wallpaper but only update cache. |
116 void SetWallpaperFromImageSkia(const std::string& user_id, | 116 void SetWallpaperFromImageSkia(const AccountId& account_id, |
117 const gfx::ImageSkia& image, | 117 const gfx::ImageSkia& image, |
118 wallpaper::WallpaperLayout layout, | 118 wallpaper::WallpaperLayout layout, |
119 bool update_wallpaper) override; | 119 bool update_wallpaper) override; |
120 | 120 |
121 // Returns queue size. | 121 // Returns queue size. |
122 size_t GetPendingListSizeForTesting() const override; | 122 size_t GetPendingListSizeForTesting() const override; |
123 | 123 |
124 // Overridden from user_manager::UserManager::UserSessionStateObserver: | 124 // Overridden from user_manager::UserManager::UserSessionStateObserver: |
125 void UserChangedChildStatus(user_manager::User* user) override; | 125 void UserChangedChildStatus(user_manager::User* user) override; |
126 | 126 |
127 private: | 127 private: |
128 friend class TestApi; | 128 friend class TestApi; |
129 friend class WallpaperManagerBrowserTest; | 129 friend class WallpaperManagerBrowserTest; |
130 friend class WallpaperManagerBrowserTestDefaultWallpaper; | 130 friend class WallpaperManagerBrowserTestDefaultWallpaper; |
131 friend class WallpaperManagerPolicyTest; | 131 friend class WallpaperManagerPolicyTest; |
132 | 132 |
133 WallpaperManager(); | 133 WallpaperManager(); |
134 | 134 |
135 // Returns modifiable PendingWallpaper. | 135 // Returns modifiable PendingWallpaper. |
136 // Returns pending_inactive_ or creates new PendingWallpaper if necessary. | 136 // Returns pending_inactive_ or creates new PendingWallpaper if necessary. |
137 PendingWallpaper* GetPendingWallpaper(const std::string& user_id, | 137 PendingWallpaper* GetPendingWallpaper(const AccountId& account_id, |
138 bool delayed); | 138 bool delayed); |
139 | 139 |
140 // This is called by PendingWallpaper when load is finished. | 140 // This is called by PendingWallpaper when load is finished. |
141 void RemovePendingWallpaperFromList(PendingWallpaper* pending); | 141 void RemovePendingWallpaperFromList(PendingWallpaper* pending); |
142 | 142 |
143 // WallpaperManagerBase overrides: | 143 // WallpaperManagerBase overrides: |
144 void InitializeRegisteredDeviceWallpaper() override; | 144 void InitializeRegisteredDeviceWallpaper() override; |
145 bool GetUserWallpaperInfo(const std::string& user_id, | 145 bool GetUserWallpaperInfo(const AccountId& account_id, |
146 wallpaper::WallpaperInfo* info) const override; | 146 wallpaper::WallpaperInfo* info) const override; |
147 void OnWallpaperDecoded(const std::string& user_id, | 147 void OnWallpaperDecoded(const AccountId& account_id, |
148 wallpaper::WallpaperLayout layout, | 148 wallpaper::WallpaperLayout layout, |
149 bool update_wallpaper, | 149 bool update_wallpaper, |
150 wallpaper::MovableOnDestroyCallbackHolder on_finish, | 150 wallpaper::MovableOnDestroyCallbackHolder on_finish, |
151 const user_manager::UserImage& user_image) override; | 151 const user_manager::UserImage& user_image) override; |
152 void StartLoad(const std::string& user_id, | 152 void StartLoad(const AccountId& account_id, |
153 const wallpaper::WallpaperInfo& info, | 153 const wallpaper::WallpaperInfo& info, |
154 bool update_wallpaper, | 154 bool update_wallpaper, |
155 const base::FilePath& wallpaper_path, | 155 const base::FilePath& wallpaper_path, |
156 wallpaper::MovableOnDestroyCallbackHolder on_finish) override; | 156 wallpaper::MovableOnDestroyCallbackHolder on_finish) override; |
157 void SetCustomizedDefaultWallpaperAfterCheck( | 157 void SetCustomizedDefaultWallpaperAfterCheck( |
158 const GURL& wallpaper_url, | 158 const GURL& wallpaper_url, |
159 const base::FilePath& downloaded_file, | 159 const base::FilePath& downloaded_file, |
160 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files) override; | 160 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files) override; |
161 void OnCustomizedDefaultWallpaperResized( | 161 void OnCustomizedDefaultWallpaperResized( |
162 const GURL& wallpaper_url, | 162 const GURL& wallpaper_url, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 typedef std::vector<scoped_refptr<PendingWallpaper> > PendingList; | 197 typedef std::vector<scoped_refptr<PendingWallpaper> > PendingList; |
198 PendingList loading_; | 198 PendingList loading_; |
199 | 199 |
200 base::WeakPtrFactory<WallpaperManager> weak_factory_; | 200 base::WeakPtrFactory<WallpaperManager> weak_factory_; |
201 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 201 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
202 }; | 202 }; |
203 | 203 |
204 } // namespace chromeos | 204 } // namespace chromeos |
205 | 205 |
206 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ | 206 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ |
OLD | NEW |