Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: chrome/browser/chromeos/login/wallpaper_manager.cc

Issue 162393002: Enable surprise me wallpaper for new profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 11 matching lines...) Expand all
22 #include "base/prefs/pref_service.h" 22 #include "base/prefs/pref_service.h"
23 #include "base/prefs/scoped_user_pref_update.h" 23 #include "base/prefs/scoped_user_pref_update.h"
24 #include "base/strings/string_number_conversions.h" 24 #include "base/strings/string_number_conversions.h"
25 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
26 #include "base/strings/stringprintf.h" 26 #include "base/strings/stringprintf.h"
27 #include "base/threading/worker_pool.h" 27 #include "base/threading/worker_pool.h"
28 #include "base/time/time.h" 28 #include "base/time/time.h"
29 #include "base/values.h" 29 #include "base/values.h"
30 #include "chrome/browser/browser_process.h" 30 #include "chrome/browser/browser_process.h"
31 #include "chrome/browser/chrome_notification_types.h" 31 #include "chrome/browser/chrome_notification_types.h"
32 #include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h"
33 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h"
34 #include "chrome/browser/chromeos/login/login_display_host_impl.h"
32 #include "chrome/browser/chromeos/login/startup_utils.h" 35 #include "chrome/browser/chromeos/login/startup_utils.h"
33 #include "chrome/browser/chromeos/login/user.h" 36 #include "chrome/browser/chromeos/login/user.h"
34 #include "chrome/browser/chromeos/login/user_manager.h" 37 #include "chrome/browser/chromeos/login/user_manager.h"
35 #include "chrome/browser/chromeos/login/wizard_controller.h" 38 #include "chrome/browser/chromeos/login/wizard_controller.h"
36 #include "chrome/browser/chromeos/settings/cros_settings.h" 39 #include "chrome/browser/chromeos/settings/cros_settings.h"
40 #include "chrome/browser/extensions/extension_service.h"
37 #include "chrome/common/chrome_paths.h" 41 #include "chrome/common/chrome_paths.h"
38 #include "chrome/common/chrome_switches.h" 42 #include "chrome/common/chrome_switches.h"
39 #include "chrome/common/pref_names.h" 43 #include "chrome/common/pref_names.h"
40 #include "chromeos/chromeos_switches.h" 44 #include "chromeos/chromeos_switches.h"
41 #include "chromeos/dbus/dbus_thread_manager.h" 45 #include "chromeos/dbus/dbus_thread_manager.h"
42 #include "content/public/browser/browser_thread.h" 46 #include "content/public/browser/browser_thread.h"
43 #include "content/public/browser/notification_service.h" 47 #include "content/public/browser/notification_service.h"
48 #include "content/public/browser/web_ui.h"
49 #include "extensions/browser/event_router.h"
44 #include "grit/ash_resources.h" 50 #include "grit/ash_resources.h"
45 #include "ui/base/resource/resource_bundle.h" 51 #include "ui/base/resource/resource_bundle.h"
46 #include "ui/gfx/codec/jpeg_codec.h" 52 #include "ui/gfx/codec/jpeg_codec.h"
47 #include "ui/gfx/image/image_skia_operations.h" 53 #include "ui/gfx/image/image_skia_operations.h"
48 #include "ui/gfx/skia_util.h" 54 #include "ui/gfx/skia_util.h"
49 55
50 using content::BrowserThread; 56 using content::BrowserThread;
51 57
52 namespace chromeos { 58 namespace chromeos {
53 59
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 } 974 }
969 975
970 void WallpaperManager::AddObserver(WallpaperManager::Observer* observer) { 976 void WallpaperManager::AddObserver(WallpaperManager::Observer* observer) {
971 observers_.AddObserver(observer); 977 observers_.AddObserver(observer);
972 } 978 }
973 979
974 void WallpaperManager::RemoveObserver(WallpaperManager::Observer* observer) { 980 void WallpaperManager::RemoveObserver(WallpaperManager::Observer* observer) {
975 observers_.RemoveObserver(observer); 981 observers_.RemoveObserver(observer);
976 } 982 }
977 983
984 void WallpaperManager::EnableSurpriseMe() {
985 Profile* profile = ProfileManager::GetActiveUserProfile();
986 DCHECK(profile);
987 DCHECK(extensions::ExtensionSystem::Get(profile)->event_router());
988 scoped_ptr<extensions::Event> event(
989 new extensions::Event(
990 extensions::api::wallpaper_private::OnRequestEnableSurpriseMe::kEventName,
991 extensions::api::wallpaper_private::OnRequestEnableSurpriseMe::Create()));
992
993 extensions::ExtensionSystem::Get(profile)->event_router()
994 ->DispatchEventToExtension(extension_misc::kWallpaperManagerId,
995 event.Pass());
996 }
997
978 void WallpaperManager::NotifyAnimationFinished() { 998 void WallpaperManager::NotifyAnimationFinished() {
979 FOR_EACH_OBSERVER( 999 FOR_EACH_OBSERVER(
980 Observer, observers_, OnWallpaperAnimationFinished(last_selected_user_)); 1000 Observer, observers_, OnWallpaperAnimationFinished(last_selected_user_));
981 } 1001 }
982 1002
983 // WallpaperManager, private: -------------------------------------------------- 1003 // WallpaperManager, private: --------------------------------------------------
984 1004
985 bool WallpaperManager::GetWallpaperFromCache(const std::string& user_id, 1005 bool WallpaperManager::GetWallpaperFromCache(const std::string& user_id,
986 gfx::ImageSkia* wallpaper) { 1006 gfx::ImageSkia* wallpaper) {
987 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1007 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 base::Passed(on_finish.Pass()))); 1594 base::Passed(on_finish.Pass())));
1575 } 1595 }
1576 1596
1577 const char* WallpaperManager::GetCustomWallpaperSubdirForCurrentResolution() { 1597 const char* WallpaperManager::GetCustomWallpaperSubdirForCurrentResolution() {
1578 WallpaperResolution resolution = GetAppropriateResolution(); 1598 WallpaperResolution resolution = GetAppropriateResolution();
1579 return resolution == WALLPAPER_RESOLUTION_SMALL ? kSmallWallpaperSubDir 1599 return resolution == WALLPAPER_RESOLUTION_SMALL ? kSmallWallpaperSubDir
1580 : kLargeWallpaperSubDir; 1600 : kLargeWallpaperSubDir;
1581 } 1601 }
1582 1602
1583 } // namespace chromeos 1603 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698