OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
6 | 6 |
7 #include "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "chrome/browser/prefs/pref_service.h" | 24 #include "chrome/browser/prefs/pref_service.h" |
25 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 25 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
26 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
27 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
30 #include "chromeos/dbus/dbus_thread_manager.h" | 30 #include "chromeos/dbus/dbus_thread_manager.h" |
31 #include "chromeos/dbus/power_manager_client.h" | 31 #include "chromeos/dbus/power_manager_client.h" |
32 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
34 #include "skia/ext/image_operations.h" | |
35 #include "ui/gfx/codec/png_codec.h" | 34 #include "ui/gfx/codec/png_codec.h" |
35 #include "ui/gfx/image/image_skia_operations.h" | |
36 #include "ui/gfx/skia_util.h" | 36 #include "ui/gfx/skia_util.h" |
37 | 37 |
38 using content::BrowserThread; | 38 using content::BrowserThread; |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 const int kWallpaperUpdateIntervalSec = 24 * 60 * 60; | 42 const int kWallpaperUpdateIntervalSec = 24 * 60 * 60; |
43 | 43 |
44 const char kWallpaperTypeNodeName[] = "type"; | 44 const char kWallpaperTypeNodeName[] = "type"; |
45 const char kWallpaperIndexNodeName[] = "index"; | 45 const char kWallpaperIndexNodeName[] = "index"; |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 FROM_HERE, | 512 FROM_HERE, |
513 base::Bind(&WallpaperManager::CacheThumbnail, | 513 base::Bind(&WallpaperManager::CacheThumbnail, |
514 base::Unretained(this), email, wallpaper.image())); | 514 base::Unretained(this), email, wallpaper.image())); |
515 | 515 |
516 custom_wallpaper_cache_.insert(std::make_pair(email, wallpaper.image())); | 516 custom_wallpaper_cache_.insert(std::make_pair(email, wallpaper.image())); |
517 } | 517 } |
518 | 518 |
519 void WallpaperManager::CacheThumbnail(const std::string& email, | 519 void WallpaperManager::CacheThumbnail(const std::string& email, |
520 const gfx::ImageSkia& wallpaper) { | 520 const gfx::ImageSkia& wallpaper) { |
521 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 521 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
522 gfx::ImageSkia thumbnail = | 522 gfx::ImageSkia thumbnail = gfx::ImageSkiaOperations::CreateResizedImage( |
sky
2012/08/16 16:25:59
This code runs off the UI thread. I don't think Im
sadrul
2012/08/16 17:15:12
Ah, very interesting. I think we already have this
| |
523 skia::ImageOperations::Resize(wallpaper, | 523 wallpaper, |
524 skia::ImageOperations::RESIZE_LANCZOS3, | 524 skia::ImageOperations::RESIZE_LANCZOS3, |
525 kThumbnailWidth, kThumbnailHeight); | 525 gfx::Size(kThumbnailWidth, kThumbnailHeight)); |
526 custom_wallpaper_thumbnail_cache_[email] = thumbnail; | 526 custom_wallpaper_thumbnail_cache_[email] = thumbnail; |
527 } | 527 } |
528 | 528 |
529 void WallpaperManager::FetchWallpaper(const std::string& email, | 529 void WallpaperManager::FetchWallpaper(const std::string& email, |
530 ash::WallpaperLayout layout, | 530 ash::WallpaperLayout layout, |
531 const UserImage& wallpaper) { | 531 const UserImage& wallpaper) { |
532 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 532 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
533 | 533 |
534 BrowserThread::PostTask( | 534 BrowserThread::PostTask( |
535 BrowserThread::FILE, | 535 BrowserThread::FILE, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 } | 575 } |
576 } | 576 } |
577 } | 577 } |
578 | 578 |
579 void WallpaperManager::GenerateUserWallpaperThumbnail( | 579 void WallpaperManager::GenerateUserWallpaperThumbnail( |
580 const std::string& email, | 580 const std::string& email, |
581 User::WallpaperType type, | 581 User::WallpaperType type, |
582 base::WeakPtr<WallpaperDelegate> delegate, | 582 base::WeakPtr<WallpaperDelegate> delegate, |
583 const gfx::ImageSkia& wallpaper) { | 583 const gfx::ImageSkia& wallpaper) { |
584 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 584 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
585 gfx::ImageSkia thumbnail = | 585 gfx::ImageSkia thumbnail = gfx::ImageSkiaOperations::CreateResizedImage( |
586 skia::ImageOperations::Resize(wallpaper, | 586 wallpaper, |
587 skia::ImageOperations::RESIZE_LANCZOS3, | 587 skia::ImageOperations::RESIZE_LANCZOS3, |
588 kThumbnailWidth, kThumbnailHeight); | 588 gfx::Size(kThumbnailWidth, kThumbnailHeight)); |
589 | 589 |
590 custom_wallpaper_thumbnail_cache_[email] = thumbnail; | 590 custom_wallpaper_thumbnail_cache_[email] = thumbnail; |
591 | 591 |
592 // Notify thumbnail is ready. | 592 // Notify thumbnail is ready. |
593 BrowserThread::PostTask( | 593 BrowserThread::PostTask( |
594 BrowserThread::UI, | 594 BrowserThread::UI, |
595 FROM_HERE, | 595 FROM_HERE, |
596 base::Bind(&WallpaperManager::OnThumbnailUpdated, | 596 base::Bind(&WallpaperManager::OnThumbnailUpdated, |
597 base::Unretained(this), delegate)); | 597 base::Unretained(this), delegate)); |
598 } | 598 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 | 650 |
651 void WallpaperManager::SystemResumed() { | 651 void WallpaperManager::SystemResumed() { |
652 BatchUpdateWallpaper(); | 652 BatchUpdateWallpaper(); |
653 } | 653 } |
654 | 654 |
655 void WallpaperManager::TimezoneChanged(const icu::TimeZone& timezone) { | 655 void WallpaperManager::TimezoneChanged(const icu::TimeZone& timezone) { |
656 RestartTimer(); | 656 RestartTimer(); |
657 } | 657 } |
658 | 658 |
659 } // chromeos | 659 } // chromeos |
OLD | NEW |