| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/users/wallpaper/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 6 | 6 |
| 7 #include <numeric> | 7 #include <numeric> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // | 128 // |
| 129 // PendingWallpaper is owned by WallpaperManager, but reference to this object | 129 // PendingWallpaper is owned by WallpaperManager, but reference to this object |
| 130 // is passed to other threads by PostTask() calls, therefore it is | 130 // is passed to other threads by PostTask() calls, therefore it is |
| 131 // RefCountedThreadSafe. | 131 // RefCountedThreadSafe. |
| 132 class WallpaperManager::PendingWallpaper : | 132 class WallpaperManager::PendingWallpaper : |
| 133 public base::RefCountedThreadSafe<PendingWallpaper> { | 133 public base::RefCountedThreadSafe<PendingWallpaper> { |
| 134 public: | 134 public: |
| 135 // Do LoadWallpaper() - image not found in cache. | 135 // Do LoadWallpaper() - image not found in cache. |
| 136 PendingWallpaper( | 136 PendingWallpaper( |
| 137 const base::TimeDelta delay, | 137 const base::TimeDelta delay, |
| 138 const std::string& user_id) | 138 const user_manager::UserID& user_id) |
| 139 : user_id_(user_id), | 139 : user_id_(user_id), |
| 140 default_(false), | 140 default_(false), |
| 141 on_finish_(new MovableOnDestroyCallback( | 141 on_finish_(new MovableOnDestroyCallback( |
| 142 base::Bind(&WallpaperManager::PendingWallpaper::OnWallpaperSet, | 142 base::Bind(&WallpaperManager::PendingWallpaper::OnWallpaperSet, |
| 143 this))) { | 143 this))) { |
| 144 timer.Start( | 144 timer.Start( |
| 145 FROM_HERE, | 145 FROM_HERE, |
| 146 delay, | 146 delay, |
| 147 base::Bind(&WallpaperManager::PendingWallpaper::ProcessRequest, this)); | 147 base::Bind(&WallpaperManager::PendingWallpaper::ProcessRequest, this)); |
| 148 } | 148 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 247 } |
| 248 if (manager->pending_inactive_ == this) { | 248 if (manager->pending_inactive_ == this) { |
| 249 // ProcessRequest() was never executed. | 249 // ProcessRequest() was never executed. |
| 250 manager->pending_inactive_ = NULL; | 250 manager->pending_inactive_ = NULL; |
| 251 } | 251 } |
| 252 | 252 |
| 253 // Destroy self. | 253 // Destroy self. |
| 254 manager->RemovePendingWallpaperFromList(this); | 254 manager->RemovePendingWallpaperFromList(this); |
| 255 } | 255 } |
| 256 | 256 |
| 257 std::string user_id_; | 257 const user_manager::UserID user_id_; |
| 258 wallpaper::WallpaperInfo info_; | 258 wallpaper::WallpaperInfo info_; |
| 259 gfx::ImageSkia user_wallpaper_; | 259 gfx::ImageSkia user_wallpaper_; |
| 260 base::FilePath wallpaper_path_; | 260 base::FilePath wallpaper_path_; |
| 261 | 261 |
| 262 // Load default wallpaper instead of user image. | 262 // Load default wallpaper instead of user image. |
| 263 bool default_; | 263 bool default_; |
| 264 | 264 |
| 265 // This is "on destroy" callback that will call OnWallpaperSet() when | 265 // This is "on destroy" callback that will call OnWallpaperSet() when |
| 266 // image will be loaded. | 266 // image will be loaded. |
| 267 wallpaper::MovableOnDestroyCallbackHolder on_finish_; | 267 wallpaper::MovableOnDestroyCallbackHolder on_finish_; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 return; | 327 return; |
| 328 | 328 |
| 329 WallpaperInfo info; | 329 WallpaperInfo info; |
| 330 if (GetLoggedInUserWallpaperInfo(&info)) { | 330 if (GetLoggedInUserWallpaperInfo(&info)) { |
| 331 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", info.type, | 331 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", info.type, |
| 332 user_manager::User::WALLPAPER_TYPE_COUNT); | 332 user_manager::User::WALLPAPER_TYPE_COUNT); |
| 333 if (info == current_user_wallpaper_info_) | 333 if (info == current_user_wallpaper_info_) |
| 334 return; | 334 return; |
| 335 } | 335 } |
| 336 SetUserWallpaperNow( | 336 SetUserWallpaperNow( |
| 337 user_manager::UserManager::Get()->GetLoggedInUser()->email()); | 337 user_manager::UserManager::Get()->GetLoggedInUser()->GetUserID()); |
| 338 } | 338 } |
| 339 | 339 |
| 340 void WallpaperManager::InitializeWallpaper() { | 340 void WallpaperManager::InitializeWallpaper() { |
| 341 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 341 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 342 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 342 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 343 | 343 |
| 344 // Apply device customization. | 344 // Apply device customization. |
| 345 if (ShouldUseCustomizedDefaultWallpaper()) { | 345 if (ShouldUseCustomizedDefaultWallpaper()) { |
| 346 SetDefaultWallpaperPath(GetCustomizedWallpaperDefaultRescaledFileName( | 346 SetDefaultWallpaperPath(GetCustomizedWallpaperDefaultRescaledFileName( |
| 347 wallpaper::kSmallWallpaperSuffix), | 347 wallpaper::kSmallWallpaperSuffix), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 365 // Zero delays is also set in autotests. | 365 // Zero delays is also set in autotests. |
| 366 if (WizardController::IsZeroDelayEnabled()) { | 366 if (WizardController::IsZeroDelayEnabled()) { |
| 367 // Ensure tests have some sort of wallpaper. | 367 // Ensure tests have some sort of wallpaper. |
| 368 ash::Shell::GetInstance()->desktop_background_controller()-> | 368 ash::Shell::GetInstance()->desktop_background_controller()-> |
| 369 CreateEmptyWallpaper(); | 369 CreateEmptyWallpaper(); |
| 370 return; | 370 return; |
| 371 } | 371 } |
| 372 | 372 |
| 373 if (!user_manager->IsUserLoggedIn()) { | 373 if (!user_manager->IsUserLoggedIn()) { |
| 374 if (!StartupUtils::IsDeviceRegistered()) | 374 if (!StartupUtils::IsDeviceRegistered()) |
| 375 SetDefaultWallpaperDelayed(chromeos::login::kSignInUser); | 375 SetDefaultWallpaperDelayed(chromeos::login::GetSignInUserID()); |
| 376 else | 376 else |
| 377 InitializeRegisteredDeviceWallpaper(); | 377 InitializeRegisteredDeviceWallpaper(); |
| 378 return; | 378 return; |
| 379 } | 379 } |
| 380 SetUserWallpaperDelayed(user_manager->GetLoggedInUser()->email()); | 380 SetUserWallpaperDelayed(user_manager->GetLoggedInUser()->GetUserID()); |
| 381 } | 381 } |
| 382 | 382 |
| 383 void WallpaperManager::Observe(int type, | 383 void WallpaperManager::Observe(int type, |
| 384 const content::NotificationSource& source, | 384 const content::NotificationSource& source, |
| 385 const content::NotificationDetails& details) { | 385 const content::NotificationDetails& details) { |
| 386 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 386 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 387 switch (type) { | 387 switch (type) { |
| 388 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { | 388 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { |
| 389 ClearDisposableWallpaperCache(); | 389 ClearDisposableWallpaperCache(); |
| 390 BrowserThread::PostDelayedTask( | 390 BrowserThread::PostDelayedTask( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 417 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); | 417 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); |
| 418 should_cache_wallpaper_ = false; | 418 should_cache_wallpaper_ = false; |
| 419 } | 419 } |
| 420 break; | 420 break; |
| 421 } | 421 } |
| 422 default: | 422 default: |
| 423 NOTREACHED() << "Unexpected notification " << type; | 423 NOTREACHED() << "Unexpected notification " << type; |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 | 426 |
| 427 void WallpaperManager::RemoveUserWallpaperInfo(const std::string& user_id) { | 427 void WallpaperManager::RemoveUserWallpaperInfo(const user_manager::UserID& user_
id) { |
| 428 WallpaperInfo info; | 428 WallpaperInfo info; |
| 429 GetUserWallpaperInfo(user_id, &info); | 429 GetUserWallpaperInfo(user_id, &info); |
| 430 PrefService* prefs = g_browser_process->local_state(); | 430 PrefService* prefs = g_browser_process->local_state(); |
| 431 DictionaryPrefUpdate prefs_wallpapers_info_update( | 431 DictionaryPrefUpdate prefs_wallpapers_info_update( |
| 432 prefs, wallpaper::kUsersWallpaperInfo); | 432 prefs, wallpaper::kUsersWallpaperInfo); |
| 433 prefs_wallpapers_info_update->RemoveWithoutPathExpansion(user_id, NULL); | 433 prefs_wallpapers_info_update->RemoveWithoutPathExpansion(user_id.GetUserEmail(
), NULL); |
| 434 DeleteUserWallpapers(user_id, info.location); | 434 DeleteUserWallpapers(user_id, info.location); |
| 435 } | 435 } |
| 436 | 436 |
| 437 void WallpaperManager::OnPolicyFetched(const std::string& policy, | 437 void WallpaperManager::OnPolicyFetched(const std::string& policy, |
| 438 const std::string& user_id, | 438 const user_manager::UserID& user_id, |
| 439 scoped_ptr<std::string> data) { | 439 scoped_ptr<std::string> data) { |
| 440 if (!data) | 440 if (!data) |
| 441 return; | 441 return; |
| 442 | 442 |
| 443 wallpaper_loader_->Start( | 443 wallpaper_loader_->Start( |
| 444 data.Pass(), | 444 data.Pass(), |
| 445 0, // Do not crop. | 445 0, // Do not crop. |
| 446 base::Bind(&WallpaperManager::SetPolicyControlledWallpaper, | 446 base::Bind(&WallpaperManager::SetPolicyControlledWallpaper, |
| 447 weak_factory_.GetWeakPtr(), | 447 weak_factory_.GetWeakPtr(), |
| 448 user_id)); | 448 user_id)); |
| 449 } | 449 } |
| 450 | 450 |
| 451 void WallpaperManager::SetCustomWallpaper( | 451 void WallpaperManager::SetCustomWallpaper( |
| 452 const std::string& user_id, | 452 const user_manager::UserID& user_id, |
| 453 const std::string& user_id_hash, | 453 const std::string& user_id_hash, |
| 454 const std::string& file, | 454 const std::string& file, |
| 455 wallpaper::WallpaperLayout layout, | 455 wallpaper::WallpaperLayout layout, |
| 456 user_manager::User::WallpaperType type, | 456 user_manager::User::WallpaperType type, |
| 457 const gfx::ImageSkia& image, | 457 const gfx::ImageSkia& image, |
| 458 bool update_wallpaper) { | 458 bool update_wallpaper) { |
| 459 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 459 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 460 | 460 |
| 461 // There is no visible background in kiosk mode. | 461 // There is no visible background in kiosk mode. |
| 462 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) | 462 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 base::Time::Now().LocalMidnight() | 521 base::Time::Now().LocalMidnight() |
| 522 }; | 522 }; |
| 523 SetUserWallpaperInfo(user_id, info, is_persistent); | 523 SetUserWallpaperInfo(user_id, info, is_persistent); |
| 524 if (update_wallpaper) { | 524 if (update_wallpaper) { |
| 525 GetPendingWallpaper(user_id, false)->ResetSetWallpaperImage(image, info); | 525 GetPendingWallpaper(user_id, false)->ResetSetWallpaperImage(image, info); |
| 526 } | 526 } |
| 527 | 527 |
| 528 wallpaper_cache_[user_id] = CustomWallpaperElement(wallpaper_path, image); | 528 wallpaper_cache_[user_id] = CustomWallpaperElement(wallpaper_path, image); |
| 529 } | 529 } |
| 530 | 530 |
| 531 void WallpaperManager::SetDefaultWallpaperNow(const std::string& user_id) { | 531 void WallpaperManager::SetDefaultWallpaperNow(const user_manager::UserID& user_i
d) { |
| 532 GetPendingWallpaper(user_id, false)->ResetSetDefaultWallpaper(); | 532 GetPendingWallpaper(user_id, false)->ResetSetDefaultWallpaper(); |
| 533 } | 533 } |
| 534 | 534 |
| 535 void WallpaperManager::SetDefaultWallpaperDelayed(const std::string& user_id) { | 535 void WallpaperManager::SetDefaultWallpaperDelayed(const user_manager::UserID& us
er_id) { |
| 536 GetPendingWallpaper(user_id, true)->ResetSetDefaultWallpaper(); | 536 GetPendingWallpaper(user_id, true)->ResetSetDefaultWallpaper(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 void WallpaperManager::DoSetDefaultWallpaper( | 539 void WallpaperManager::DoSetDefaultWallpaper( |
| 540 const std::string& user_id, | 540 const user_manager::UserID& user_id, |
| 541 MovableOnDestroyCallbackHolder on_finish) { | 541 MovableOnDestroyCallbackHolder on_finish) { |
| 542 // There is no visible background in kiosk mode. | 542 // There is no visible background in kiosk mode. |
| 543 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) | 543 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) |
| 544 return; | 544 return; |
| 545 wallpaper_cache_.erase(user_id); | 545 wallpaper_cache_.erase(user_id); |
| 546 // Some browser tests do not have a shell instance. As no wallpaper is needed | 546 // Some browser tests do not have a shell instance. As no wallpaper is needed |
| 547 // in these tests anyway, avoid loading one, preventing crashes and speeding | 547 // in these tests anyway, avoid loading one, preventing crashes and speeding |
| 548 // up the tests. | 548 // up the tests. |
| 549 if (!ash::Shell::HasInstance()) | 549 if (!ash::Shell::HasInstance()) |
| 550 return; | 550 return; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 } | 585 } |
| 586 // 1x1 wallpaper is actually solid color, so it should be stretched. | 586 // 1x1 wallpaper is actually solid color, so it should be stretched. |
| 587 if (default_wallpaper_image_->image().width() == 1 && | 587 if (default_wallpaper_image_->image().width() == 1 && |
| 588 default_wallpaper_image_->image().height() == 1) | 588 default_wallpaper_image_->image().height() == 1) |
| 589 layout = wallpaper::WALLPAPER_LAYOUT_STRETCH; | 589 layout = wallpaper::WALLPAPER_LAYOUT_STRETCH; |
| 590 | 590 |
| 591 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( | 591 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( |
| 592 default_wallpaper_image_->image(), layout); | 592 default_wallpaper_image_->image(), layout); |
| 593 } | 593 } |
| 594 | 594 |
| 595 void WallpaperManager::SetUserWallpaperInfo(const std::string& user_id, | 595 void WallpaperManager::SetUserWallpaperInfo(const user_manager::UserID& user_id, |
| 596 const WallpaperInfo& info, | 596 const WallpaperInfo& info, |
| 597 bool is_persistent) { | 597 bool is_persistent) { |
| 598 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 598 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 599 current_user_wallpaper_info_ = info; | 599 current_user_wallpaper_info_ = info; |
| 600 if (!is_persistent) | 600 if (!is_persistent) |
| 601 return; | 601 return; |
| 602 | 602 |
| 603 PrefService* local_state = g_browser_process->local_state(); | 603 PrefService* local_state = g_browser_process->local_state(); |
| 604 DictionaryPrefUpdate wallpaper_update(local_state, | 604 DictionaryPrefUpdate wallpaper_update(local_state, |
| 605 wallpaper::kUsersWallpaperInfo); | 605 wallpaper::kUsersWallpaperInfo); |
| 606 | 606 |
| 607 base::DictionaryValue* wallpaper_info_dict = new base::DictionaryValue(); | 607 base::DictionaryValue* wallpaper_info_dict = new base::DictionaryValue(); |
| 608 wallpaper_info_dict->SetString(kNewWallpaperDateNodeName, | 608 wallpaper_info_dict->SetString(kNewWallpaperDateNodeName, |
| 609 base::Int64ToString(info.date.ToInternalValue())); | 609 base::Int64ToString(info.date.ToInternalValue())); |
| 610 wallpaper_info_dict->SetString(kNewWallpaperLocationNodeName, info.location); | 610 wallpaper_info_dict->SetString(kNewWallpaperLocationNodeName, info.location); |
| 611 wallpaper_info_dict->SetInteger(kNewWallpaperLayoutNodeName, info.layout); | 611 wallpaper_info_dict->SetInteger(kNewWallpaperLayoutNodeName, info.layout); |
| 612 wallpaper_info_dict->SetInteger(kNewWallpaperTypeNodeName, info.type); | 612 wallpaper_info_dict->SetInteger(kNewWallpaperTypeNodeName, info.type); |
| 613 wallpaper_update->SetWithoutPathExpansion(user_id, wallpaper_info_dict); | 613 wallpaper_update->SetWithoutPathExpansion(user_id.GetUserEmail(), wallpaper_in
fo_dict); |
| 614 } | 614 } |
| 615 | 615 |
| 616 void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id, | 616 void WallpaperManager::ScheduleSetUserWallpaper(const user_manager::UserID& user
_id, |
| 617 bool delayed) { | 617 bool delayed) { |
| 618 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 618 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 619 // Some unit tests come here without a UserManager or without a pref system.q | 619 // Some unit tests come here without a UserManager or without a pref system.q |
| 620 if (!user_manager::UserManager::IsInitialized() || | 620 if (!user_manager::UserManager::IsInitialized() || |
| 621 !g_browser_process->local_state()) { | 621 !g_browser_process->local_state()) { |
| 622 return; | 622 return; |
| 623 } | 623 } |
| 624 | 624 |
| 625 // There is no visible background in kiosk mode. | 625 // There is no visible background in kiosk mode. |
| 626 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) | 626 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 ->ResetSetCustomWallpaper(info, wallpaper_path); | 688 ->ResetSetCustomWallpaper(info, wallpaper_path); |
| 689 return; | 689 return; |
| 690 } | 690 } |
| 691 | 691 |
| 692 // Load downloaded ONLINE or converted DEFAULT wallpapers. | 692 // Load downloaded ONLINE or converted DEFAULT wallpapers. |
| 693 GetPendingWallpaper(user_id, delayed)->ResetLoadWallpaper(info); | 693 GetPendingWallpaper(user_id, delayed)->ResetLoadWallpaper(info); |
| 694 } | 694 } |
| 695 } | 695 } |
| 696 | 696 |
| 697 void WallpaperManager::SetWallpaperFromImageSkia( | 697 void WallpaperManager::SetWallpaperFromImageSkia( |
| 698 const std::string& user_id, | 698 const user_manager::UserID& user_id, |
| 699 const gfx::ImageSkia& image, | 699 const gfx::ImageSkia& image, |
| 700 wallpaper::WallpaperLayout layout, | 700 wallpaper::WallpaperLayout layout, |
| 701 bool update_wallpaper) { | 701 bool update_wallpaper) { |
| 702 DCHECK(user_manager::UserManager::Get()->IsUserLoggedIn()); | 702 DCHECK(user_manager::UserManager::Get()->IsUserLoggedIn()); |
| 703 | 703 |
| 704 // There is no visible background in kiosk mode. | 704 // There is no visible background in kiosk mode. |
| 705 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) | 705 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) |
| 706 return; | 706 return; |
| 707 WallpaperInfo info; | 707 WallpaperInfo info; |
| 708 info.layout = layout; | 708 info.layout = layout; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 739 BrowserThread::GetBlockingPool() | 739 BrowserThread::GetBlockingPool() |
| 740 ->GetSequencedTaskRunnerWithShutdownBehavior( | 740 ->GetSequencedTaskRunnerWithShutdownBehavior( |
| 741 sequence_token_, base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 741 sequence_token_, base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 742 wallpaper_loader_ = | 742 wallpaper_loader_ = |
| 743 new UserImageLoader(ImageDecoder::ROBUST_JPEG_CODEC, task_runner_); | 743 new UserImageLoader(ImageDecoder::ROBUST_JPEG_CODEC, task_runner_); |
| 744 | 744 |
| 745 user_manager::UserManager::Get()->AddSessionStateObserver(this); | 745 user_manager::UserManager::Get()->AddSessionStateObserver(this); |
| 746 } | 746 } |
| 747 | 747 |
| 748 WallpaperManager::PendingWallpaper* WallpaperManager::GetPendingWallpaper( | 748 WallpaperManager::PendingWallpaper* WallpaperManager::GetPendingWallpaper( |
| 749 const std::string& user_id, | 749 const user_manager::UserID& user_id, |
| 750 bool delayed) { | 750 bool delayed) { |
| 751 if (!pending_inactive_) { | 751 if (!pending_inactive_) { |
| 752 loading_.push_back(new WallpaperManager::PendingWallpaper( | 752 loading_.push_back(new WallpaperManager::PendingWallpaper( |
| 753 (delayed ? GetWallpaperLoadDelay() | 753 (delayed ? GetWallpaperLoadDelay() |
| 754 : base::TimeDelta::FromMilliseconds(0)), | 754 : base::TimeDelta::FromMilliseconds(0)), |
| 755 user_id)); | 755 user_id)); |
| 756 pending_inactive_ = loading_.back().get(); | 756 pending_inactive_ = loading_.back().get(); |
| 757 } | 757 } |
| 758 return pending_inactive_; | 758 return pending_inactive_; |
| 759 } | 759 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 783 bool show_users = true; | 783 bool show_users = true; |
| 784 bool result = CrosSettings::Get()->GetBoolean( | 784 bool result = CrosSettings::Get()->GetBoolean( |
| 785 kAccountsPrefShowUserNamesOnSignIn, &show_users); | 785 kAccountsPrefShowUserNamesOnSignIn, &show_users); |
| 786 DCHECK(result) << "Unable to fetch setting " | 786 DCHECK(result) << "Unable to fetch setting " |
| 787 << kAccountsPrefShowUserNamesOnSignIn; | 787 << kAccountsPrefShowUserNamesOnSignIn; |
| 788 const user_manager::UserList& users = | 788 const user_manager::UserList& users = |
| 789 user_manager::UserManager::Get()->GetUsers(); | 789 user_manager::UserManager::Get()->GetUsers(); |
| 790 int public_session_user_index = FindPublicSession(users); | 790 int public_session_user_index = FindPublicSession(users); |
| 791 if ((!show_users && public_session_user_index == -1) || users.empty()) { | 791 if ((!show_users && public_session_user_index == -1) || users.empty()) { |
| 792 // Boot into sign in form, preload default wallpaper. | 792 // Boot into sign in form, preload default wallpaper. |
| 793 SetDefaultWallpaperDelayed(chromeos::login::kSignInUser); | 793 SetDefaultWallpaperDelayed(chromeos::login::GetSignInUserID()); |
| 794 return; | 794 return; |
| 795 } | 795 } |
| 796 | 796 |
| 797 if (!disable_boot_animation) { | 797 if (!disable_boot_animation) { |
| 798 int index = public_session_user_index != -1 ? public_session_user_index : 0; | 798 int index = public_session_user_index != -1 ? public_session_user_index : 0; |
| 799 // Normal boot, load user wallpaper. | 799 // Normal boot, load user wallpaper. |
| 800 // If normal boot animation is disabled wallpaper would be set | 800 // If normal boot animation is disabled wallpaper would be set |
| 801 // asynchronously once user pods are loaded. | 801 // asynchronously once user pods are loaded. |
| 802 SetUserWallpaperDelayed(users[index]->email()); | 802 SetUserWallpaperDelayed(users[index]->GetUserID()); |
| 803 } | 803 } |
| 804 } | 804 } |
| 805 | 805 |
| 806 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, | 806 bool WallpaperManager::GetUserWallpaperInfo(const user_manager::UserID& user_id, |
| 807 WallpaperInfo* info) const { | 807 WallpaperInfo* info) const { |
| 808 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 808 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 809 | 809 |
| 810 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 810 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
| 811 user_id)) { | 811 user_id)) { |
| 812 // Default to the values cached in memory. | 812 // Default to the values cached in memory. |
| 813 *info = current_user_wallpaper_info_; | 813 *info = current_user_wallpaper_info_; |
| 814 | 814 |
| 815 // Ephemeral users do not save anything to local state. But we have got | 815 // Ephemeral users do not save anything to local state. But we have got |
| 816 // wallpaper info from memory. Returns true. | 816 // wallpaper info from memory. Returns true. |
| 817 return true; | 817 return true; |
| 818 } | 818 } |
| 819 | 819 |
| 820 const base::DictionaryValue* info_dict; | 820 const base::DictionaryValue* info_dict; |
| 821 if (!g_browser_process->local_state() | 821 if (!g_browser_process->local_state() |
| 822 ->GetDictionary(wallpaper::kUsersWallpaperInfo) | 822 ->GetDictionary(wallpaper::kUsersWallpaperInfo) |
| 823 ->GetDictionaryWithoutPathExpansion(user_id, &info_dict)) { | 823 ->GetDictionaryWithoutPathExpansion(user_id.GetUserEmail(), &info_dic
t)) { |
| 824 return false; | 824 return false; |
| 825 } | 825 } |
| 826 | 826 |
| 827 // Use temporary variables to keep |info| untouched in the error case. | 827 // Use temporary variables to keep |info| untouched in the error case. |
| 828 std::string location; | 828 std::string location; |
| 829 if (!info_dict->GetString(kNewWallpaperLocationNodeName, &location)) | 829 if (!info_dict->GetString(kNewWallpaperLocationNodeName, &location)) |
| 830 return false; | 830 return false; |
| 831 int layout; | 831 int layout; |
| 832 if (!info_dict->GetInteger(kNewWallpaperLayoutNodeName, &layout)) | 832 if (!info_dict->GetInteger(kNewWallpaperLayoutNodeName, &layout)) |
| 833 return false; | 833 return false; |
| 834 int type; | 834 int type; |
| 835 if (!info_dict->GetInteger(kNewWallpaperTypeNodeName, &type)) | 835 if (!info_dict->GetInteger(kNewWallpaperTypeNodeName, &type)) |
| 836 return false; | 836 return false; |
| 837 std::string date_string; | 837 std::string date_string; |
| 838 if (!info_dict->GetString(kNewWallpaperDateNodeName, &date_string)) | 838 if (!info_dict->GetString(kNewWallpaperDateNodeName, &date_string)) |
| 839 return false; | 839 return false; |
| 840 int64 date_val; | 840 int64 date_val; |
| 841 if (!base::StringToInt64(date_string, &date_val)) | 841 if (!base::StringToInt64(date_string, &date_val)) |
| 842 return false; | 842 return false; |
| 843 | 843 |
| 844 info->location = location; | 844 info->location = location; |
| 845 info->layout = static_cast<wallpaper::WallpaperLayout>(layout); | 845 info->layout = static_cast<wallpaper::WallpaperLayout>(layout); |
| 846 info->type = static_cast<user_manager::User::WallpaperType>(type); | 846 info->type = static_cast<user_manager::User::WallpaperType>(type); |
| 847 info->date = base::Time::FromInternalValue(date_val); | 847 info->date = base::Time::FromInternalValue(date_val); |
| 848 return true; | 848 return true; |
| 849 } | 849 } |
| 850 | 850 |
| 851 void WallpaperManager::OnWallpaperDecoded( | 851 void WallpaperManager::OnWallpaperDecoded( |
| 852 const std::string& user_id, | 852 const user_manager::UserID& user_id, |
| 853 wallpaper::WallpaperLayout layout, | 853 wallpaper::WallpaperLayout layout, |
| 854 bool update_wallpaper, | 854 bool update_wallpaper, |
| 855 MovableOnDestroyCallbackHolder on_finish, | 855 MovableOnDestroyCallbackHolder on_finish, |
| 856 const user_manager::UserImage& user_image) { | 856 const user_manager::UserImage& user_image) { |
| 857 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 857 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 858 TRACE_EVENT_ASYNC_END0("ui", "LoadAndDecodeWallpaper", this); | 858 TRACE_EVENT_ASYNC_END0("ui", "LoadAndDecodeWallpaper", this); |
| 859 | 859 |
| 860 // If decoded wallpaper is empty, we have probably failed to decode the file. | 860 // If decoded wallpaper is empty, we have probably failed to decode the file. |
| 861 // Use default wallpaper in this case. | 861 // Use default wallpaper in this case. |
| 862 if (user_image.image().isNull()) { | 862 if (user_image.image().isNull()) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 875 // Update the image, but keep the path which was set earlier. | 875 // Update the image, but keep the path which was set earlier. |
| 876 wallpaper_cache_[user_id].second = user_image.image(); | 876 wallpaper_cache_[user_id].second = user_image.image(); |
| 877 | 877 |
| 878 if (update_wallpaper) { | 878 if (update_wallpaper) { |
| 879 ash::Shell::GetInstance() | 879 ash::Shell::GetInstance() |
| 880 ->desktop_background_controller() | 880 ->desktop_background_controller() |
| 881 ->SetWallpaperImage(user_image.image(), layout); | 881 ->SetWallpaperImage(user_image.image(), layout); |
| 882 } | 882 } |
| 883 } | 883 } |
| 884 | 884 |
| 885 void WallpaperManager::StartLoad(const std::string& user_id, | 885 void WallpaperManager::StartLoad(const user_manager::UserID& user_id, |
| 886 const WallpaperInfo& info, | 886 const WallpaperInfo& info, |
| 887 bool update_wallpaper, | 887 bool update_wallpaper, |
| 888 const base::FilePath& wallpaper_path, | 888 const base::FilePath& wallpaper_path, |
| 889 MovableOnDestroyCallbackHolder on_finish) { | 889 MovableOnDestroyCallbackHolder on_finish) { |
| 890 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 890 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 891 TRACE_EVENT_ASYNC_BEGIN0("ui", "LoadAndDecodeWallpaper", this); | 891 TRACE_EVENT_ASYNC_BEGIN0("ui", "LoadAndDecodeWallpaper", this); |
| 892 if (update_wallpaper) { | 892 if (update_wallpaper) { |
| 893 // We are now about to change the wallpaper, so update the path and remove | 893 // We are now about to change the wallpaper, so update the path and remove |
| 894 // the existing image. | 894 // the existing image. |
| 895 wallpaper_cache_[user_id] = CustomWallpaperElement(wallpaper_path, | 895 wallpaper_cache_[user_id] = CustomWallpaperElement(wallpaper_path, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 rescaled_files->path_rescaled_large(), | 954 rescaled_files->path_rescaled_large(), |
| 955 large_wallpaper_image.Pass()); | 955 large_wallpaper_image.Pass()); |
| 956 VLOG(1) << "Customized default wallpaper applied."; | 956 VLOG(1) << "Customized default wallpaper applied."; |
| 957 } | 957 } |
| 958 | 958 |
| 959 size_t WallpaperManager::GetPendingListSizeForTesting() const { | 959 size_t WallpaperManager::GetPendingListSizeForTesting() const { |
| 960 return loading_.size(); | 960 return loading_.size(); |
| 961 } | 961 } |
| 962 | 962 |
| 963 void WallpaperManager::UserChangedChildStatus(user_manager::User* user) { | 963 void WallpaperManager::UserChangedChildStatus(user_manager::User* user) { |
| 964 SetUserWallpaperNow(user->email()); | 964 SetUserWallpaperNow(user->GetUserID()); |
| 965 } | 965 } |
| 966 | 966 |
| 967 void WallpaperManager::OnDefaultWallpaperDecoded( | 967 void WallpaperManager::OnDefaultWallpaperDecoded( |
| 968 const base::FilePath& path, | 968 const base::FilePath& path, |
| 969 const wallpaper::WallpaperLayout layout, | 969 const wallpaper::WallpaperLayout layout, |
| 970 scoped_ptr<user_manager::UserImage>* result_out, | 970 scoped_ptr<user_manager::UserImage>* result_out, |
| 971 MovableOnDestroyCallbackHolder on_finish, | 971 MovableOnDestroyCallbackHolder on_finish, |
| 972 const user_manager::UserImage& user_image) { | 972 const user_manager::UserImage& user_image) { |
| 973 result_out->reset(new user_manager::UserImage(user_image)); | 973 result_out->reset(new user_manager::UserImage(user_image)); |
| 974 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( | 974 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 } else { | 1024 } else { |
| 1025 if (large_wallpaper_image) { | 1025 if (large_wallpaper_image) { |
| 1026 default_wallpaper_image_.reset( | 1026 default_wallpaper_image_.reset( |
| 1027 new user_manager::UserImage(*large_wallpaper_image)); | 1027 new user_manager::UserImage(*large_wallpaper_image)); |
| 1028 default_wallpaper_image_->set_file_path( | 1028 default_wallpaper_image_->set_file_path( |
| 1029 default_large_wallpaper_file.value()); | 1029 default_large_wallpaper_file.value()); |
| 1030 } | 1030 } |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 if (need_update_screen) { | 1033 if (need_update_screen) { |
| 1034 DoSetDefaultWallpaper(std::string(), | 1034 DoSetDefaultWallpaper(user_manager::UserID(std::string(), std::string()), |
| 1035 MovableOnDestroyCallbackHolder().Pass()); | 1035 MovableOnDestroyCallbackHolder().Pass()); |
| 1036 } | 1036 } |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 } // namespace chromeos | 1039 } // namespace chromeos |
| OLD | NEW |