Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 } | 219 } |
| 220 | 220 |
| 221 bool disable_new_oobe = CommandLine::ForCurrentProcess()-> | 221 bool disable_new_oobe = CommandLine::ForCurrentProcess()-> |
| 222 HasSwitch(switches::kDisableNewOobe); | 222 HasSwitch(switches::kDisableNewOobe); |
| 223 | 223 |
| 224 if (!user_manager->IsUserLoggedIn()) { | 224 if (!user_manager->IsUserLoggedIn()) { |
| 225 if (!disable_new_oobe) { | 225 if (!disable_new_oobe) { |
| 226 if (!WizardController::IsDeviceRegistered()) { | 226 if (!WizardController::IsDeviceRegistered()) { |
| 227 SetDefaultWallpaper(); | 227 SetDefaultWallpaper(); |
| 228 } else { | 228 } else { |
| 229 CrosSettings::Get()->AddSettingsObserver( | |
| 230 kAccountsPrefShowUserNamesOnSignIn, this); | |
| 229 InitializeRegisteredDeviceWallpaper(); | 231 InitializeRegisteredDeviceWallpaper(); |
| 230 } | 232 } |
| 231 } | 233 } |
| 232 return; | 234 return; |
| 233 } | 235 } |
| 234 SetUserWallpaper(user_manager->GetLoggedInUser()->email()); | 236 SetUserWallpaper(user_manager->GetLoggedInUser()->email()); |
| 235 } | 237 } |
| 236 | 238 |
| 237 void WallpaperManager::Observe(int type, | 239 void WallpaperManager::Observe(int type, |
| 238 const content::NotificationSource& source, | 240 const content::NotificationSource& source, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 260 if (should_cache_wallpaper_) { | 262 if (should_cache_wallpaper_) { |
| 261 BrowserThread::PostDelayedTask( | 263 BrowserThread::PostDelayedTask( |
| 262 BrowserThread::UI, FROM_HERE, | 264 BrowserThread::UI, FROM_HERE, |
| 263 base::Bind(&WallpaperManager::CacheUsersWallpapers, | 265 base::Bind(&WallpaperManager::CacheUsersWallpapers, |
| 264 weak_factory_.GetWeakPtr()), | 266 weak_factory_.GetWeakPtr()), |
| 265 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); | 267 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); |
| 266 should_cache_wallpaper_ = false; | 268 should_cache_wallpaper_ = false; |
| 267 } | 269 } |
| 268 break; | 270 break; |
| 269 } | 271 } |
| 272 case chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED: { | |
| 273 if (*content::Details<const std::string>(details).ptr() == | |
| 274 kAccountsPrefShowUserNamesOnSignIn) | |
|
pastarmovj
2013/01/21 14:55:24
Multi-line conditions needs { } around the body.
bshe
2013/01/21 22:53:07
Done.
| |
| 275 InitializeRegisteredDeviceWallpaper(); | |
| 276 break; | |
| 277 } | |
| 270 default: | 278 default: |
| 271 NOTREACHED() << "Unexpected notification " << type; | 279 NOTREACHED() << "Unexpected notification " << type; |
| 272 } | 280 } |
| 273 } | 281 } |
| 274 | 282 |
| 275 void WallpaperManager::RemoveUserWallpaperInfo(const std::string& email) { | 283 void WallpaperManager::RemoveUserWallpaperInfo(const std::string& email) { |
| 276 PrefService* prefs = g_browser_process->local_state(); | 284 PrefService* prefs = g_browser_process->local_state(); |
| 277 DictionaryPrefUpdate prefs_wallpapers_info_update(prefs, | 285 DictionaryPrefUpdate prefs_wallpapers_info_update(prefs, |
| 278 prefs::kUsersWallpaperInfo); | 286 prefs::kUsersWallpaperInfo); |
| 279 prefs_wallpapers_info_update->RemoveWithoutPathExpansion(email, NULL); | 287 prefs_wallpapers_info_update->RemoveWithoutPathExpansion(email, NULL); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 current_wallpaper_path_.clear(); | 558 current_wallpaper_path_.clear(); |
| 551 SetUserWallpaper(last_selected_user_); | 559 SetUserWallpaper(last_selected_user_); |
| 552 } | 560 } |
| 553 | 561 |
| 554 // WallpaperManager, private: -------------------------------------------------- | 562 // WallpaperManager, private: -------------------------------------------------- |
| 555 | 563 |
| 556 WallpaperManager::~WallpaperManager() { | 564 WallpaperManager::~WallpaperManager() { |
| 557 ClearObsoleteWallpaperPrefs(); | 565 ClearObsoleteWallpaperPrefs(); |
| 558 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 566 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
| 559 system::TimezoneSettings::GetInstance()->RemoveObserver(this); | 567 system::TimezoneSettings::GetInstance()->RemoveObserver(this); |
| 568 CrosSettings::Get()->RemoveSettingsObserver( | |
| 569 kAccountsPrefShowUserNamesOnSignIn, this); | |
| 570 | |
| 560 weak_factory_.InvalidateWeakPtrs(); | 571 weak_factory_.InvalidateWeakPtrs(); |
| 561 } | 572 } |
| 562 | 573 |
| 563 void WallpaperManager::BatchUpdateWallpaper() { | 574 void WallpaperManager::BatchUpdateWallpaper() { |
| 564 NOTIMPLEMENTED(); | 575 NOTIMPLEMENTED(); |
| 565 } | 576 } |
| 566 | 577 |
| 567 void WallpaperManager::CacheUsersWallpapers() { | 578 void WallpaperManager::CacheUsersWallpapers() { |
| 568 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 579 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 569 UserList users = UserManager::Get()->GetUsers(); | 580 UserList users = UserManager::Get()->GetUsers(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 | 654 |
| 644 base::WorkerPool::PostTask( | 655 base::WorkerPool::PostTask( |
| 645 FROM_HERE, | 656 FROM_HERE, |
| 646 base::Bind(&WallpaperManager::DeleteWallpaperInList, | 657 base::Bind(&WallpaperManager::DeleteWallpaperInList, |
| 647 base::Unretained(this), | 658 base::Unretained(this), |
| 648 file_to_remove), | 659 file_to_remove), |
| 649 false); | 660 false); |
| 650 } | 661 } |
| 651 | 662 |
| 652 void WallpaperManager::InitializeRegisteredDeviceWallpaper() { | 663 void WallpaperManager::InitializeRegisteredDeviceWallpaper() { |
| 653 if (CrosSettingsProvider::TEMPORARILY_UNTRUSTED == | 664 if (UserManager::Get()->IsUserLoggedIn()) |
| 654 CrosSettings::Get()->PrepareTrustedValues( | |
| 655 base::Bind(&WallpaperManager::InitializeRegisteredDeviceWallpaper, | |
| 656 base::Unretained(this)))) { | |
| 657 return; | 665 return; |
| 658 } | 666 |
| 659 bool disable_boot_animation = CommandLine::ForCurrentProcess()-> | 667 bool disable_boot_animation = CommandLine::ForCurrentProcess()-> |
| 660 HasSwitch(switches::kDisableBootAnimation); | 668 HasSwitch(switches::kDisableBootAnimation); |
| 661 bool show_users = true; | 669 bool show_users = true; |
| 662 bool result = CrosSettings::Get()->GetBoolean( | 670 bool result = CrosSettings::Get()->GetBoolean( |
|
pastarmovj
2013/01/21 14:55:24
Without the condition you removed on |PrepareTrust
Nikita (slow)
2013/01/23 09:53:34
Julian, were're fine here with using cached value.
pastarmovj
2013/01/23 10:05:59
Cool, thanks for explaining! I just wanted to make
bshe
2013/01/23 14:54:05
Sorry pastarmovj, I missed your comment. Thanks Ni
| |
| 663 kAccountsPrefShowUserNamesOnSignIn, &show_users); | 671 kAccountsPrefShowUserNamesOnSignIn, &show_users); |
| 664 DCHECK(result) << "Unable to fetch setting " | 672 DCHECK(result) << "Unable to fetch setting " |
| 665 << kAccountsPrefShowUserNamesOnSignIn; | 673 << kAccountsPrefShowUserNamesOnSignIn; |
| 666 const chromeos::UserList& users = UserManager::Get()->GetUsers(); | 674 const chromeos::UserList& users = UserManager::Get()->GetUsers(); |
| 667 if (!show_users || users.empty()) { | 675 if (!show_users || users.empty()) { |
| 668 // Boot into sign in form, preload default wallpaper. | 676 // Boot into sign in form, preload default wallpaper. |
| 669 SetDefaultWallpaper(); | 677 SetDefaultWallpaper(); |
| 670 return; | 678 return; |
| 671 } | 679 } |
| 672 | 680 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 913 FROM_HERE, | 921 FROM_HERE, |
| 914 base::Bind(&WallpaperManager::StartLoad, | 922 base::Bind(&WallpaperManager::StartLoad, |
| 915 base::Unretained(this), | 923 base::Unretained(this), |
| 916 email, | 924 email, |
| 917 info, | 925 info, |
| 918 update_wallpaper, | 926 update_wallpaper, |
| 919 valid_path)); | 927 valid_path)); |
| 920 } | 928 } |
| 921 | 929 |
| 922 } // chromeos | 930 } // chromeos |
| OLD | NEW |