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 COMPONENTS_WALLPAPER_WALLPAPER_MANAGER_BASE_H_ | 5 #ifndef COMPONENTS_WALLPAPER_WALLPAPER_MANAGER_BASE_H_ |
6 #define COMPONENTS_WALLPAPER_WALLPAPER_MANAGER_BASE_H_ | 6 #define COMPONENTS_WALLPAPER_WALLPAPER_MANAGER_BASE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
| 21 #include "components/signin/core/account_id/account_id.h" |
21 #include "components/user_manager/user.h" | 22 #include "components/user_manager/user.h" |
22 #include "components/user_manager/user_image/user_image.h" | 23 #include "components/user_manager/user_image/user_image.h" |
23 #include "components/wallpaper/wallpaper_export.h" | 24 #include "components/wallpaper/wallpaper_export.h" |
24 #include "components/wallpaper/wallpaper_layout.h" | 25 #include "components/wallpaper/wallpaper_layout.h" |
25 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
26 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
27 #include "third_party/icu/source/i18n/unicode/timezone.h" | 28 #include "third_party/icu/source/i18n/unicode/timezone.h" |
28 #include "ui/gfx/image/image_skia.h" | 29 #include "ui/gfx/image/image_skia.h" |
29 | 30 |
30 class PrefRegistrySimple; | 31 class PrefRegistrySimple; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 160 |
160 DISALLOW_COPY_AND_ASSIGN(CustomizedWallpaperRescaledFiles); | 161 DISALLOW_COPY_AND_ASSIGN(CustomizedWallpaperRescaledFiles); |
161 }; | 162 }; |
162 | 163 |
163 // For testing. | 164 // For testing. |
164 class TestApi { | 165 class TestApi { |
165 public: | 166 public: |
166 explicit TestApi(WallpaperManagerBase* wallpaper_manager); | 167 explicit TestApi(WallpaperManagerBase* wallpaper_manager); |
167 virtual ~TestApi(); | 168 virtual ~TestApi(); |
168 | 169 |
169 bool GetWallpaperFromCache(const std::string& user_id, | 170 bool GetWallpaperFromCache(const AccountId& account_id, |
170 gfx::ImageSkia* image); | 171 gfx::ImageSkia* image); |
171 | 172 |
172 bool GetPathFromCache(const std::string& user_id, | 173 bool GetPathFromCache(const AccountId& account_id, base::FilePath* path); |
173 base::FilePath* path); | |
174 | 174 |
175 void SetWallpaperCache(const std::string& user_id, | 175 void SetWallpaperCache(const AccountId& account_id, |
176 const base::FilePath& path, | 176 const base::FilePath& path, |
177 const gfx::ImageSkia& image); | 177 const gfx::ImageSkia& image); |
178 | 178 |
179 void ClearDisposableWallpaperCache(); | 179 void ClearDisposableWallpaperCache(); |
180 | 180 |
181 private: | 181 private: |
182 WallpaperManagerBase* wallpaper_manager_; // not owned | 182 WallpaperManagerBase* wallpaper_manager_; // not owned |
183 | 183 |
184 DISALLOW_COPY_AND_ASSIGN(TestApi); | 184 DISALLOW_COPY_AND_ASSIGN(TestApi); |
185 }; | 185 }; |
186 | 186 |
187 class Observer { | 187 class Observer { |
188 public: | 188 public: |
189 virtual ~Observer() {} | 189 virtual ~Observer() {} |
190 virtual void OnWallpaperAnimationFinished(const std::string& user_id) = 0; | 190 virtual void OnWallpaperAnimationFinished(const AccountId& account_id) = 0; |
191 virtual void OnUpdateWallpaperForTesting() {} | 191 virtual void OnUpdateWallpaperForTesting() {} |
192 virtual void OnPendingListEmptyForTesting() {} | 192 virtual void OnPendingListEmptyForTesting() {} |
193 }; | 193 }; |
194 | 194 |
195 // set path IDs for used directories | 195 // set path IDs for used directories |
196 static void SetPathIds(int dir_user_data_enum, | 196 static void SetPathIds(int dir_user_data_enum, |
197 int dir_chromeos_wallpapers_enum, | 197 int dir_chromeos_wallpapers_enum, |
198 int dir_chromeos_custom_wallpapers_enum); | 198 int dir_chromeos_custom_wallpapers_enum); |
199 | 199 |
200 // Returns custom wallpaper directory by appending corresponding |sub_dir|. | 200 // Returns custom wallpaper directory by appending corresponding |sub_dir|. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged | 251 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged |
252 // in, uses a solid color wallpaper. If logged in as a stub user, uses an | 252 // in, uses a solid color wallpaper. If logged in as a stub user, uses an |
253 // empty wallpaper. | 253 // empty wallpaper. |
254 virtual void InitializeWallpaper() = 0; | 254 virtual void InitializeWallpaper() = 0; |
255 | 255 |
256 // NotificationObserver overrides: | 256 // NotificationObserver overrides: |
257 void Observe(int type, | 257 void Observe(int type, |
258 const content::NotificationSource& source, | 258 const content::NotificationSource& source, |
259 const content::NotificationDetails& details) override = 0; | 259 const content::NotificationDetails& details) override = 0; |
260 | 260 |
261 // Removes all |user_id| related wallpaper info and saved wallpapers. | 261 // Removes all |account_id| related wallpaper info and saved wallpapers. |
262 virtual void RemoveUserWallpaperInfo(const std::string& user_id) = 0; | 262 virtual void RemoveUserWallpaperInfo(const AccountId& account_id) = 0; |
263 | 263 |
264 // Calls SetCustomWallpaper() with |user_id_hash| received from cryptohome. | 264 // Calls SetCustomWallpaper() with |user_id_hash| received from cryptohome. |
265 virtual void SetCustomWallpaperOnSanitizedUsername( | 265 virtual void SetCustomWallpaperOnSanitizedUsername( |
266 const std::string& user_id, | 266 const AccountId& account_id, |
267 const gfx::ImageSkia& image, | 267 const gfx::ImageSkia& image, |
268 bool update_wallpaper, | 268 bool update_wallpaper, |
269 bool cryptohome_success, | 269 bool cryptohome_success, |
270 const std::string& user_id_hash); | 270 const std::string& user_id_hash); |
271 | 271 |
272 // Saves custom wallpaper to file, post task to generate thumbnail and updates | 272 // Saves custom wallpaper to file, post task to generate thumbnail and updates |
273 // local state preferences. If |update_wallpaper| is false, don't change | 273 // local state preferences. If |update_wallpaper| is false, don't change |
274 // wallpaper but only update cache. | 274 // wallpaper but only update cache. |
275 virtual void SetCustomWallpaper(const std::string& user_id, | 275 virtual void SetCustomWallpaper(const AccountId& account_id, |
276 const std::string& user_id_hash, | 276 const std::string& user_id_hash, |
277 const std::string& file, | 277 const std::string& file, |
278 WallpaperLayout layout, | 278 WallpaperLayout layout, |
279 user_manager::User::WallpaperType type, | 279 user_manager::User::WallpaperType type, |
280 const gfx::ImageSkia& image, | 280 const gfx::ImageSkia& image, |
281 bool update_wallpaper) = 0; | 281 bool update_wallpaper) = 0; |
282 | 282 |
283 // Use given files as new default wallpaper. | 283 // Use given files as new default wallpaper. |
284 // Reloads current wallpaper, if old default was loaded. | 284 // Reloads current wallpaper, if old default was loaded. |
285 // Current value of default_wallpaper_image_ is destroyed. | 285 // Current value of default_wallpaper_image_ is destroyed. |
286 // Sets default_wallpaper_image_ either to |small_wallpaper_image| or | 286 // Sets default_wallpaper_image_ either to |small_wallpaper_image| or |
287 // |large_wallpaper_image| depending on GetAppropriateResolution(). | 287 // |large_wallpaper_image| depending on GetAppropriateResolution(). |
288 virtual void SetDefaultWallpaperPath( | 288 virtual void SetDefaultWallpaperPath( |
289 const base::FilePath& customized_default_wallpaper_file_small, | 289 const base::FilePath& customized_default_wallpaper_file_small, |
290 scoped_ptr<gfx::ImageSkia> small_wallpaper_image, | 290 scoped_ptr<gfx::ImageSkia> small_wallpaper_image, |
291 const base::FilePath& customized_default_wallpaper_file_large, | 291 const base::FilePath& customized_default_wallpaper_file_large, |
292 scoped_ptr<gfx::ImageSkia> large_wallpaper_image) = 0; | 292 scoped_ptr<gfx::ImageSkia> large_wallpaper_image) = 0; |
293 | 293 |
294 // Sets wallpaper to default wallpaper (asynchronously with zero delay). | 294 // Sets wallpaper to default wallpaper (asynchronously with zero delay). |
295 virtual void SetDefaultWallpaperNow(const std::string& user_id) = 0; | 295 virtual void SetDefaultWallpaperNow(const AccountId& account_id) = 0; |
296 | 296 |
297 // Sets wallpaper to default wallpaper (asynchronously with default delay). | 297 // Sets wallpaper to default wallpaper (asynchronously with default delay). |
298 virtual void SetDefaultWallpaperDelayed(const std::string& user_id) = 0; | 298 virtual void SetDefaultWallpaperDelayed(const AccountId& account_id) = 0; |
299 | 299 |
300 // Sets selected wallpaper information for |user_id| and saves it to Local | 300 // Sets selected wallpaper information for |account_id| and saves it to Local |
301 // State if |is_persistent| is true. | 301 // State if |is_persistent| is true. |
302 virtual void SetUserWallpaperInfo(const std::string& user_id, | 302 virtual void SetUserWallpaperInfo(const AccountId& account_id, |
303 const WallpaperInfo& info, | 303 const WallpaperInfo& info, |
304 bool is_persistent) = 0; | 304 bool is_persistent) = 0; |
305 | 305 |
306 // Sets |user_id|'s wallpaper (asynchronously with zero delay). | 306 // Sets |account_id|'s wallpaper (asynchronously with zero delay). |
307 virtual void SetUserWallpaperNow(const std::string& user_id); | 307 virtual void SetUserWallpaperNow(const AccountId& account_id); |
308 | 308 |
309 // Sets |user_id|'s wallpaper (asynchronously with default delay). | 309 // Sets |account_id|'s wallpaper (asynchronously with default delay). |
310 virtual void SetUserWallpaperDelayed(const std::string& user_id); | 310 virtual void SetUserWallpaperDelayed(const AccountId& account_id); |
311 | 311 |
312 // Sets wallpaper to |image| (asynchronously with zero delay). If | 312 // Sets wallpaper to |image| (asynchronously with zero delay). If |
313 // |update_wallpaper| is false, skip change wallpaper but only update cache. | 313 // |update_wallpaper| is false, skip change wallpaper but only update cache. |
314 virtual void SetWallpaperFromImageSkia(const std::string& user_id, | 314 virtual void SetWallpaperFromImageSkia(const AccountId& account_id, |
315 const gfx::ImageSkia& image, | 315 const gfx::ImageSkia& image, |
316 WallpaperLayout layout, | 316 WallpaperLayout layout, |
317 bool update_wallpaper) = 0; | 317 bool update_wallpaper) = 0; |
318 | 318 |
319 // Updates current wallpaper. It may switch the size of wallpaper based on the | 319 // Updates current wallpaper. It may switch the size of wallpaper based on the |
320 // current display's resolution. (asynchronously with zero delay) | 320 // current display's resolution. (asynchronously with zero delay) |
321 virtual void UpdateWallpaper(bool clear_cache); | 321 virtual void UpdateWallpaper(bool clear_cache); |
322 | 322 |
323 // Adds given observer to the list. | 323 // Adds given observer to the list. |
324 virtual void AddObserver(Observer* observer); | 324 virtual void AddObserver(Observer* observer); |
325 | 325 |
326 // Removes given observer from the list. | 326 // Removes given observer from the list. |
327 virtual void RemoveObserver(Observer* observer); | 327 virtual void RemoveObserver(Observer* observer); |
328 | 328 |
329 // Returns whether a wallpaper policy is enforced for |user_id|. | 329 // Returns whether a wallpaper policy is enforced for |account_id|. |
330 virtual bool IsPolicyControlled(const std::string& user_id) const; | 330 virtual bool IsPolicyControlled(const AccountId& account_id) const; |
331 | 331 |
332 // Called when a wallpaper policy has been set for |user_id|. Blocks user | 332 // Called when a wallpaper policy has been set for |account_id|. Blocks user |
333 // from changing the wallpaper. | 333 // from changing the wallpaper. |
334 virtual void OnPolicySet(const std::string& policy, | 334 virtual void OnPolicySet(const std::string& policy, |
335 const std::string& user_id); | 335 const AccountId& account_id); |
336 | 336 |
337 // Called when the wallpaper policy has been cleared for |user_id|. | 337 // Called when the wallpaper policy has been cleared for |account_id|. |
338 virtual void OnPolicyCleared(const std::string& policy, | 338 virtual void OnPolicyCleared(const std::string& policy, |
339 const std::string& user_id); | 339 const AccountId& account_id); |
340 | 340 |
341 // Called when the policy-set wallpaper has been fetched. Initiates decoding | 341 // Called when the policy-set wallpaper has been fetched. Initiates decoding |
342 // of the JPEG |data| with a callback to SetPolicyControlledWallpaper(). | 342 // of the JPEG |data| with a callback to SetPolicyControlledWallpaper(). |
343 virtual void OnPolicyFetched(const std::string& policy, | 343 virtual void OnPolicyFetched(const std::string& policy, |
344 const std::string& user_id, | 344 const AccountId& account_id, |
345 scoped_ptr<std::string> data) = 0; | 345 scoped_ptr<std::string> data) = 0; |
346 | 346 |
347 // This is called from CustomizationDocument. | 347 // This is called from CustomizationDocument. |
348 // |resized_directory| is the directory where resized versions are stored and | 348 // |resized_directory| is the directory where resized versions are stored and |
349 // must be writable. | 349 // must be writable. |
350 virtual void SetCustomizedDefaultWallpaper( | 350 virtual void SetCustomizedDefaultWallpaper( |
351 const GURL& wallpaper_url, | 351 const GURL& wallpaper_url, |
352 const base::FilePath& downloaded_file, | 352 const base::FilePath& downloaded_file, |
353 const base::FilePath& resized_directory); | 353 const base::FilePath& resized_directory); |
354 | 354 |
355 // Returns queue size. | 355 // Returns queue size. |
356 virtual size_t GetPendingListSizeForTesting() const = 0; | 356 virtual size_t GetPendingListSizeForTesting() const = 0; |
357 | 357 |
358 protected: | 358 protected: |
359 friend class TestApi; | 359 friend class TestApi; |
360 friend class WallpaperManagerBrowserTest; | 360 friend class WallpaperManagerBrowserTest; |
361 friend class WallpaperManagerBrowserTestDefaultWallpaper; | 361 friend class WallpaperManagerBrowserTestDefaultWallpaper; |
362 friend class WallpaperManagerPolicyTest; | 362 friend class WallpaperManagerPolicyTest; |
363 | 363 |
364 // The |CustomWallpaperElement| contains |first| the path of the image which | 364 // The |CustomWallpaperElement| contains |first| the path of the image which |
365 // is currently being loaded and or in progress of being loaded and |second| | 365 // is currently being loaded and or in progress of being loaded and |second| |
366 // the image itself. | 366 // the image itself. |
367 typedef std::pair<base::FilePath, gfx::ImageSkia> CustomWallpaperElement; | 367 typedef std::pair<base::FilePath, gfx::ImageSkia> CustomWallpaperElement; |
368 typedef std::map<std::string, CustomWallpaperElement> CustomWallpaperMap; | 368 typedef std::map<AccountId, CustomWallpaperElement> CustomWallpaperMap; |
369 | 369 |
370 // Saves original custom wallpaper to |path| (absolute path) on filesystem | 370 // Saves original custom wallpaper to |path| (absolute path) on filesystem |
371 // and starts resizing operation of the custom wallpaper if necessary. | 371 // and starts resizing operation of the custom wallpaper if necessary. |
372 static void SaveCustomWallpaper(const std::string& user_id_hash, | 372 static void SaveCustomWallpaper(const std::string& user_id_hash, |
373 const base::FilePath& path, | 373 const base::FilePath& path, |
374 WallpaperLayout layout, | 374 WallpaperLayout layout, |
375 scoped_ptr<gfx::ImageSkia> image); | 375 scoped_ptr<gfx::ImageSkia> image); |
376 | 376 |
377 // Moves custom wallpapers from |user_id| directory to |user_id_hash| | 377 // Moves custom wallpapers from user email directory to |user_id_hash| |
378 // directory. | 378 // directory. |
379 static void MoveCustomWallpapersOnWorker( | 379 static void MoveCustomWallpapersOnWorker( |
380 const std::string& user_id, | 380 const AccountId& account_id, |
381 const std::string& user_id_hash, | 381 const std::string& user_id_hash, |
382 base::WeakPtr<WallpaperManagerBase> weak_ptr); | 382 base::WeakPtr<WallpaperManagerBase> weak_ptr); |
383 | 383 |
384 // Gets |user_id|'s custom wallpaper at |wallpaper_path|. Falls back on | 384 // Gets |account_id|'s custom wallpaper at |wallpaper_path|. Falls back on |
385 // original custom wallpaper. When |update_wallpaper| is true, sets wallpaper | 385 // original custom wallpaper. When |update_wallpaper| is true, sets wallpaper |
386 // to the loaded wallpaper. Must run on wallpaper sequenced worker thread. | 386 // to the loaded wallpaper. Must run on wallpaper sequenced worker thread. |
387 static void GetCustomWallpaperInternal( | 387 static void GetCustomWallpaperInternal( |
388 const std::string& user_id, | 388 const AccountId& account_id, |
389 const WallpaperInfo& info, | 389 const WallpaperInfo& info, |
390 const base::FilePath& wallpaper_path, | 390 const base::FilePath& wallpaper_path, |
391 bool update_wallpaper, | 391 bool update_wallpaper, |
392 MovableOnDestroyCallbackHolder on_finish, | 392 MovableOnDestroyCallbackHolder on_finish, |
393 base::WeakPtr<WallpaperManagerBase> weak_ptr); | 393 base::WeakPtr<WallpaperManagerBase> weak_ptr); |
394 | 394 |
395 // Resize and save customized default wallpaper. | 395 // Resize and save customized default wallpaper. |
396 static void ResizeCustomizedDefaultWallpaper( | 396 static void ResizeCustomizedDefaultWallpaper( |
397 scoped_ptr<gfx::ImageSkia> image, | 397 scoped_ptr<gfx::ImageSkia> image, |
398 const user_manager::UserImage::RawImage& raw_image, | 398 const user_manager::UserImage::RawImage& raw_image, |
399 const CustomizedWallpaperRescaledFiles* rescaled_files, | 399 const CustomizedWallpaperRescaledFiles* rescaled_files, |
400 bool* success, | 400 bool* success, |
401 gfx::ImageSkia* small_wallpaper_image, | 401 gfx::ImageSkia* small_wallpaper_image, |
402 gfx::ImageSkia* large_wallpaper_image); | 402 gfx::ImageSkia* large_wallpaper_image); |
403 | 403 |
404 // Initialize wallpaper for the specified user to default and saves this | 404 // Initialize wallpaper for the specified user to default and saves this |
405 // settings in local state. | 405 // settings in local state. |
406 virtual void InitInitialUserWallpaper(const std::string& user_id, | 406 virtual void InitInitialUserWallpaper(const AccountId& account_id, |
407 bool is_persistent); | 407 bool is_persistent); |
408 | 408 |
409 // Set wallpaper to |user_image| controlled by policy. (Takes a UserImage | 409 // Set wallpaper to |user_image| controlled by policy. (Takes a UserImage |
410 // because that's the callback interface provided by UserImageLoader.) | 410 // because that's the callback interface provided by UserImageLoader.) |
411 virtual void SetPolicyControlledWallpaper( | 411 virtual void SetPolicyControlledWallpaper( |
412 const std::string& user_id, | 412 const AccountId& account_id, |
413 const user_manager::UserImage& user_image); | 413 const user_manager::UserImage& user_image); |
414 | 414 |
415 // Gets encoded wallpaper from cache. Returns true if success. | 415 // Gets encoded wallpaper from cache. Returns true if success. |
416 virtual bool GetWallpaperFromCache(const std::string& user_id, | 416 virtual bool GetWallpaperFromCache(const AccountId& account_id, |
417 gfx::ImageSkia* image); | 417 gfx::ImageSkia* image); |
418 | 418 |
419 // Gets path of encoded wallpaper from cache. Returns true if success. | 419 // Gets path of encoded wallpaper from cache. Returns true if success. |
420 virtual bool GetPathFromCache(const std::string& user_id, | 420 virtual bool GetPathFromCache(const AccountId& account_id, |
421 base::FilePath* path); | 421 base::FilePath* path); |
422 | 422 |
423 // The number of wallpapers have loaded. For test only. | 423 // The number of wallpapers have loaded. For test only. |
424 virtual int loaded_wallpapers_for_test() const; | 424 virtual int loaded_wallpapers_for_test() const; |
425 | 425 |
426 // Cache some (or all) logged in users' wallpapers to memory at login | 426 // Cache some (or all) logged in users' wallpapers to memory at login |
427 // screen. It should not compete with first wallpaper loading when boot | 427 // screen. It should not compete with first wallpaper loading when boot |
428 // up/initialize login WebUI page. | 428 // up/initialize login WebUI page. |
429 // There are two ways the first wallpaper might be loaded: | 429 // There are two ways the first wallpaper might be loaded: |
430 // 1. Loaded on boot. Login WebUI waits for it. | 430 // 1. Loaded on boot. Login WebUI waits for it. |
431 // 2. When flag --disable-boot-animation is passed. Login WebUI is loaded | 431 // 2. When flag --disable-boot-animation is passed. Login WebUI is loaded |
432 // right away and in 500ms after. Wallpaper started to load. | 432 // right away and in 500ms after. Wallpaper started to load. |
433 // For case 2, should_cache_wallpaper_ is used to indicate if we need to | 433 // For case 2, should_cache_wallpaper_ is used to indicate if we need to |
434 // cache wallpapers on wallpaper animation finished. The cache operation | 434 // cache wallpapers on wallpaper animation finished. The cache operation |
435 // should be only executed once. | 435 // should be only executed once. |
436 virtual void CacheUsersWallpapers(); | 436 virtual void CacheUsersWallpapers(); |
437 | 437 |
438 // Caches |user_id|'s wallpaper to memory. | 438 // Caches |account_id|'s wallpaper to memory. |
439 virtual void CacheUserWallpaper(const std::string& user_id); | 439 virtual void CacheUserWallpaper(const AccountId& account_id); |
440 | 440 |
441 // Clears disposable ONLINE and CUSTOM wallpaper cache. At multi profile | 441 // Clears disposable ONLINE and CUSTOM wallpaper cache. At multi profile |
442 // world, logged in users' wallpaper cache is not disposable. | 442 // world, logged in users' wallpaper cache is not disposable. |
443 virtual void ClearDisposableWallpaperCache(); | 443 virtual void ClearDisposableWallpaperCache(); |
444 | 444 |
445 // Deletes all |user_id| related custom wallpapers and directories. | 445 // Deletes all |account_id| related custom wallpapers and directories. |
446 virtual void DeleteUserWallpapers(const std::string& user_id, | 446 virtual void DeleteUserWallpapers(const AccountId& account_id, |
447 const std::string& path_to_file); | 447 const std::string& path_to_file); |
448 | 448 |
449 // Gets the CommandLine representing the current process's command line. | 449 // Gets the CommandLine representing the current process's command line. |
450 virtual base::CommandLine* GetCommandLine(); | 450 virtual base::CommandLine* GetCommandLine(); |
451 | 451 |
452 // Initialize wallpaper of registered device after device policy is trusted. | 452 // Initialize wallpaper of registered device after device policy is trusted. |
453 // Note that before device is enrolled, it proceeds with untrusted setting. | 453 // Note that before device is enrolled, it proceeds with untrusted setting. |
454 virtual void InitializeRegisteredDeviceWallpaper() = 0; | 454 virtual void InitializeRegisteredDeviceWallpaper() = 0; |
455 | 455 |
456 // Loads |user_id|'s wallpaper. When |update_wallpaper| is true, sets | 456 // Loads |account_id|'s wallpaper. When |update_wallpaper| is true, sets |
457 // wallpaper to the loaded wallpaper. | 457 // wallpaper to the loaded wallpaper. |
458 virtual void LoadWallpaper(const std::string& user_id, | 458 virtual void LoadWallpaper(const AccountId& account_id, |
459 const WallpaperInfo& info, | 459 const WallpaperInfo& info, |
460 bool update_wallpaper, | 460 bool update_wallpaper, |
461 MovableOnDestroyCallbackHolder on_finish); | 461 MovableOnDestroyCallbackHolder on_finish); |
462 | 462 |
463 // Called when the original custom wallpaper is moved to the new place. | 463 // Called when the original custom wallpaper is moved to the new place. |
464 // Updates the corresponding user wallpaper info. | 464 // Updates the corresponding user wallpaper info. |
465 virtual void MoveCustomWallpapersSuccess(const std::string& user_id, | 465 virtual void MoveCustomWallpapersSuccess(const AccountId& account_id, |
466 const std::string& user_id_hash); | 466 const std::string& user_id_hash); |
467 | 467 |
468 // Moves custom wallpaper to a new place. Email address was used as directory | 468 // Moves custom wallpaper to a new place. Email address was used as directory |
469 // name in the old system, this is not safe. New directory system uses | 469 // name in the old system, this is not safe. New directory system uses |
470 // user_id_hash instead of user_id. This must be called after user_id_hash is | 470 // user_id_hash instead of account_id. This must be called after user_id_hash |
| 471 // is |
471 // ready. | 472 // ready. |
472 virtual void MoveLoggedInUserCustomWallpaper(); | 473 virtual void MoveLoggedInUserCustomWallpaper(); |
473 | 474 |
474 // Gets wallpaper information of |user_id| from Local State or memory. Returns | 475 // Gets wallpaper information of |account_id| from Local State or memory. |
| 476 // Returns |
475 // false if wallpaper information is not found. | 477 // false if wallpaper information is not found. |
476 virtual bool GetUserWallpaperInfo(const std::string& user_id, | 478 virtual bool GetUserWallpaperInfo(const AccountId& account_id, |
477 WallpaperInfo* info) const = 0; | 479 WallpaperInfo* info) const = 0; |
478 | 480 |
479 // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true. | 481 // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true. |
480 // Otherwise, cache wallpaper to memory if not logged in. (Takes a UserImage | 482 // Otherwise, cache wallpaper to memory if not logged in. (Takes a UserImage |
481 // because that's the callback interface provided by UserImageLoader.) | 483 // because that's the callback interface provided by UserImageLoader.) |
482 virtual void OnWallpaperDecoded( | 484 virtual void OnWallpaperDecoded( |
483 const std::string& user_id, | 485 const AccountId& account_id, |
484 WallpaperLayout layout, | 486 WallpaperLayout layout, |
485 bool update_wallpaper, | 487 bool update_wallpaper, |
486 MovableOnDestroyCallbackHolder on_finish, | 488 MovableOnDestroyCallbackHolder on_finish, |
487 const user_manager::UserImage& user_image) = 0; | 489 const user_manager::UserImage& user_image) = 0; |
488 | 490 |
489 // Creates new PendingWallpaper request (or updates currently pending). | 491 // Creates new PendingWallpaper request (or updates currently pending). |
490 virtual void ScheduleSetUserWallpaper(const std::string& user_id, | 492 virtual void ScheduleSetUserWallpaper(const AccountId& account_id, |
491 bool delayed) = 0; | 493 bool delayed) = 0; |
492 | 494 |
493 // Sets wallpaper to default. | 495 // Sets wallpaper to default. |
494 virtual void DoSetDefaultWallpaper( | 496 virtual void DoSetDefaultWallpaper( |
495 const std::string& user_id, | 497 const AccountId& account_id, |
496 MovableOnDestroyCallbackHolder on_finish) = 0; | 498 MovableOnDestroyCallbackHolder on_finish) = 0; |
497 | 499 |
498 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is | 500 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is |
499 // already loaded for that user, do nothing. Must be called on UI thread. | 501 // already loaded for that user, do nothing. Must be called on UI thread. |
500 virtual void StartLoad(const std::string& user_id, | 502 virtual void StartLoad(const AccountId& account_id, |
501 const WallpaperInfo& info, | 503 const WallpaperInfo& info, |
502 bool update_wallpaper, | 504 bool update_wallpaper, |
503 const base::FilePath& wallpaper_path, | 505 const base::FilePath& wallpaper_path, |
504 MovableOnDestroyCallbackHolder on_finish) = 0; | 506 MovableOnDestroyCallbackHolder on_finish) = 0; |
505 | 507 |
506 // After completed load operation, update average load time. | 508 // After completed load operation, update average load time. |
507 virtual void SaveLastLoadTime(const base::TimeDelta elapsed); | 509 virtual void SaveLastLoadTime(const base::TimeDelta elapsed); |
508 | 510 |
509 // Notify all registered observers. | 511 // Notify all registered observers. |
510 virtual void NotifyAnimationFinished(); | 512 virtual void NotifyAnimationFinished(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 // Logged-in user wallpaper information. | 577 // Logged-in user wallpaper information. |
576 WallpaperInfo current_user_wallpaper_info_; | 578 WallpaperInfo current_user_wallpaper_info_; |
577 | 579 |
578 // If non-NULL, used in place of the real command line. | 580 // If non-NULL, used in place of the real command line. |
579 base::CommandLine* command_line_for_testing_; | 581 base::CommandLine* command_line_for_testing_; |
580 | 582 |
581 // Caches wallpapers of users. Accessed only on UI thread. | 583 // Caches wallpapers of users. Accessed only on UI thread. |
582 CustomWallpaperMap wallpaper_cache_; | 584 CustomWallpaperMap wallpaper_cache_; |
583 | 585 |
584 // The last selected user on user pod row. | 586 // The last selected user on user pod row. |
585 std::string last_selected_user_; | 587 AccountId last_selected_user_ = EmptyAccountId(); |
586 | 588 |
587 bool should_cache_wallpaper_; | 589 bool should_cache_wallpaper_; |
588 | 590 |
589 content::NotificationRegistrar registrar_; | 591 content::NotificationRegistrar registrar_; |
590 | 592 |
591 base::ObserverList<Observer> observers_; | 593 base::ObserverList<Observer> observers_; |
592 | 594 |
593 // These members are for the scheduler: | 595 // These members are for the scheduler: |
594 | 596 |
595 // When last load attempt finished. | 597 // When last load attempt finished. |
(...skipping 16 matching lines...) Expand all Loading... |
612 | 614 |
613 base::WeakPtrFactory<WallpaperManagerBase> weak_factory_; | 615 base::WeakPtrFactory<WallpaperManagerBase> weak_factory_; |
614 | 616 |
615 private: | 617 private: |
616 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerBase); | 618 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerBase); |
617 }; | 619 }; |
618 | 620 |
619 } // namespace wallpaper | 621 } // namespace wallpaper |
620 | 622 |
621 #endif // COMPONENTS_WALLPAPER_WALLPAPER_MANAGER_BASE_H_ | 623 #endif // COMPONENTS_WALLPAPER_WALLPAPER_MANAGER_BASE_H_ |
OLD | NEW |