OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_WALLPAPER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 base::Time started_load_at_; | 164 base::Time started_load_at_; |
165 | 165 |
166 DISALLOW_COPY_AND_ASSIGN(PendingWallpaper); | 166 DISALLOW_COPY_AND_ASSIGN(PendingWallpaper); |
167 }; | 167 }; |
168 | 168 |
169 static WallpaperManager* Get(); | 169 static WallpaperManager* Get(); |
170 | 170 |
171 WallpaperManager(); | 171 WallpaperManager(); |
172 virtual ~WallpaperManager(); | 172 virtual ~WallpaperManager(); |
173 | 173 |
174 void set_command_line_for_testing(base::CommandLine* command_line) { | 174 void set_command_line_for_testing(base::CommandLine* command_line); |
175 command_line_for_testing_ = command_line; | |
176 } | |
177 | 175 |
178 // Indicates imminent shutdown, allowing the WallpaperManager to remove any | 176 // Indicates imminent shutdown, allowing the WallpaperManager to remove any |
179 // observers it has registered. | 177 // observers it has registered. |
180 void Shutdown(); | 178 void Shutdown(); |
181 | 179 |
182 // Registers wallpaper manager preferences. | 180 // Registers wallpaper manager preferences. |
183 static void RegisterPrefs(PrefRegistrySimple* registry); | 181 static void RegisterPrefs(PrefRegistrySimple* registry); |
184 | 182 |
185 // Adds PowerManagerClient, TimeZoneSettings and CrosSettings observers. | 183 // Adds PowerManagerClient, TimeZoneSettings and CrosSettings observers. |
186 void AddObservers(); | 184 void AddObservers(); |
(...skipping 30 matching lines...) Expand all Loading... | |
217 | 215 |
218 // Removes all |user_id| related wallpaper info and saved wallpapers. | 216 // Removes all |user_id| related wallpaper info and saved wallpapers. |
219 void RemoveUserWallpaperInfo(const std::string& user_id); | 217 void RemoveUserWallpaperInfo(const std::string& user_id); |
220 | 218 |
221 // Resizes |wallpaper| to a resolution which is nearest to |preferred_width| | 219 // Resizes |wallpaper| to a resolution which is nearest to |preferred_width| |
222 // and |preferred_height| while maintaining aspect ratio. | 220 // and |preferred_height| while maintaining aspect ratio. |
223 bool ResizeWallpaper(const UserImage& wallpaper, | 221 bool ResizeWallpaper(const UserImage& wallpaper, |
224 ash::WallpaperLayout layout, | 222 ash::WallpaperLayout layout, |
225 int preferred_width, | 223 int preferred_width, |
226 int preferred_height, | 224 int preferred_height, |
227 scoped_refptr<base::RefCountedBytes>* output) const; | 225 scoped_refptr<base::RefCountedBytes>* output, |
226 gfx::ImageSkia* output_skia) const; | |
228 | 227 |
229 // Resizes |wallpaper| to a resolution which is nearest to |preferred_width| | 228 // Resizes |wallpaper| to a resolution which is nearest to |preferred_width| |
230 // and |preferred_height| while maintaining aspect ratio. And saves the | 229 // and |preferred_height| while maintaining aspect ratio. And saves the |
231 // resized wallpaper to |path|. | 230 // resized wallpaper to |path|. |result| is optional (may be NULL). |
232 void ResizeAndSaveWallpaper(const UserImage& wallpaper, | 231 // Result is true on success. |
Daniel Erat
2014/03/31 22:25:46
nit: change to "Returns true on success."
Alexander Alekseev
2014/04/03 19:15:44
Done.
| |
232 bool ResizeAndSaveWallpaper(const UserImage& wallpaper, | |
233 const base::FilePath& path, | 233 const base::FilePath& path, |
234 ash::WallpaperLayout layout, | 234 ash::WallpaperLayout layout, |
235 int preferred_width, | 235 int preferred_width, |
236 int preferred_height) const; | 236 int preferred_height, |
237 gfx::ImageSkia* result) const; | |
237 | 238 |
238 // Saves custom wallpaper to file, post task to generate thumbnail and updates | 239 // Saves custom wallpaper to file, post task to generate thumbnail and updates |
239 // local state preferences. If |update_wallpaper| is false, don't change | 240 // local state preferences. If |update_wallpaper| is false, don't change |
240 // wallpaper but only update cache. | 241 // wallpaper but only update cache. |
241 void SetCustomWallpaper(const std::string& user_id, | 242 void SetCustomWallpaper(const std::string& user_id, |
242 const std::string& user_id_hash, | 243 const std::string& user_id_hash, |
243 const std::string& file, | 244 const std::string& file, |
244 ash::WallpaperLayout layout, | 245 ash::WallpaperLayout layout, |
245 User::WallpaperType type, | 246 User::WallpaperType type, |
246 const UserImage& wallpaper, | 247 const UserImage& wallpaper, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 // Called when the policy-set wallpaper has been fetched. Initiates decoding | 303 // Called when the policy-set wallpaper has been fetched. Initiates decoding |
303 // of the JPEG |data| with a callback to SetPolicyControlledWallpaper(). | 304 // of the JPEG |data| with a callback to SetPolicyControlledWallpaper(). |
304 void OnPolicyFetched(const std::string& policy, | 305 void OnPolicyFetched(const std::string& policy, |
305 const std::string& user_id, | 306 const std::string& user_id, |
306 scoped_ptr<std::string> data); | 307 scoped_ptr<std::string> data); |
307 | 308 |
308 private: | 309 private: |
309 friend class TestApi; | 310 friend class TestApi; |
310 friend class WallpaperManagerBrowserTest; | 311 friend class WallpaperManagerBrowserTest; |
311 friend class WallpaperManagerPolicyTest; | 312 friend class WallpaperManagerPolicyTest; |
313 friend class WallpaperManagerTest; | |
312 | 314 |
313 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; | 315 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; |
314 | 316 |
315 // Set |wallpaper| controlled by policy. | 317 // Set |wallpaper| controlled by policy. |
316 void SetPolicyControlledWallpaper(const std::string& user_id, | 318 void SetPolicyControlledWallpaper(const std::string& user_id, |
317 const UserImage& wallpaper); | 319 const UserImage& wallpaper); |
318 | 320 |
319 // Gets encoded wallpaper from cache. Returns true if success. | 321 // Gets encoded wallpaper from cache. Returns true if success. |
320 bool GetWallpaperFromCache(const std::string& user_id, | 322 bool GetWallpaperFromCache(const std::string& user_id, |
321 gfx::ImageSkia* wallpaper); | 323 gfx::ImageSkia* wallpaper); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 void RecordUma(User::WallpaperType type, int index) const; | 422 void RecordUma(User::WallpaperType type, int index) const; |
421 | 423 |
422 // Saves original custom wallpaper to |path| (absolute path) on filesystem | 424 // Saves original custom wallpaper to |path| (absolute path) on filesystem |
423 // and starts resizing operation of the custom wallpaper if necessary. | 425 // and starts resizing operation of the custom wallpaper if necessary. |
424 void SaveCustomWallpaper(const std::string& user_id_hash, | 426 void SaveCustomWallpaper(const std::string& user_id_hash, |
425 const base::FilePath& path, | 427 const base::FilePath& path, |
426 ash::WallpaperLayout layout, | 428 ash::WallpaperLayout layout, |
427 const UserImage& wallpaper); | 429 const UserImage& wallpaper); |
428 | 430 |
429 // Saves wallpaper image raw |data| to |path| (absolute path) in file system. | 431 // Saves wallpaper image raw |data| to |path| (absolute path) in file system. |
430 void SaveWallpaperInternal(const base::FilePath& path, const char* data, | 432 // True on success. |
433 bool SaveWallpaperInternal(const base::FilePath& path, | |
434 const char* data, | |
431 int size) const; | 435 int size) const; |
432 | 436 |
433 // Creates new PendingWallpaper request (or updates currently pending). | 437 // Creates new PendingWallpaper request (or updates currently pending). |
434 void ScheduleSetUserWallpaper(const std::string& user_id, bool delayed); | 438 void ScheduleSetUserWallpaper(const std::string& user_id, bool delayed); |
435 | 439 |
436 // Sets wallpaper to default. | 440 // Sets wallpaper to default. |
437 void DoSetDefaultWallpaper( | 441 void DoSetDefaultWallpaper( |
438 const std::string& user_id, | 442 const std::string& user_id, |
439 MovableOnDestroyCallbackHolder on_finish); | 443 MovableOnDestroyCallbackHolder on_finish); |
440 | 444 |
(...skipping 16 matching lines...) Expand all Loading... | |
457 PendingWallpaper* GetPendingWallpaper(const std::string& user_id, | 461 PendingWallpaper* GetPendingWallpaper(const std::string& user_id, |
458 bool delayed); | 462 bool delayed); |
459 | 463 |
460 // Calculate delay for next wallpaper load. | 464 // Calculate delay for next wallpaper load. |
461 // It is usually average wallpaper load time. | 465 // It is usually average wallpaper load time. |
462 // If last wallpaper load happened long ago, timeout should be reduced by | 466 // If last wallpaper load happened long ago, timeout should be reduced by |
463 // the time passed after last wallpaper load. So usual user experience results | 467 // the time passed after last wallpaper load. So usual user experience results |
464 // in zero delay. | 468 // in zero delay. |
465 base::TimeDelta GetWallpaperLoadDelay() const; | 469 base::TimeDelta GetWallpaperLoadDelay() const; |
466 | 470 |
471 // Init "*default_*_wallpaper_file_" from given command line. | |
472 void SetDefaultWallpaperPathFromCommandLine(base::CommandLine* command_line); | |
Daniel Erat
2014/03/31 22:25:46
nit: s/Path/Paths/
Alexander Alekseev
2014/04/03 19:15:44
Done.
| |
473 | |
474 // Sets wallpaper to decoded default. | |
475 void OnDefaultWallpaperDecoded(const base::FilePath& path, | |
476 scoped_ptr<gfx::ImageSkia>* result, | |
477 MovableOnDestroyCallbackHolder on_finish, | |
478 const UserImage& wallpaper); | |
bshe
2014/04/01 15:32:56
nit: parameters that output result should appears
Alexander Alekseev
2014/04/03 19:15:44
OnDefaultWallpaperDecoded is used to create callba
| |
479 | |
480 // Start decoding given default wallpaper. | |
481 void StartLoadAndSetDefaultWallpaper( | |
482 const base::FilePath& path, | |
483 scoped_ptr<gfx::ImageSkia>* result, | |
484 MovableOnDestroyCallbackHolder on_finish); | |
485 | |
467 // The number of loaded wallpapers. | 486 // The number of loaded wallpapers. |
468 int loaded_wallpapers_; | 487 int loaded_wallpapers_; |
469 | 488 |
470 // Sequence token associated with wallpaper operations. | 489 // Sequence token associated with wallpaper operations. |
471 base::SequencedWorkerPool::SequenceToken sequence_token_; | 490 base::SequencedWorkerPool::SequenceToken sequence_token_; |
472 | 491 |
473 // Wallpaper sequenced task runner. | 492 // Wallpaper sequenced task runner. |
474 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 493 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
475 | 494 |
476 // The file path of current loaded/loading custom/online wallpaper. | 495 // The file path of current loaded/loading custom/online wallpaper. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
513 // Pointer to last inactive (waiting) entry of 'loading_' list. | 532 // Pointer to last inactive (waiting) entry of 'loading_' list. |
514 // NULL when there is no inactive request. | 533 // NULL when there is no inactive request. |
515 PendingWallpaper* pending_inactive_; | 534 PendingWallpaper* pending_inactive_; |
516 | 535 |
517 // Owns PendingWallpaper. | 536 // Owns PendingWallpaper. |
518 // PendingWallpaper deletes itself from here on load complete. | 537 // PendingWallpaper deletes itself from here on load complete. |
519 // All pending will be finally deleted on destroy. | 538 // All pending will be finally deleted on destroy. |
520 typedef std::vector<scoped_refptr<PendingWallpaper> > PendingList; | 539 typedef std::vector<scoped_refptr<PendingWallpaper> > PendingList; |
521 PendingList loading_; | 540 PendingList loading_; |
522 | 541 |
542 base::FilePath default_small_wallpaper_file_; | |
543 base::FilePath default_large_wallpaper_file_; | |
544 | |
545 base::FilePath guest_default_small_wallpaper_file_; | |
Daniel Erat
2014/03/31 22:25:46
mind renaming these to "guest_small_wallpaper_file
Alexander Alekseev
2014/04/03 19:15:44
Done.
| |
546 base::FilePath guest_default_large_wallpaper_file_; | |
547 | |
548 // Decoded default images are stored here. | |
549 scoped_ptr<gfx::ImageSkia> default_small_wallpaper_image_; | |
Daniel Erat
2014/03/31 22:25:46
i'm pretty sure we don't want to hold all of these
bshe
2014/04/01 15:32:56
+1
On 2014/03/31 22:25:46, Daniel Erat wrote:
Alexander Alekseev
2014/04/03 19:15:44
Done.
| |
550 scoped_ptr<gfx::ImageSkia> default_large_wallpaper_image_; | |
551 scoped_ptr<gfx::ImageSkia> guest_default_small_wallpaper_image_; | |
552 scoped_ptr<gfx::ImageSkia> guest_default_large_wallpaper_image_; | |
553 | |
523 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 554 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
524 }; | 555 }; |
525 | 556 |
526 } // namespace chromeos | 557 } // namespace chromeos |
527 | 558 |
528 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 559 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
OLD | NEW |