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