| 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 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
| 6 | 6 |
| 7 #include <numeric> | 7 #include <numeric> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/file_enumerator.h" | 14 #include "base/files/file_enumerator.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 19 #include "base/prefs/pref_registry_simple.h" | 19 #include "base/prefs/pref_registry_simple.h" |
| 20 #include "base/prefs/pref_service.h" | 20 #include "base/prefs/pref_service.h" |
| 21 #include "base/prefs/scoped_user_pref_update.h" | 21 #include "base/prefs/scoped_user_pref_update.h" |
| 22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 25 #include "base/threading/worker_pool.h" | 25 #include "base/threading/worker_pool.h" |
| 26 #include "base/time/time.h" | 26 #include "base/time/time.h" |
| 27 #include "base/values.h" | 27 #include "base/values.h" |
| 28 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 29 #include "chrome/browser/chrome_notification_types.h" | 29 #include "chrome/browser/chrome_notification_types.h" |
| 30 #include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h" |
| 31 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" |
| 32 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| 30 #include "chrome/browser/chromeos/login/startup_utils.h" | 33 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 31 #include "chrome/browser/chromeos/login/user.h" | 34 #include "chrome/browser/chromeos/login/user.h" |
| 32 #include "chrome/browser/chromeos/login/user_manager.h" | 35 #include "chrome/browser/chromeos/login/user_manager.h" |
| 33 #include "chrome/browser/chromeos/login/wizard_controller.h" | 36 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 34 #include "chrome/browser/chromeos/settings/cros_settings.h" | 37 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 38 #include "chrome/browser/extensions/extension_service.h" |
| 35 #include "chrome/common/chrome_paths.h" | 39 #include "chrome/common/chrome_paths.h" |
| 36 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
| 37 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
| 38 #include "chromeos/chromeos_switches.h" | 42 #include "chromeos/chromeos_switches.h" |
| 39 #include "chromeos/dbus/dbus_thread_manager.h" | 43 #include "chromeos/dbus/dbus_thread_manager.h" |
| 40 #include "content/public/browser/browser_thread.h" | 44 #include "content/public/browser/browser_thread.h" |
| 41 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
| 46 #include "content/public/browser/web_ui.h" |
| 47 #include "extensions/browser/event_router.h" |
| 42 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
| 43 #include "ui/gfx/codec/jpeg_codec.h" | 49 #include "ui/gfx/codec/jpeg_codec.h" |
| 44 #include "ui/gfx/image/image_skia_operations.h" | 50 #include "ui/gfx/image/image_skia_operations.h" |
| 45 #include "ui/gfx/skia_util.h" | 51 #include "ui/gfx/skia_util.h" |
| 46 | 52 |
| 47 using content::BrowserThread; | 53 using content::BrowserThread; |
| 48 | 54 |
| 49 namespace { | 55 namespace { |
| 50 | 56 |
| 51 // The amount of delay before starts to move custom wallpapers to the new place. | 57 // The amount of delay before starts to move custom wallpapers to the new place. |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 } | 909 } |
| 904 | 910 |
| 905 void WallpaperManager::AddObserver(WallpaperManager::Observer* observer) { | 911 void WallpaperManager::AddObserver(WallpaperManager::Observer* observer) { |
| 906 observers_.AddObserver(observer); | 912 observers_.AddObserver(observer); |
| 907 } | 913 } |
| 908 | 914 |
| 909 void WallpaperManager::RemoveObserver(WallpaperManager::Observer* observer) { | 915 void WallpaperManager::RemoveObserver(WallpaperManager::Observer* observer) { |
| 910 observers_.RemoveObserver(observer); | 916 observers_.RemoveObserver(observer); |
| 911 } | 917 } |
| 912 | 918 |
| 919 void WallpaperManager::EnableSurpriseMe() { |
| 920 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 921 DCHECK(profile); |
| 922 DCHECK(extensions::ExtensionSystem::Get(profile)->event_router()); |
| 923 scoped_ptr<extensions::Event> event( |
| 924 new extensions::Event( |
| 925 extensions::api::wallpaper_private::OnRequestEnableSurpriseMe::kEventName, |
| 926 extensions::api::wallpaper_private::OnRequestEnableSurpriseMe::Create())); |
| 927 |
| 928 extensions::ExtensionSystem::Get(profile)->event_router() |
| 929 ->DispatchEventToExtension(extension_misc::kWallpaperManagerId, |
| 930 event.Pass()); |
| 931 } |
| 932 |
| 913 void WallpaperManager::NotifyAnimationFinished() { | 933 void WallpaperManager::NotifyAnimationFinished() { |
| 914 FOR_EACH_OBSERVER( | 934 FOR_EACH_OBSERVER( |
| 915 Observer, observers_, OnWallpaperAnimationFinished(last_selected_user_)); | 935 Observer, observers_, OnWallpaperAnimationFinished(last_selected_user_)); |
| 916 } | 936 } |
| 917 | 937 |
| 918 // WallpaperManager, private: -------------------------------------------------- | 938 // WallpaperManager, private: -------------------------------------------------- |
| 919 | 939 |
| 920 bool WallpaperManager::GetWallpaperFromCache(const std::string& user_id, | 940 bool WallpaperManager::GetWallpaperFromCache(const std::string& user_id, |
| 921 gfx::ImageSkia* wallpaper) { | 941 gfx::ImageSkia* wallpaper) { |
| 922 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 942 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 loading_.push_back(new WallpaperManager::PendingWallpaper( | 1469 loading_.push_back(new WallpaperManager::PendingWallpaper( |
| 1450 (delayed ? GetWallpaperLoadDelay() | 1470 (delayed ? GetWallpaperLoadDelay() |
| 1451 : base::TimeDelta::FromMilliseconds(0)), | 1471 : base::TimeDelta::FromMilliseconds(0)), |
| 1452 user_id)); | 1472 user_id)); |
| 1453 pending_inactive_ = loading_.back(); | 1473 pending_inactive_ = loading_.back(); |
| 1454 } | 1474 } |
| 1455 return pending_inactive_; | 1475 return pending_inactive_; |
| 1456 } | 1476 } |
| 1457 | 1477 |
| 1458 } // namespace chromeos | 1478 } // namespace chromeos |
| OLD | NEW |