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 // Enqueued but not started request might be updated by subsequent load | 128 // Enqueued but not started request might be updated by subsequent load |
129 // request. Therefore it's created empty, and updated being enqueued. | 129 // request. Therefore it's created empty, and updated being enqueued. |
130 // | 130 // |
131 // PendingWallpaper is owned by WallpaperManager, but reference to this object | 131 // PendingWallpaper is owned by WallpaperManager, but reference to this object |
132 // is passed to other threads by PostTask() calls, therefore it is | 132 // is passed to other threads by PostTask() calls, therefore it is |
133 // RefCountedThreadSafe. | 133 // RefCountedThreadSafe. |
134 class WallpaperManager::PendingWallpaper : | 134 class WallpaperManager::PendingWallpaper : |
135 public base::RefCountedThreadSafe<PendingWallpaper> { | 135 public base::RefCountedThreadSafe<PendingWallpaper> { |
136 public: | 136 public: |
137 // Do LoadWallpaper() - image not found in cache. | 137 // Do LoadWallpaper() - image not found in cache. |
138 PendingWallpaper( | 138 PendingWallpaper(const base::TimeDelta delay, const AccountId& account_id) |
139 const base::TimeDelta delay, | 139 : account_id_(account_id), |
140 const std::string& user_id) | |
141 : user_id_(user_id), | |
142 default_(false), | 140 default_(false), |
143 on_finish_(new MovableOnDestroyCallback( | 141 on_finish_(new MovableOnDestroyCallback( |
144 base::Bind(&WallpaperManager::PendingWallpaper::OnWallpaperSet, | 142 base::Bind(&WallpaperManager::PendingWallpaper::OnWallpaperSet, |
145 this))) { | 143 this))) { |
146 timer.Start( | 144 timer.Start( |
147 FROM_HERE, | 145 FROM_HERE, |
148 delay, | 146 delay, |
149 base::Bind(&WallpaperManager::PendingWallpaper::ProcessRequest, this)); | 147 base::Bind(&WallpaperManager::PendingWallpaper::ProcessRequest, this)); |
150 } | 148 } |
151 | 149 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 196 |
199 timer.Stop(); // Erase reference to self. | 197 timer.Stop(); // Erase reference to self. |
200 | 198 |
201 WallpaperManager* manager = WallpaperManager::Get(); | 199 WallpaperManager* manager = WallpaperManager::Get(); |
202 if (manager->pending_inactive_ == this) | 200 if (manager->pending_inactive_ == this) |
203 manager->pending_inactive_ = NULL; | 201 manager->pending_inactive_ = NULL; |
204 | 202 |
205 started_load_at_ = base::Time::Now(); | 203 started_load_at_ = base::Time::Now(); |
206 | 204 |
207 if (default_) { | 205 if (default_) { |
208 manager->DoSetDefaultWallpaper(user_id_, on_finish_.Pass()); | 206 manager->DoSetDefaultWallpaper(account_id_, on_finish_.Pass()); |
209 } else if (!user_wallpaper_.isNull()) { | 207 } else if (!user_wallpaper_.isNull()) { |
210 ash::Shell::GetInstance() | 208 ash::Shell::GetInstance() |
211 ->desktop_background_controller() | 209 ->desktop_background_controller() |
212 ->SetWallpaperImage(user_wallpaper_, info_.layout); | 210 ->SetWallpaperImage(user_wallpaper_, info_.layout); |
213 } else if (!wallpaper_path_.empty()) { | 211 } else if (!wallpaper_path_.empty()) { |
214 manager->task_runner_->PostTask( | 212 manager->task_runner_->PostTask( |
215 FROM_HERE, | 213 FROM_HERE, |
216 base::Bind(&WallpaperManager::GetCustomWallpaperInternal, | 214 base::Bind(&WallpaperManager::GetCustomWallpaperInternal, account_id_, |
217 user_id_, | 215 info_, wallpaper_path_, true /* update wallpaper */, |
218 info_, | |
219 wallpaper_path_, | |
220 true /* update wallpaper */, | |
221 base::Passed(on_finish_.Pass()), | 216 base::Passed(on_finish_.Pass()), |
222 manager->weak_factory_.GetWeakPtr())); | 217 manager->weak_factory_.GetWeakPtr())); |
223 } else if (!info_.location.empty()) { | 218 } else if (!info_.location.empty()) { |
224 manager->LoadWallpaper(user_id_, info_, true, on_finish_.Pass()); | 219 manager->LoadWallpaper(account_id_, info_, true, on_finish_.Pass()); |
225 } else { | 220 } else { |
226 // PendingWallpaper was created and never initialized? | 221 // PendingWallpaper was created and never initialized? |
227 NOTREACHED(); | 222 NOTREACHED(); |
228 // Error. Do not record time. | 223 // Error. Do not record time. |
229 started_load_at_ = base::Time(); | 224 started_load_at_ = base::Time(); |
230 } | 225 } |
231 on_finish_.reset(); | 226 on_finish_.reset(); |
232 } | 227 } |
233 | 228 |
234 // This method is called by callback, when load request is finished. | 229 // This method is called by callback, when load request is finished. |
(...skipping 14 matching lines...) Expand all Loading... |
249 } | 244 } |
250 if (manager->pending_inactive_ == this) { | 245 if (manager->pending_inactive_ == this) { |
251 // ProcessRequest() was never executed. | 246 // ProcessRequest() was never executed. |
252 manager->pending_inactive_ = NULL; | 247 manager->pending_inactive_ = NULL; |
253 } | 248 } |
254 | 249 |
255 // Destroy self. | 250 // Destroy self. |
256 manager->RemovePendingWallpaperFromList(this); | 251 manager->RemovePendingWallpaperFromList(this); |
257 } | 252 } |
258 | 253 |
259 std::string user_id_; | 254 AccountId account_id_; |
260 wallpaper::WallpaperInfo info_; | 255 wallpaper::WallpaperInfo info_; |
261 gfx::ImageSkia user_wallpaper_; | 256 gfx::ImageSkia user_wallpaper_; |
262 base::FilePath wallpaper_path_; | 257 base::FilePath wallpaper_path_; |
263 | 258 |
264 // Load default wallpaper instead of user image. | 259 // Load default wallpaper instead of user image. |
265 bool default_; | 260 bool default_; |
266 | 261 |
267 // This is "on destroy" callback that will call OnWallpaperSet() when | 262 // This is "on destroy" callback that will call OnWallpaperSet() when |
268 // image will be loaded. | 263 // image will be loaded. |
269 wallpaper::MovableOnDestroyCallbackHolder on_finish_; | 264 wallpaper::MovableOnDestroyCallbackHolder on_finish_; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 return; | 324 return; |
330 | 325 |
331 WallpaperInfo info; | 326 WallpaperInfo info; |
332 if (GetLoggedInUserWallpaperInfo(&info)) { | 327 if (GetLoggedInUserWallpaperInfo(&info)) { |
333 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", info.type, | 328 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", info.type, |
334 user_manager::User::WALLPAPER_TYPE_COUNT); | 329 user_manager::User::WALLPAPER_TYPE_COUNT); |
335 if (info == current_user_wallpaper_info_) | 330 if (info == current_user_wallpaper_info_) |
336 return; | 331 return; |
337 } | 332 } |
338 SetUserWallpaperNow( | 333 SetUserWallpaperNow( |
339 user_manager::UserManager::Get()->GetLoggedInUser()->email()); | 334 user_manager::UserManager::Get()->GetLoggedInUser()->GetAccountId()); |
340 } | 335 } |
341 | 336 |
342 void WallpaperManager::InitializeWallpaper() { | 337 void WallpaperManager::InitializeWallpaper() { |
343 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 338 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
344 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 339 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
345 | 340 |
346 // Apply device customization. | 341 // Apply device customization. |
347 if (ShouldUseCustomizedDefaultWallpaper()) { | 342 if (ShouldUseCustomizedDefaultWallpaper()) { |
348 SetDefaultWallpaperPath(GetCustomizedWallpaperDefaultRescaledFileName( | 343 SetDefaultWallpaperPath(GetCustomizedWallpaperDefaultRescaledFileName( |
349 wallpaper::kSmallWallpaperSuffix), | 344 wallpaper::kSmallWallpaperSuffix), |
(...skipping 17 matching lines...) Expand all Loading... |
367 // Zero delays is also set in autotests. | 362 // Zero delays is also set in autotests. |
368 if (WizardController::IsZeroDelayEnabled()) { | 363 if (WizardController::IsZeroDelayEnabled()) { |
369 // Ensure tests have some sort of wallpaper. | 364 // Ensure tests have some sort of wallpaper. |
370 ash::Shell::GetInstance()->desktop_background_controller()-> | 365 ash::Shell::GetInstance()->desktop_background_controller()-> |
371 CreateEmptyWallpaper(); | 366 CreateEmptyWallpaper(); |
372 return; | 367 return; |
373 } | 368 } |
374 | 369 |
375 if (!user_manager->IsUserLoggedIn()) { | 370 if (!user_manager->IsUserLoggedIn()) { |
376 if (!StartupUtils::IsDeviceRegistered()) | 371 if (!StartupUtils::IsDeviceRegistered()) |
377 SetDefaultWallpaperDelayed(login::SignInAccountId().GetUserEmail()); | 372 SetDefaultWallpaperDelayed(login::SignInAccountId()); |
378 else | 373 else |
379 InitializeRegisteredDeviceWallpaper(); | 374 InitializeRegisteredDeviceWallpaper(); |
380 return; | 375 return; |
381 } | 376 } |
382 SetUserWallpaperDelayed(user_manager->GetLoggedInUser()->email()); | 377 SetUserWallpaperDelayed(user_manager->GetLoggedInUser()->GetAccountId()); |
383 } | 378 } |
384 | 379 |
385 void WallpaperManager::Observe(int type, | 380 void WallpaperManager::Observe(int type, |
386 const content::NotificationSource& source, | 381 const content::NotificationSource& source, |
387 const content::NotificationDetails& details) { | 382 const content::NotificationDetails& details) { |
388 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 383 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
389 switch (type) { | 384 switch (type) { |
390 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { | 385 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { |
391 ClearDisposableWallpaperCache(); | 386 ClearDisposableWallpaperCache(); |
392 BrowserThread::PostDelayedTask( | 387 BrowserThread::PostDelayedTask( |
(...skipping 26 matching lines...) Expand all Loading... |
419 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); | 414 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); |
420 should_cache_wallpaper_ = false; | 415 should_cache_wallpaper_ = false; |
421 } | 416 } |
422 break; | 417 break; |
423 } | 418 } |
424 default: | 419 default: |
425 NOTREACHED() << "Unexpected notification " << type; | 420 NOTREACHED() << "Unexpected notification " << type; |
426 } | 421 } |
427 } | 422 } |
428 | 423 |
429 void WallpaperManager::RemoveUserWallpaperInfo(const std::string& user_id) { | 424 void WallpaperManager::RemoveUserWallpaperInfo(const AccountId& account_id) { |
430 if (wallpaper_cache_.find(user_id) != wallpaper_cache_.end()) | 425 if (wallpaper_cache_.find(account_id) != wallpaper_cache_.end()) |
431 wallpaper_cache_.erase(user_id); | 426 wallpaper_cache_.erase(account_id); |
432 | 427 |
433 PrefService* prefs = g_browser_process->local_state(); | 428 PrefService* prefs = g_browser_process->local_state(); |
434 // PrefService could be NULL in tests. | 429 // PrefService could be NULL in tests. |
435 if (!prefs) | 430 if (!prefs) |
436 return; | 431 return; |
437 WallpaperInfo info; | 432 WallpaperInfo info; |
438 GetUserWallpaperInfo(user_id, &info); | 433 GetUserWallpaperInfo(account_id, &info); |
439 DictionaryPrefUpdate prefs_wallpapers_info_update( | 434 DictionaryPrefUpdate prefs_wallpapers_info_update( |
440 prefs, wallpaper::kUsersWallpaperInfo); | 435 prefs, wallpaper::kUsersWallpaperInfo); |
441 prefs_wallpapers_info_update->RemoveWithoutPathExpansion(user_id, NULL); | 436 prefs_wallpapers_info_update->RemoveWithoutPathExpansion( |
442 DeleteUserWallpapers(user_id, info.location); | 437 account_id.GetUserEmail(), NULL); |
| 438 DeleteUserWallpapers(account_id, info.location); |
443 } | 439 } |
444 | 440 |
445 void WallpaperManager::OnPolicyFetched(const std::string& policy, | 441 void WallpaperManager::OnPolicyFetched(const std::string& policy, |
446 const std::string& user_id, | 442 const AccountId& account_id, |
447 scoped_ptr<std::string> data) { | 443 scoped_ptr<std::string> data) { |
448 if (!data) | 444 if (!data) |
449 return; | 445 return; |
450 | 446 |
451 wallpaper_loader_->Start( | 447 wallpaper_loader_->Start( |
452 data.Pass(), | 448 data.Pass(), |
453 0, // Do not crop. | 449 0, // Do not crop. |
454 base::Bind(&WallpaperManager::SetPolicyControlledWallpaper, | 450 base::Bind(&WallpaperManager::SetPolicyControlledWallpaper, |
455 weak_factory_.GetWeakPtr(), | 451 weak_factory_.GetWeakPtr(), account_id)); |
456 user_id)); | |
457 } | 452 } |
458 | 453 |
459 void WallpaperManager::SetCustomWallpaper( | 454 void WallpaperManager::SetCustomWallpaper( |
460 const std::string& user_id, | 455 const AccountId& account_id, |
461 const std::string& user_id_hash, | 456 const std::string& user_id_hash, |
462 const std::string& file, | 457 const std::string& file, |
463 wallpaper::WallpaperLayout layout, | 458 wallpaper::WallpaperLayout layout, |
464 user_manager::User::WallpaperType type, | 459 user_manager::User::WallpaperType type, |
465 const gfx::ImageSkia& image, | 460 const gfx::ImageSkia& image, |
466 bool update_wallpaper) { | 461 bool update_wallpaper) { |
467 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 462 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
468 | 463 |
469 // There is no visible background in kiosk mode. | 464 // There is no visible background in kiosk mode. |
470 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) | 465 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) |
471 return; | 466 return; |
472 | 467 |
473 // Don't allow custom wallpapers while policy is in effect. | 468 // Don't allow custom wallpapers while policy is in effect. |
474 if (type != user_manager::User::POLICY && IsPolicyControlled(user_id)) | 469 if (type != user_manager::User::POLICY && IsPolicyControlled(account_id)) |
475 return; | 470 return; |
476 | 471 |
477 base::FilePath wallpaper_path = GetCustomWallpaperPath( | 472 base::FilePath wallpaper_path = GetCustomWallpaperPath( |
478 wallpaper::kOriginalWallpaperSubDir, user_id_hash, file); | 473 wallpaper::kOriginalWallpaperSubDir, user_id_hash, file); |
479 | 474 |
480 // If decoded wallpaper is empty, we have probably failed to decode the file. | 475 // If decoded wallpaper is empty, we have probably failed to decode the file. |
481 // Use default wallpaper in this case. | 476 // Use default wallpaper in this case. |
482 if (image.isNull()) { | 477 if (image.isNull()) { |
483 SetDefaultWallpaperDelayed(user_id); | 478 SetDefaultWallpaperDelayed(account_id); |
484 return; | 479 return; |
485 } | 480 } |
486 | 481 |
487 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( | 482 const user_manager::User* user = |
488 AccountId::FromUserEmail(user_id)); | 483 user_manager::UserManager::Get()->FindUser(account_id); |
489 CHECK(user); | 484 CHECK(user); |
490 const bool is_persistent = | 485 const bool is_persistent = |
491 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 486 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
492 AccountId::FromUserEmail(user_id)) || | 487 account_id) || |
493 (type == user_manager::User::POLICY && | 488 (type == user_manager::User::POLICY && |
494 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); | 489 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); |
495 | 490 |
496 WallpaperInfo wallpaper_info = { | 491 WallpaperInfo wallpaper_info = { |
497 wallpaper_path.value(), | 492 wallpaper_path.value(), |
498 layout, | 493 layout, |
499 type, | 494 type, |
500 // Date field is not used. | 495 // Date field is not used. |
501 base::Time::Now().LocalMidnight() | 496 base::Time::Now().LocalMidnight() |
502 }; | 497 }; |
(...skipping 18 matching lines...) Expand all Loading... |
521 | 516 |
522 std::string relative_path = base::FilePath(user_id_hash).Append(file).value(); | 517 std::string relative_path = base::FilePath(user_id_hash).Append(file).value(); |
523 // User's custom wallpaper path is determined by relative path and the | 518 // User's custom wallpaper path is determined by relative path and the |
524 // appropriate wallpaper resolution in GetCustomWallpaperInternal. | 519 // appropriate wallpaper resolution in GetCustomWallpaperInternal. |
525 WallpaperInfo info = { | 520 WallpaperInfo info = { |
526 relative_path, | 521 relative_path, |
527 layout, | 522 layout, |
528 type, | 523 type, |
529 base::Time::Now().LocalMidnight() | 524 base::Time::Now().LocalMidnight() |
530 }; | 525 }; |
531 SetUserWallpaperInfo(user_id, info, is_persistent); | 526 SetUserWallpaperInfo(account_id, info, is_persistent); |
532 if (update_wallpaper) { | 527 if (update_wallpaper) { |
533 GetPendingWallpaper(user_id, false)->ResetSetWallpaperImage(image, info); | 528 GetPendingWallpaper(account_id, false)->ResetSetWallpaperImage(image, info); |
534 } | 529 } |
535 | 530 |
536 wallpaper_cache_[user_id] = CustomWallpaperElement(wallpaper_path, image); | 531 wallpaper_cache_[account_id] = CustomWallpaperElement(wallpaper_path, image); |
537 } | 532 } |
538 | 533 |
539 void WallpaperManager::SetDefaultWallpaperNow(const std::string& user_id) { | 534 void WallpaperManager::SetDefaultWallpaperNow(const AccountId& account_id) { |
540 GetPendingWallpaper(user_id, false)->ResetSetDefaultWallpaper(); | 535 GetPendingWallpaper(account_id, false)->ResetSetDefaultWallpaper(); |
541 } | 536 } |
542 | 537 |
543 void WallpaperManager::SetDefaultWallpaperDelayed(const std::string& user_id) { | 538 void WallpaperManager::SetDefaultWallpaperDelayed(const AccountId& account_id) { |
544 GetPendingWallpaper(user_id, true)->ResetSetDefaultWallpaper(); | 539 GetPendingWallpaper(account_id, true)->ResetSetDefaultWallpaper(); |
545 } | 540 } |
546 | 541 |
547 void WallpaperManager::DoSetDefaultWallpaper( | 542 void WallpaperManager::DoSetDefaultWallpaper( |
548 const std::string& user_id, | 543 const AccountId& account_id, |
549 MovableOnDestroyCallbackHolder on_finish) { | 544 MovableOnDestroyCallbackHolder on_finish) { |
550 // There is no visible background in kiosk mode. | 545 // There is no visible background in kiosk mode. |
551 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) | 546 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) |
552 return; | 547 return; |
553 wallpaper_cache_.erase(user_id); | 548 wallpaper_cache_.erase(account_id); |
554 // Some browser tests do not have a shell instance. As no wallpaper is needed | 549 // Some browser tests do not have a shell instance. As no wallpaper is needed |
555 // in these tests anyway, avoid loading one, preventing crashes and speeding | 550 // in these tests anyway, avoid loading one, preventing crashes and speeding |
556 // up the tests. | 551 // up the tests. |
557 if (!ash::Shell::HasInstance()) | 552 if (!ash::Shell::HasInstance()) |
558 return; | 553 return; |
559 | 554 |
560 WallpaperResolution resolution = GetAppropriateResolution(); | 555 WallpaperResolution resolution = GetAppropriateResolution(); |
561 const bool use_small = (resolution == WALLPAPER_RESOLUTION_SMALL); | 556 const bool use_small = (resolution == WALLPAPER_RESOLUTION_SMALL); |
562 | 557 |
563 const base::FilePath* file = NULL; | 558 const base::FilePath* file = NULL; |
564 | 559 |
565 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( | 560 const user_manager::User* user = |
566 AccountId::FromUserEmail(user_id)); | 561 user_manager::UserManager::Get()->FindUser(account_id); |
567 | 562 |
568 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) { | 563 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) { |
569 file = | 564 file = |
570 use_small ? &guest_small_wallpaper_file_ : &guest_large_wallpaper_file_; | 565 use_small ? &guest_small_wallpaper_file_ : &guest_large_wallpaper_file_; |
571 } else if (user && user->GetType() == user_manager::USER_TYPE_CHILD) { | 566 } else if (user && user->GetType() == user_manager::USER_TYPE_CHILD) { |
572 file = | 567 file = |
573 use_small ? &child_small_wallpaper_file_ : &child_large_wallpaper_file_; | 568 use_small ? &child_small_wallpaper_file_ : &child_large_wallpaper_file_; |
574 } else { | 569 } else { |
575 file = use_small ? &default_small_wallpaper_file_ | 570 file = use_small ? &default_small_wallpaper_file_ |
576 : &default_large_wallpaper_file_; | 571 : &default_large_wallpaper_file_; |
(...skipping 16 matching lines...) Expand all Loading... |
593 } | 588 } |
594 // 1x1 wallpaper is actually solid color, so it should be stretched. | 589 // 1x1 wallpaper is actually solid color, so it should be stretched. |
595 if (default_wallpaper_image_->image().width() == 1 && | 590 if (default_wallpaper_image_->image().width() == 1 && |
596 default_wallpaper_image_->image().height() == 1) | 591 default_wallpaper_image_->image().height() == 1) |
597 layout = wallpaper::WALLPAPER_LAYOUT_STRETCH; | 592 layout = wallpaper::WALLPAPER_LAYOUT_STRETCH; |
598 | 593 |
599 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( | 594 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( |
600 default_wallpaper_image_->image(), layout); | 595 default_wallpaper_image_->image(), layout); |
601 } | 596 } |
602 | 597 |
603 void WallpaperManager::SetUserWallpaperInfo(const std::string& user_id, | 598 void WallpaperManager::SetUserWallpaperInfo(const AccountId& account_id, |
604 const WallpaperInfo& info, | 599 const WallpaperInfo& info, |
605 bool is_persistent) { | 600 bool is_persistent) { |
606 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 601 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
607 current_user_wallpaper_info_ = info; | 602 current_user_wallpaper_info_ = info; |
608 if (!is_persistent) | 603 if (!is_persistent) |
609 return; | 604 return; |
610 | 605 |
611 PrefService* local_state = g_browser_process->local_state(); | 606 PrefService* local_state = g_browser_process->local_state(); |
612 DictionaryPrefUpdate wallpaper_update(local_state, | 607 DictionaryPrefUpdate wallpaper_update(local_state, |
613 wallpaper::kUsersWallpaperInfo); | 608 wallpaper::kUsersWallpaperInfo); |
614 | 609 |
615 base::DictionaryValue* wallpaper_info_dict = new base::DictionaryValue(); | 610 base::DictionaryValue* wallpaper_info_dict = new base::DictionaryValue(); |
616 wallpaper_info_dict->SetString(kNewWallpaperDateNodeName, | 611 wallpaper_info_dict->SetString(kNewWallpaperDateNodeName, |
617 base::Int64ToString(info.date.ToInternalValue())); | 612 base::Int64ToString(info.date.ToInternalValue())); |
618 wallpaper_info_dict->SetString(kNewWallpaperLocationNodeName, info.location); | 613 wallpaper_info_dict->SetString(kNewWallpaperLocationNodeName, info.location); |
619 wallpaper_info_dict->SetInteger(kNewWallpaperLayoutNodeName, info.layout); | 614 wallpaper_info_dict->SetInteger(kNewWallpaperLayoutNodeName, info.layout); |
620 wallpaper_info_dict->SetInteger(kNewWallpaperTypeNodeName, info.type); | 615 wallpaper_info_dict->SetInteger(kNewWallpaperTypeNodeName, info.type); |
621 wallpaper_update->SetWithoutPathExpansion(user_id, wallpaper_info_dict); | 616 wallpaper_update->SetWithoutPathExpansion(account_id.GetUserEmail(), |
| 617 wallpaper_info_dict); |
622 } | 618 } |
623 | 619 |
624 void WallpaperManager::ScheduleSetUserWallpaper(const std::string& user_id, | 620 void WallpaperManager::ScheduleSetUserWallpaper(const AccountId& account_id, |
625 bool delayed) { | 621 bool delayed) { |
626 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 622 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
627 // Some unit tests come here without a UserManager or without a pref system. | 623 // Some unit tests come here without a UserManager or without a pref system. |
628 if (!user_manager::UserManager::IsInitialized() || | 624 if (!user_manager::UserManager::IsInitialized() || |
629 !g_browser_process->local_state()) { | 625 !g_browser_process->local_state()) { |
630 return; | 626 return; |
631 } | 627 } |
632 | 628 |
633 const AccountId account_id = AccountId::FromUserEmail(user_id); | |
634 const user_manager::User* user = | 629 const user_manager::User* user = |
635 user_manager::UserManager::Get()->FindUser(account_id); | 630 user_manager::UserManager::Get()->FindUser(account_id); |
636 | 631 |
637 // User is unknown or there is no visible background in kiosk mode. | 632 // User is unknown or there is no visible background in kiosk mode. |
638 if (!user || user->GetType() == user_manager::USER_TYPE_KIOSK_APP) | 633 if (!user || user->GetType() == user_manager::USER_TYPE_KIOSK_APP) |
639 return; | 634 return; |
640 | 635 |
641 // Guest user or regular user in ephemeral mode. | 636 // Guest user or regular user in ephemeral mode. |
642 if ((user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 637 if ((user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
643 account_id) && | 638 account_id) && |
644 user->HasGaiaAccount()) || | 639 user->HasGaiaAccount()) || |
645 user->GetType() == user_manager::USER_TYPE_GUEST) { | 640 user->GetType() == user_manager::USER_TYPE_GUEST) { |
646 LOG(ERROR) << "User is ephemeral or guest! Fallback to default wallpaper."; | 641 LOG(ERROR) << "User is ephemeral or guest! Fallback to default wallpaper."; |
647 InitInitialUserWallpaper(user_id, false); | 642 InitInitialUserWallpaper(account_id, false); |
648 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); | 643 GetPendingWallpaper(account_id, delayed)->ResetSetDefaultWallpaper(); |
649 return; | 644 return; |
650 } | 645 } |
651 | 646 |
652 last_selected_user_ = user_id; | 647 last_selected_user_ = account_id; |
653 | 648 |
654 WallpaperInfo info; | 649 WallpaperInfo info; |
655 | 650 |
656 if (!GetUserWallpaperInfo(user_id, &info)) { | 651 if (!GetUserWallpaperInfo(account_id, &info)) { |
657 InitInitialUserWallpaper(user_id, true); | 652 InitInitialUserWallpaper(account_id, true); |
658 GetUserWallpaperInfo(user_id, &info); | 653 GetUserWallpaperInfo(account_id, &info); |
659 } | 654 } |
660 | 655 |
661 gfx::ImageSkia user_wallpaper; | 656 gfx::ImageSkia user_wallpaper; |
662 current_user_wallpaper_info_ = info; | 657 current_user_wallpaper_info_ = info; |
663 if (GetWallpaperFromCache(user_id, &user_wallpaper)) { | 658 if (GetWallpaperFromCache(account_id, &user_wallpaper)) { |
664 GetPendingWallpaper(user_id, delayed) | 659 GetPendingWallpaper(account_id, delayed) |
665 ->ResetSetWallpaperImage(user_wallpaper, info); | 660 ->ResetSetWallpaperImage(user_wallpaper, info); |
666 } else { | 661 } else { |
667 if (info.location.empty()) { | 662 if (info.location.empty()) { |
668 // Uses default built-in wallpaper when file is empty. Eventually, we | 663 // Uses default built-in wallpaper when file is empty. Eventually, we |
669 // will only ship one built-in wallpaper in ChromeOS image. | 664 // will only ship one built-in wallpaper in ChromeOS image. |
670 GetPendingWallpaper(user_id, delayed)->ResetSetDefaultWallpaper(); | 665 GetPendingWallpaper(account_id, delayed)->ResetSetDefaultWallpaper(); |
671 return; | 666 return; |
672 } | 667 } |
673 | 668 |
674 if (info.type == user_manager::User::CUSTOMIZED || | 669 if (info.type == user_manager::User::CUSTOMIZED || |
675 info.type == user_manager::User::POLICY) { | 670 info.type == user_manager::User::POLICY) { |
676 const char* sub_dir = GetCustomWallpaperSubdirForCurrentResolution(); | 671 const char* sub_dir = GetCustomWallpaperSubdirForCurrentResolution(); |
677 // Wallpaper is not resized when layout is | 672 // Wallpaper is not resized when layout is |
678 // wallpaper::WALLPAPER_LAYOUT_CENTER. | 673 // wallpaper::WALLPAPER_LAYOUT_CENTER. |
679 // Original wallpaper should be used in this case. | 674 // Original wallpaper should be used in this case. |
680 // TODO(bshe): Generates cropped custom wallpaper for CENTER layout. | 675 // TODO(bshe): Generates cropped custom wallpaper for CENTER layout. |
681 if (info.layout == wallpaper::WALLPAPER_LAYOUT_CENTER) | 676 if (info.layout == wallpaper::WALLPAPER_LAYOUT_CENTER) |
682 sub_dir = wallpaper::kOriginalWallpaperSubDir; | 677 sub_dir = wallpaper::kOriginalWallpaperSubDir; |
683 base::FilePath wallpaper_path = GetCustomWallpaperDir(sub_dir); | 678 base::FilePath wallpaper_path = GetCustomWallpaperDir(sub_dir); |
684 wallpaper_path = wallpaper_path.Append(info.location); | 679 wallpaper_path = wallpaper_path.Append(info.location); |
685 CustomWallpaperMap::iterator it = wallpaper_cache_.find(user_id); | 680 CustomWallpaperMap::iterator it = wallpaper_cache_.find(account_id); |
686 // Do not try to load the wallpaper if the path is the same. Since loading | 681 // Do not try to load the wallpaper if the path is the same. Since loading |
687 // could still be in progress, we ignore the existence of the image. | 682 // could still be in progress, we ignore the existence of the image. |
688 if (it != wallpaper_cache_.end() && it->second.first == wallpaper_path) | 683 if (it != wallpaper_cache_.end() && it->second.first == wallpaper_path) |
689 return; | 684 return; |
690 | 685 |
691 // Set the new path and reset the existing image - the image will be | 686 // Set the new path and reset the existing image - the image will be |
692 // added once it becomes available. | 687 // added once it becomes available. |
693 wallpaper_cache_[user_id] = | 688 wallpaper_cache_[account_id] = |
694 CustomWallpaperElement(wallpaper_path, gfx::ImageSkia()); | 689 CustomWallpaperElement(wallpaper_path, gfx::ImageSkia()); |
695 loaded_wallpapers_for_test_++; | 690 loaded_wallpapers_for_test_++; |
696 | 691 |
697 GetPendingWallpaper(user_id, delayed) | 692 GetPendingWallpaper(account_id, delayed) |
698 ->ResetSetCustomWallpaper(info, wallpaper_path); | 693 ->ResetSetCustomWallpaper(info, wallpaper_path); |
699 return; | 694 return; |
700 } | 695 } |
701 | 696 |
702 // Load downloaded ONLINE or converted DEFAULT wallpapers. | 697 // Load downloaded ONLINE or converted DEFAULT wallpapers. |
703 GetPendingWallpaper(user_id, delayed)->ResetLoadWallpaper(info); | 698 GetPendingWallpaper(account_id, delayed)->ResetLoadWallpaper(info); |
704 } | 699 } |
705 } | 700 } |
706 | 701 |
707 void WallpaperManager::SetWallpaperFromImageSkia( | 702 void WallpaperManager::SetWallpaperFromImageSkia( |
708 const std::string& user_id, | 703 const AccountId& account_id, |
709 const gfx::ImageSkia& image, | 704 const gfx::ImageSkia& image, |
710 wallpaper::WallpaperLayout layout, | 705 wallpaper::WallpaperLayout layout, |
711 bool update_wallpaper) { | 706 bool update_wallpaper) { |
712 DCHECK(user_manager::UserManager::Get()->IsUserLoggedIn()); | 707 DCHECK(user_manager::UserManager::Get()->IsUserLoggedIn()); |
713 | 708 |
714 // There is no visible background in kiosk mode. | 709 // There is no visible background in kiosk mode. |
715 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) | 710 if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) |
716 return; | 711 return; |
717 WallpaperInfo info; | 712 WallpaperInfo info; |
718 info.layout = layout; | 713 info.layout = layout; |
719 | 714 |
720 // This is an API call and we do not know the path. So we set the image, but | 715 // This is an API call and we do not know the path. So we set the image, but |
721 // no path. | 716 // no path. |
722 wallpaper_cache_[user_id] = CustomWallpaperElement(base::FilePath(), image); | 717 wallpaper_cache_[account_id] = |
| 718 CustomWallpaperElement(base::FilePath(), image); |
723 | 719 |
724 if (update_wallpaper) { | 720 if (update_wallpaper) { |
725 GetPendingWallpaper(last_selected_user_, false /* Not delayed */) | 721 GetPendingWallpaper(last_selected_user_, false /* Not delayed */) |
726 ->ResetSetWallpaperImage(image, info); | 722 ->ResetSetWallpaperImage(image, info); |
727 } | 723 } |
728 } | 724 } |
729 | 725 |
730 | 726 |
731 // WallpaperManager, private: -------------------------------------------------- | 727 // WallpaperManager, private: -------------------------------------------------- |
732 | 728 |
(...skipping 16 matching lines...) Expand all Loading... |
749 BrowserThread::GetBlockingPool() | 745 BrowserThread::GetBlockingPool() |
750 ->GetSequencedTaskRunnerWithShutdownBehavior( | 746 ->GetSequencedTaskRunnerWithShutdownBehavior( |
751 sequence_token_, base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 747 sequence_token_, base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
752 wallpaper_loader_ = | 748 wallpaper_loader_ = |
753 new UserImageLoader(ImageDecoder::ROBUST_JPEG_CODEC, task_runner_); | 749 new UserImageLoader(ImageDecoder::ROBUST_JPEG_CODEC, task_runner_); |
754 | 750 |
755 user_manager::UserManager::Get()->AddSessionStateObserver(this); | 751 user_manager::UserManager::Get()->AddSessionStateObserver(this); |
756 } | 752 } |
757 | 753 |
758 WallpaperManager::PendingWallpaper* WallpaperManager::GetPendingWallpaper( | 754 WallpaperManager::PendingWallpaper* WallpaperManager::GetPendingWallpaper( |
759 const std::string& user_id, | 755 const AccountId& account_id, |
760 bool delayed) { | 756 bool delayed) { |
761 if (!pending_inactive_) { | 757 if (!pending_inactive_) { |
762 loading_.push_back(new WallpaperManager::PendingWallpaper( | 758 loading_.push_back(new WallpaperManager::PendingWallpaper( |
763 (delayed ? GetWallpaperLoadDelay() | 759 (delayed ? GetWallpaperLoadDelay() |
764 : base::TimeDelta::FromMilliseconds(0)), | 760 : base::TimeDelta::FromMilliseconds(0)), |
765 user_id)); | 761 account_id)); |
766 pending_inactive_ = loading_.back().get(); | 762 pending_inactive_ = loading_.back().get(); |
767 } | 763 } |
768 return pending_inactive_; | 764 return pending_inactive_; |
769 } | 765 } |
770 | 766 |
771 void WallpaperManager::RemovePendingWallpaperFromList( | 767 void WallpaperManager::RemovePendingWallpaperFromList( |
772 PendingWallpaper* pending) { | 768 PendingWallpaper* pending) { |
773 DCHECK(loading_.size() > 0); | 769 DCHECK(loading_.size() > 0); |
774 for (WallpaperManager::PendingList::iterator i = loading_.begin(); | 770 for (WallpaperManager::PendingList::iterator i = loading_.begin(); |
775 i != loading_.end(); | 771 i != loading_.end(); |
(...skipping 17 matching lines...) Expand all Loading... |
793 bool show_users = true; | 789 bool show_users = true; |
794 bool result = CrosSettings::Get()->GetBoolean( | 790 bool result = CrosSettings::Get()->GetBoolean( |
795 kAccountsPrefShowUserNamesOnSignIn, &show_users); | 791 kAccountsPrefShowUserNamesOnSignIn, &show_users); |
796 DCHECK(result) << "Unable to fetch setting " | 792 DCHECK(result) << "Unable to fetch setting " |
797 << kAccountsPrefShowUserNamesOnSignIn; | 793 << kAccountsPrefShowUserNamesOnSignIn; |
798 const user_manager::UserList& users = | 794 const user_manager::UserList& users = |
799 user_manager::UserManager::Get()->GetUsers(); | 795 user_manager::UserManager::Get()->GetUsers(); |
800 int public_session_user_index = FindPublicSession(users); | 796 int public_session_user_index = FindPublicSession(users); |
801 if ((!show_users && public_session_user_index == -1) || users.empty()) { | 797 if ((!show_users && public_session_user_index == -1) || users.empty()) { |
802 // Boot into sign in form, preload default wallpaper. | 798 // Boot into sign in form, preload default wallpaper. |
803 SetDefaultWallpaperDelayed(login::SignInAccountId().GetUserEmail()); | 799 SetDefaultWallpaperDelayed(login::SignInAccountId()); |
804 return; | 800 return; |
805 } | 801 } |
806 | 802 |
807 if (!disable_boot_animation) { | 803 if (!disable_boot_animation) { |
808 int index = public_session_user_index != -1 ? public_session_user_index : 0; | 804 int index = public_session_user_index != -1 ? public_session_user_index : 0; |
809 // Normal boot, load user wallpaper. | 805 // Normal boot, load user wallpaper. |
810 // If normal boot animation is disabled wallpaper would be set | 806 // If normal boot animation is disabled wallpaper would be set |
811 // asynchronously once user pods are loaded. | 807 // asynchronously once user pods are loaded. |
812 SetUserWallpaperDelayed(users[index]->email()); | 808 SetUserWallpaperDelayed(users[index]->GetAccountId()); |
813 } | 809 } |
814 } | 810 } |
815 | 811 |
816 bool WallpaperManager::GetUserWallpaperInfo(const std::string& user_id, | 812 bool WallpaperManager::GetUserWallpaperInfo(const AccountId& account_id, |
817 WallpaperInfo* info) const { | 813 WallpaperInfo* info) const { |
818 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 814 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
819 | 815 |
820 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( | 816 if (user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( |
821 AccountId::FromUserEmail(user_id))) { | 817 account_id)) { |
822 // Default to the values cached in memory. | 818 // Default to the values cached in memory. |
823 *info = current_user_wallpaper_info_; | 819 *info = current_user_wallpaper_info_; |
824 | 820 |
825 // Ephemeral users do not save anything to local state. But we have got | 821 // Ephemeral users do not save anything to local state. But we have got |
826 // wallpaper info from memory. Returns true. | 822 // wallpaper info from memory. Returns true. |
827 return true; | 823 return true; |
828 } | 824 } |
829 | 825 |
830 const base::DictionaryValue* info_dict; | 826 const base::DictionaryValue* info_dict; |
831 if (!g_browser_process->local_state() | 827 if (!g_browser_process->local_state() |
832 ->GetDictionary(wallpaper::kUsersWallpaperInfo) | 828 ->GetDictionary(wallpaper::kUsersWallpaperInfo) |
833 ->GetDictionaryWithoutPathExpansion(user_id, &info_dict)) { | 829 ->GetDictionaryWithoutPathExpansion(account_id.GetUserEmail(), |
| 830 &info_dict)) { |
834 return false; | 831 return false; |
835 } | 832 } |
836 | 833 |
837 // Use temporary variables to keep |info| untouched in the error case. | 834 // Use temporary variables to keep |info| untouched in the error case. |
838 std::string location; | 835 std::string location; |
839 if (!info_dict->GetString(kNewWallpaperLocationNodeName, &location)) | 836 if (!info_dict->GetString(kNewWallpaperLocationNodeName, &location)) |
840 return false; | 837 return false; |
841 int layout; | 838 int layout; |
842 if (!info_dict->GetInteger(kNewWallpaperLayoutNodeName, &layout)) | 839 if (!info_dict->GetInteger(kNewWallpaperLayoutNodeName, &layout)) |
843 return false; | 840 return false; |
844 int type; | 841 int type; |
845 if (!info_dict->GetInteger(kNewWallpaperTypeNodeName, &type)) | 842 if (!info_dict->GetInteger(kNewWallpaperTypeNodeName, &type)) |
846 return false; | 843 return false; |
847 std::string date_string; | 844 std::string date_string; |
848 if (!info_dict->GetString(kNewWallpaperDateNodeName, &date_string)) | 845 if (!info_dict->GetString(kNewWallpaperDateNodeName, &date_string)) |
849 return false; | 846 return false; |
850 int64 date_val; | 847 int64 date_val; |
851 if (!base::StringToInt64(date_string, &date_val)) | 848 if (!base::StringToInt64(date_string, &date_val)) |
852 return false; | 849 return false; |
853 | 850 |
854 info->location = location; | 851 info->location = location; |
855 info->layout = static_cast<wallpaper::WallpaperLayout>(layout); | 852 info->layout = static_cast<wallpaper::WallpaperLayout>(layout); |
856 info->type = static_cast<user_manager::User::WallpaperType>(type); | 853 info->type = static_cast<user_manager::User::WallpaperType>(type); |
857 info->date = base::Time::FromInternalValue(date_val); | 854 info->date = base::Time::FromInternalValue(date_val); |
858 return true; | 855 return true; |
859 } | 856 } |
860 | 857 |
861 void WallpaperManager::OnWallpaperDecoded( | 858 void WallpaperManager::OnWallpaperDecoded( |
862 const std::string& user_id, | 859 const AccountId& account_id, |
863 wallpaper::WallpaperLayout layout, | 860 wallpaper::WallpaperLayout layout, |
864 bool update_wallpaper, | 861 bool update_wallpaper, |
865 MovableOnDestroyCallbackHolder on_finish, | 862 MovableOnDestroyCallbackHolder on_finish, |
866 const user_manager::UserImage& user_image) { | 863 const user_manager::UserImage& user_image) { |
867 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 864 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
868 TRACE_EVENT_ASYNC_END0("ui", "LoadAndDecodeWallpaper", this); | 865 TRACE_EVENT_ASYNC_END0("ui", "LoadAndDecodeWallpaper", this); |
869 | 866 |
870 // If decoded wallpaper is empty, we have probably failed to decode the file. | 867 // If decoded wallpaper is empty, we have probably failed to decode the file. |
871 // Use default wallpaper in this case. | 868 // Use default wallpaper in this case. |
872 if (user_image.image().isNull()) { | 869 if (user_image.image().isNull()) { |
873 // Updates user pref to default wallpaper. | 870 // Updates user pref to default wallpaper. |
874 WallpaperInfo info = {"", | 871 WallpaperInfo info = {"", |
875 wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, | 872 wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, |
876 user_manager::User::DEFAULT, | 873 user_manager::User::DEFAULT, |
877 base::Time::Now().LocalMidnight()}; | 874 base::Time::Now().LocalMidnight()}; |
878 SetUserWallpaperInfo(user_id, info, true); | 875 SetUserWallpaperInfo(account_id, info, true); |
879 | 876 |
880 if (update_wallpaper) | 877 if (update_wallpaper) |
881 DoSetDefaultWallpaper(user_id, on_finish.Pass()); | 878 DoSetDefaultWallpaper(account_id, on_finish.Pass()); |
882 return; | 879 return; |
883 } | 880 } |
884 | 881 |
885 // Update the image, but keep the path which was set earlier. | 882 // Update the image, but keep the path which was set earlier. |
886 wallpaper_cache_[user_id].second = user_image.image(); | 883 wallpaper_cache_[account_id].second = user_image.image(); |
887 | 884 |
888 if (update_wallpaper) { | 885 if (update_wallpaper) { |
889 ash::Shell::GetInstance() | 886 ash::Shell::GetInstance() |
890 ->desktop_background_controller() | 887 ->desktop_background_controller() |
891 ->SetWallpaperImage(user_image.image(), layout); | 888 ->SetWallpaperImage(user_image.image(), layout); |
892 } | 889 } |
893 } | 890 } |
894 | 891 |
895 void WallpaperManager::StartLoad(const std::string& user_id, | 892 void WallpaperManager::StartLoad(const AccountId& account_id, |
896 const WallpaperInfo& info, | 893 const WallpaperInfo& info, |
897 bool update_wallpaper, | 894 bool update_wallpaper, |
898 const base::FilePath& wallpaper_path, | 895 const base::FilePath& wallpaper_path, |
899 MovableOnDestroyCallbackHolder on_finish) { | 896 MovableOnDestroyCallbackHolder on_finish) { |
900 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 897 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
901 TRACE_EVENT_ASYNC_BEGIN0("ui", "LoadAndDecodeWallpaper", this); | 898 TRACE_EVENT_ASYNC_BEGIN0("ui", "LoadAndDecodeWallpaper", this); |
902 if (update_wallpaper) { | 899 if (update_wallpaper) { |
903 // We are now about to change the wallpaper, so update the path and remove | 900 // We are now about to change the wallpaper, so update the path and remove |
904 // the existing image. | 901 // the existing image. |
905 wallpaper_cache_[user_id] = CustomWallpaperElement(wallpaper_path, | 902 wallpaper_cache_[account_id] = |
906 gfx::ImageSkia()); | 903 CustomWallpaperElement(wallpaper_path, gfx::ImageSkia()); |
907 } | 904 } |
908 wallpaper_loader_->Start(wallpaper_path.value(), | 905 wallpaper_loader_->Start( |
909 0, // Do not crop. | 906 wallpaper_path.value(), |
910 base::Bind(&WallpaperManager::OnWallpaperDecoded, | 907 0, // Do not crop. |
911 weak_factory_.GetWeakPtr(), | 908 base::Bind(&WallpaperManager::OnWallpaperDecoded, |
912 user_id, | 909 weak_factory_.GetWeakPtr(), account_id, info.layout, |
913 info.layout, | 910 update_wallpaper, base::Passed(on_finish.Pass()))); |
914 update_wallpaper, | |
915 base::Passed(on_finish.Pass()))); | |
916 } | 911 } |
917 | 912 |
918 void WallpaperManager::SetCustomizedDefaultWallpaperAfterCheck( | 913 void WallpaperManager::SetCustomizedDefaultWallpaperAfterCheck( |
919 const GURL& wallpaper_url, | 914 const GURL& wallpaper_url, |
920 const base::FilePath& downloaded_file, | 915 const base::FilePath& downloaded_file, |
921 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files) { | 916 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files) { |
922 PrefService* pref_service = g_browser_process->local_state(); | 917 PrefService* pref_service = g_browser_process->local_state(); |
923 | 918 |
924 std::string current_url = | 919 std::string current_url = |
925 pref_service->GetString(prefs::kCustomizationDefaultWallpaperURL); | 920 pref_service->GetString(prefs::kCustomizationDefaultWallpaperURL); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 rescaled_files->path_rescaled_large(), | 959 rescaled_files->path_rescaled_large(), |
965 large_wallpaper_image.Pass()); | 960 large_wallpaper_image.Pass()); |
966 VLOG(1) << "Customized default wallpaper applied."; | 961 VLOG(1) << "Customized default wallpaper applied."; |
967 } | 962 } |
968 | 963 |
969 size_t WallpaperManager::GetPendingListSizeForTesting() const { | 964 size_t WallpaperManager::GetPendingListSizeForTesting() const { |
970 return loading_.size(); | 965 return loading_.size(); |
971 } | 966 } |
972 | 967 |
973 void WallpaperManager::UserChangedChildStatus(user_manager::User* user) { | 968 void WallpaperManager::UserChangedChildStatus(user_manager::User* user) { |
974 SetUserWallpaperNow(user->email()); | 969 SetUserWallpaperNow(user->GetAccountId()); |
975 } | 970 } |
976 | 971 |
977 void WallpaperManager::OnDefaultWallpaperDecoded( | 972 void WallpaperManager::OnDefaultWallpaperDecoded( |
978 const base::FilePath& path, | 973 const base::FilePath& path, |
979 const wallpaper::WallpaperLayout layout, | 974 const wallpaper::WallpaperLayout layout, |
980 scoped_ptr<user_manager::UserImage>* result_out, | 975 scoped_ptr<user_manager::UserImage>* result_out, |
981 MovableOnDestroyCallbackHolder on_finish, | 976 MovableOnDestroyCallbackHolder on_finish, |
982 const user_manager::UserImage& user_image) { | 977 const user_manager::UserImage& user_image) { |
983 result_out->reset(new user_manager::UserImage(user_image)); | 978 result_out->reset(new user_manager::UserImage(user_image)); |
984 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( | 979 ash::Shell::GetInstance()->desktop_background_controller()->SetWallpaperImage( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 } else { | 1029 } else { |
1035 if (large_wallpaper_image) { | 1030 if (large_wallpaper_image) { |
1036 default_wallpaper_image_.reset( | 1031 default_wallpaper_image_.reset( |
1037 new user_manager::UserImage(*large_wallpaper_image)); | 1032 new user_manager::UserImage(*large_wallpaper_image)); |
1038 default_wallpaper_image_->set_file_path( | 1033 default_wallpaper_image_->set_file_path( |
1039 default_large_wallpaper_file.value()); | 1034 default_large_wallpaper_file.value()); |
1040 } | 1035 } |
1041 } | 1036 } |
1042 | 1037 |
1043 if (need_update_screen) { | 1038 if (need_update_screen) { |
1044 DoSetDefaultWallpaper(std::string(), | 1039 DoSetDefaultWallpaper(EmptyAccountId(), |
1045 MovableOnDestroyCallbackHolder().Pass()); | 1040 MovableOnDestroyCallbackHolder().Pass()); |
1046 } | 1041 } |
1047 } | 1042 } |
1048 | 1043 |
1049 } // namespace chromeos | 1044 } // namespace chromeos |
OLD | NEW |