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

Side by Side Diff: components/wallpaper/wallpaper_manager_base.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
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 "components/wallpaper/wallpaper_manager_base.h" 5 #include "components/wallpaper/wallpaper_manager_base.h"
6 6
7 #include <numeric> 7 #include <numeric>
8 #include <vector> 8 #include <vector>
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 10 matching lines...) Expand all
21 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
22 #include "base/sys_info.h" 22 #include "base/sys_info.h"
23 #include "base/threading/worker_pool.h" 23 #include "base/threading/worker_pool.h"
24 #include "base/time/time.h" 24 #include "base/time/time.h"
25 #include "base/values.h" 25 #include "base/values.h"
26 #include "chromeos/chromeos_switches.h" 26 #include "chromeos/chromeos_switches.h"
27 #include "chromeos/cryptohome/async_method_caller.h" 27 #include "chromeos/cryptohome/async_method_caller.h"
28 #include "chromeos/dbus/dbus_thread_manager.h" 28 #include "chromeos/dbus/dbus_thread_manager.h"
29 #include "chromeos/login/user_names.h" 29 #include "chromeos/login/user_names.h"
30 #include "components/user_manager/user.h" 30 #include "components/user_manager/user.h"
31 #include "components/user_manager/user_id.h"
31 #include "components/user_manager/user_image/user_image.h" 32 #include "components/user_manager/user_image/user_image.h"
32 #include "components/user_manager/user_manager.h" 33 #include "components/user_manager/user_manager.h"
33 #include "components/user_manager/user_type.h" 34 #include "components/user_manager/user_type.h"
34 #include "components/wallpaper/wallpaper_layout.h" 35 #include "components/wallpaper/wallpaper_layout.h"
35 #include "content/public/browser/browser_thread.h" 36 #include "content/public/browser/browser_thread.h"
36 #include "third_party/skia/include/core/SkColor.h" 37 #include "third_party/skia/include/core/SkColor.h"
37 #include "ui/gfx/codec/jpeg_codec.h" 38 #include "ui/gfx/codec/jpeg_codec.h"
38 #include "ui/gfx/geometry/safe_integer_conversions.h" 39 #include "ui/gfx/geometry/safe_integer_conversions.h"
39 #include "ui/gfx/image/image_skia_operations.h" 40 #include "ui/gfx/image/image_skia_operations.h"
40 #include "ui/gfx/skia_util.h" 41 #include "ui/gfx/skia_util.h"
(...skipping 26 matching lines...) Expand all
67 // color. 68 // color.
68 const SkColor kDefaultWallpaperColor = SK_ColorGRAY; 69 const SkColor kDefaultWallpaperColor = SK_ColorGRAY;
69 70
70 // The path ids for directories. 71 // The path ids for directories.
71 int dir_user_data_path_id = -1; // chrome::DIR_USER_DATA 72 int dir_user_data_path_id = -1; // chrome::DIR_USER_DATA
72 int dir_chromeos_wallpapers_path_id = -1; // chrome::DIR_CHROMEOS_WALLPAPERS 73 int dir_chromeos_wallpapers_path_id = -1; // chrome::DIR_CHROMEOS_WALLPAPERS
73 int dir_chromeos_custom_wallpapers_path_id = 74 int dir_chromeos_custom_wallpapers_path_id =
74 -1; // chrome::DIR_CHROMEOS_CUSTOM_WALLPAPERS 75 -1; // chrome::DIR_CHROMEOS_CUSTOM_WALLPAPERS
75 76
76 bool MoveCustomWallpaperDirectory(const char* sub_dir, 77 bool MoveCustomWallpaperDirectory(const char* sub_dir,
77 const std::string& user_id, 78 const user_manager::UserID& user_id,
78 const std::string& user_id_hash) { 79 const std::string& user_id_hash) {
79 base::FilePath base_path = 80 base::FilePath base_path =
80 WallpaperManagerBase::GetCustomWallpaperDir(sub_dir); 81 WallpaperManagerBase::GetCustomWallpaperDir(sub_dir);
81 base::FilePath to_path = base_path.Append(user_id_hash); 82 base::FilePath to_path = base_path.Append(user_id_hash);
82 base::FilePath from_path = base_path.Append(user_id); 83 base::FilePath from_path = base_path.Append(user_id.GetUserEmail());
83 if (base::PathExists(from_path)) 84 if (base::PathExists(from_path))
84 return base::Move(from_path, to_path); 85 return base::Move(from_path, to_path);
85 return false; 86 return false;
86 } 87 }
87 88
88 // Deletes a list of wallpaper files in |file_list|. 89 // Deletes a list of wallpaper files in |file_list|.
89 void DeleteWallpaperInList(const std::vector<base::FilePath>& file_list) { 90 void DeleteWallpaperInList(const std::vector<base::FilePath>& file_list) {
90 for (std::vector<base::FilePath>::const_iterator it = file_list.begin(); 91 for (std::vector<base::FilePath>::const_iterator it = file_list.begin();
91 it != file_list.end(); ++it) { 92 it != file_list.end(); ++it) {
92 base::FilePath path = *it; 93 base::FilePath path = *it;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 252
252 // TestApi. For testing purpose 253 // TestApi. For testing purpose
253 WallpaperManagerBase::TestApi::TestApi(WallpaperManagerBase* wallpaper_manager) 254 WallpaperManagerBase::TestApi::TestApi(WallpaperManagerBase* wallpaper_manager)
254 : wallpaper_manager_(wallpaper_manager) { 255 : wallpaper_manager_(wallpaper_manager) {
255 } 256 }
256 257
257 WallpaperManagerBase::TestApi::~TestApi() { 258 WallpaperManagerBase::TestApi::~TestApi() {
258 } 259 }
259 260
260 bool WallpaperManagerBase::TestApi::GetWallpaperFromCache( 261 bool WallpaperManagerBase::TestApi::GetWallpaperFromCache(
261 const std::string& user_id, 262 const user_manager::UserID& user_id,
262 gfx::ImageSkia* image) { 263 gfx::ImageSkia* image) {
263 return wallpaper_manager_->GetWallpaperFromCache(user_id, image); 264 return wallpaper_manager_->GetWallpaperFromCache(user_id, image);
264 } 265 }
265 266
266 bool WallpaperManagerBase::TestApi::GetPathFromCache( 267 bool WallpaperManagerBase::TestApi::GetPathFromCache(
267 const std::string& user_id, 268 const user_manager::UserID& user_id,
268 base::FilePath* path) { 269 base::FilePath* path) {
269 return wallpaper_manager_->GetPathFromCache(user_id, path); 270 return wallpaper_manager_->GetPathFromCache(user_id, path);
270 } 271 }
271 272
272 void WallpaperManagerBase::TestApi::SetWallpaperCache( 273 void WallpaperManagerBase::TestApi::SetWallpaperCache(
273 const std::string& user_id, 274 const user_manager::UserID& user_id,
274 const base::FilePath& path, 275 const base::FilePath& path,
275 const gfx::ImageSkia& image) { 276 const gfx::ImageSkia& image) {
276 DCHECK(!image.isNull()); 277 DCHECK(!image.isNull());
277 wallpaper_manager_->wallpaper_cache_[user_id] = 278 wallpaper_manager_->wallpaper_cache_[user_id] =
278 CustomWallpaperElement(path, image); 279 CustomWallpaperElement(path, image);
279 } 280 }
280 281
281 void WallpaperManagerBase::TestApi::ClearDisposableWallpaperCache() { 282 void WallpaperManagerBase::TestApi::ClearDisposableWallpaperCache() {
282 wallpaper_manager_->ClearDisposableWallpaperCache(); 283 wallpaper_manager_->ClearDisposableWallpaperCache();
283 } 284 }
(...skipping 27 matching lines...) Expand all
311 312
312 void WallpaperManagerBase::EnsureLoggedInUserWallpaperLoaded() { 313 void WallpaperManagerBase::EnsureLoggedInUserWallpaperLoaded() {
313 WallpaperInfo info; 314 WallpaperInfo info;
314 if (GetLoggedInUserWallpaperInfo(&info)) { 315 if (GetLoggedInUserWallpaperInfo(&info)) {
315 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", info.type, 316 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", info.type,
316 user_manager::User::WALLPAPER_TYPE_COUNT); 317 user_manager::User::WALLPAPER_TYPE_COUNT);
317 if (info == current_user_wallpaper_info_) 318 if (info == current_user_wallpaper_info_)
318 return; 319 return;
319 } 320 }
320 SetUserWallpaperNow( 321 SetUserWallpaperNow(
321 user_manager::UserManager::Get()->GetLoggedInUser()->email()); 322 user_manager::UserManager::Get()->GetLoggedInUser()->GetUserID());
322 } 323 }
323 324
324 void WallpaperManagerBase::ClearDisposableWallpaperCache() { 325 void WallpaperManagerBase::ClearDisposableWallpaperCache() {
325 // Cancel callback for previous cache requests. 326 // Cancel callback for previous cache requests.
326 weak_factory_.InvalidateWeakPtrs(); 327 weak_factory_.InvalidateWeakPtrs();
327 // Keep the wallpaper of logged in users in cache at multi-profile mode. 328 // Keep the wallpaper of logged in users in cache at multi-profile mode.
328 std::set<std::string> logged_in_users_names; 329 std::set<user_manager::UserID> logged_in_users_ids;
329 const user_manager::UserList& logged_users = 330 const user_manager::UserList& logged_users =
330 user_manager::UserManager::Get()->GetLoggedInUsers(); 331 user_manager::UserManager::Get()->GetLoggedInUsers();
331 for (user_manager::UserList::const_iterator it = logged_users.begin(); 332 for (user_manager::UserList::const_iterator it = logged_users.begin();
332 it != logged_users.end(); ++it) { 333 it != logged_users.end(); ++it) {
333 logged_in_users_names.insert((*it)->email()); 334 logged_in_users_ids.insert((*it)->GetUserID());
334 } 335 }
335 336
336 CustomWallpaperMap logged_in_users_cache; 337 CustomWallpaperMap logged_in_users_cache;
337 for (CustomWallpaperMap::iterator it = wallpaper_cache_.begin(); 338 for (CustomWallpaperMap::iterator it = wallpaper_cache_.begin();
338 it != wallpaper_cache_.end(); ++it) { 339 it != wallpaper_cache_.end(); ++it) {
339 if (logged_in_users_names.find(it->first) != logged_in_users_names.end()) { 340 if (logged_in_users_ids.find(it->first) != logged_in_users_ids.end()) {
340 logged_in_users_cache.insert(*it); 341 logged_in_users_cache.insert(*it);
341 } 342 }
342 } 343 }
343 wallpaper_cache_ = logged_in_users_cache; 344 wallpaper_cache_ = logged_in_users_cache;
344 } 345 }
345 346
346 bool WallpaperManagerBase::GetLoggedInUserWallpaperInfo(WallpaperInfo* info) { 347 bool WallpaperManagerBase::GetLoggedInUserWallpaperInfo(WallpaperInfo* info) {
347 DCHECK_CURRENTLY_ON(BrowserThread::UI); 348 DCHECK_CURRENTLY_ON(BrowserThread::UI);
348 349
349 if (user_manager::UserManager::Get()->IsLoggedInAsStub()) { 350 if (user_manager::UserManager::Get()->IsLoggedInAsStub()) {
350 info->location = current_user_wallpaper_info_.location = ""; 351 info->location = current_user_wallpaper_info_.location = "";
351 info->layout = current_user_wallpaper_info_.layout = 352 info->layout = current_user_wallpaper_info_.layout =
352 WALLPAPER_LAYOUT_CENTER_CROPPED; 353 WALLPAPER_LAYOUT_CENTER_CROPPED;
353 info->type = current_user_wallpaper_info_.type = 354 info->type = current_user_wallpaper_info_.type =
354 user_manager::User::DEFAULT; 355 user_manager::User::DEFAULT;
355 info->date = current_user_wallpaper_info_.date = 356 info->date = current_user_wallpaper_info_.date =
356 base::Time::Now().LocalMidnight(); 357 base::Time::Now().LocalMidnight();
357 return true; 358 return true;
358 } 359 }
359 360
360 return GetUserWallpaperInfo( 361 return GetUserWallpaperInfo(
361 user_manager::UserManager::Get()->GetLoggedInUser()->email(), info); 362 user_manager::UserManager::Get()->GetLoggedInUser()->GetUserID(), info);
362 } 363 }
363 364
364 // static 365 // static
365 bool WallpaperManagerBase::ResizeImage( 366 bool WallpaperManagerBase::ResizeImage(
366 const gfx::ImageSkia& image, 367 const gfx::ImageSkia& image,
367 WallpaperLayout layout, 368 WallpaperLayout layout,
368 int preferred_width, 369 int preferred_width,
369 int preferred_height, 370 int preferred_height,
370 scoped_refptr<base::RefCountedBytes>* output, 371 scoped_refptr<base::RefCountedBytes>* output,
371 gfx::ImageSkia* output_skia) { 372 gfx::ImageSkia* output_skia) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 scoped_refptr<base::RefCountedBytes> data; 437 scoped_refptr<base::RefCountedBytes> data;
437 if (ResizeImage(image, layout, preferred_width, preferred_height, &data, 438 if (ResizeImage(image, layout, preferred_width, preferred_height, &data,
438 output_skia)) { 439 output_skia)) {
439 return SaveWallpaperInternal( 440 return SaveWallpaperInternal(
440 path, reinterpret_cast<const char*>(data->front()), data->size()); 441 path, reinterpret_cast<const char*>(data->front()), data->size());
441 } 442 }
442 return false; 443 return false;
443 } 444 }
444 445
445 bool WallpaperManagerBase::IsPolicyControlled( 446 bool WallpaperManagerBase::IsPolicyControlled(
446 const std::string& user_id) const { 447 const user_manager::UserID& user_id) const {
447 WallpaperInfo info; 448 WallpaperInfo info;
448 if (!GetUserWallpaperInfo(user_id, &info)) 449 if (!GetUserWallpaperInfo(user_id, &info))
449 return false; 450 return false;
450 return info.type == user_manager::User::POLICY; 451 return info.type == user_manager::User::POLICY;
451 } 452 }
452 453
453 void WallpaperManagerBase::OnPolicySet(const std::string& policy, 454 void WallpaperManagerBase::OnPolicySet(const std::string& policy,
454 const std::string& user_id) { 455 const user_manager::UserID& user_id) {
455 WallpaperInfo info; 456 WallpaperInfo info;
456 GetUserWallpaperInfo(user_id, &info); 457 GetUserWallpaperInfo(user_id, &info);
457 info.type = user_manager::User::POLICY; 458 info.type = user_manager::User::POLICY;
458 SetUserWallpaperInfo(user_id, info, true /* is_persistent */); 459 SetUserWallpaperInfo(user_id, info, true /* is_persistent */);
459 } 460 }
460 461
461 void WallpaperManagerBase::OnPolicyCleared(const std::string& policy, 462 void WallpaperManagerBase::OnPolicyCleared(const std::string& policy,
462 const std::string& user_id) { 463 const user_manager::UserID& user_id) {
463 WallpaperInfo info; 464 WallpaperInfo info;
464 GetUserWallpaperInfo(user_id, &info); 465 GetUserWallpaperInfo(user_id, &info);
465 info.type = user_manager::User::DEFAULT; 466 info.type = user_manager::User::DEFAULT;
466 SetUserWallpaperInfo(user_id, info, true /* is_persistent */); 467 SetUserWallpaperInfo(user_id, info, true /* is_persistent */);
467 SetDefaultWallpaperNow(user_id); 468 SetDefaultWallpaperNow(user_id);
468 } 469 }
469 470
470 // static 471 // static
471 base::FilePath WallpaperManagerBase::GetCustomWallpaperPath( 472 base::FilePath WallpaperManagerBase::GetCustomWallpaperPath(
472 const char* sub_dir, 473 const char* sub_dir,
473 const std::string& user_id_hash, 474 const std::string& user_id_hash,
474 const std::string& file) { 475 const std::string& file) {
475 base::FilePath custom_wallpaper_path = GetCustomWallpaperDir(sub_dir); 476 base::FilePath custom_wallpaper_path = GetCustomWallpaperDir(sub_dir);
476 return custom_wallpaper_path.Append(user_id_hash).Append(file); 477 return custom_wallpaper_path.Append(user_id_hash).Append(file);
477 } 478 }
478 479
479 WallpaperManagerBase::WallpaperManagerBase() 480 WallpaperManagerBase::WallpaperManagerBase()
480 : loaded_wallpapers_for_test_(0), 481 : loaded_wallpapers_for_test_(0),
481 command_line_for_testing_(NULL), 482 command_line_for_testing_(NULL),
483 last_selected_user_(std::string(), std::string()),
482 should_cache_wallpaper_(false), 484 should_cache_wallpaper_(false),
483 weak_factory_(this) { 485 weak_factory_(this) {
484 SetDefaultWallpaperPathsFromCommandLine( 486 SetDefaultWallpaperPathsFromCommandLine(
485 base::CommandLine::ForCurrentProcess()); 487 base::CommandLine::ForCurrentProcess());
486 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken( 488 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken(
487 kWallpaperSequenceTokenName); 489 kWallpaperSequenceTokenName);
488 task_runner_ = 490 task_runner_ =
489 BrowserThread::GetBlockingPool() 491 BrowserThread::GetBlockingPool()
490 ->GetSequencedTaskRunnerWithShutdownBehavior( 492 ->GetSequencedTaskRunnerWithShutdownBehavior(
491 sequence_token_, base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 493 sequence_token_, base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
492 } 494 }
493 495
494 WallpaperManagerBase::~WallpaperManagerBase() { 496 WallpaperManagerBase::~WallpaperManagerBase() {
495 // TODO(bshe): Lifetime of WallpaperManagerBase needs more consideration. 497 // TODO(bshe): Lifetime of WallpaperManagerBase needs more consideration.
496 // http://crbug.com/171694 498 // http://crbug.com/171694
497 weak_factory_.InvalidateWeakPtrs(); 499 weak_factory_.InvalidateWeakPtrs();
498 } 500 }
499 501
500 void WallpaperManagerBase::SetPolicyControlledWallpaper( 502 void WallpaperManagerBase::SetPolicyControlledWallpaper(
501 const std::string& user_id, 503 const user_manager::UserID& user_id,
502 const user_manager::UserImage& user_image) { 504 const user_manager::UserImage& user_image) {
503 const user_manager::User* user = 505 const user_manager::User* user =
504 user_manager::UserManager::Get()->FindUser(user_id); 506 user_manager::UserManager::Get()->FindUser(user_id);
505 if (!user) { 507 if (!user) {
506 NOTREACHED() << "Unknown user."; 508 NOTREACHED() << "Unknown user.";
507 return; 509 return;
508 } 510 }
509 511
510 if (user->username_hash().empty()) { 512 if (user->username_hash().empty()) {
511 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( 513 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername(
512 user_id, 514 user_id,
513 base::Bind(&WallpaperManagerBase::SetCustomWallpaperOnSanitizedUsername, 515 base::Bind(&WallpaperManagerBase::SetCustomWallpaperOnSanitizedUsername,
514 weak_factory_.GetWeakPtr(), user_id, user_image.image(), 516 weak_factory_.GetWeakPtr(), user_id, user_image.image(),
515 true /* update wallpaper */)); 517 true /* update wallpaper */));
516 } else { 518 } else {
517 SetCustomWallpaper(user_id, user->username_hash(), "policy-controlled.jpeg", 519 SetCustomWallpaper(user_id, user->username_hash(), "policy-controlled.jpeg",
518 WALLPAPER_LAYOUT_CENTER_CROPPED, 520 WALLPAPER_LAYOUT_CENTER_CROPPED,
519 user_manager::User::POLICY, user_image.image(), 521 user_manager::User::POLICY, user_image.image(),
520 true /* update wallpaper */); 522 true /* update wallpaper */);
521 } 523 }
522 } 524 }
523 525
524 void WallpaperManagerBase::SetCustomWallpaperOnSanitizedUsername( 526 void WallpaperManagerBase::SetCustomWallpaperOnSanitizedUsername(
525 const std::string& user_id, 527 const user_manager::UserID& user_id,
526 const gfx::ImageSkia& image, 528 const gfx::ImageSkia& image,
527 bool update_wallpaper, 529 bool update_wallpaper,
528 bool cryptohome_success, 530 bool cryptohome_success,
529 const std::string& user_id_hash) { 531 const std::string& user_id_hash) {
530 if (!cryptohome_success) 532 if (!cryptohome_success)
531 return; 533 return;
532 SetCustomWallpaper(user_id, user_id_hash, "policy-controlled.jpeg", 534 SetCustomWallpaper(user_id, user_id_hash, "policy-controlled.jpeg",
533 WALLPAPER_LAYOUT_CENTER_CROPPED, 535 WALLPAPER_LAYOUT_CENTER_CROPPED,
534 user_manager::User::POLICY, image, update_wallpaper); 536 user_manager::User::POLICY, image, update_wallpaper);
535 } 537 }
(...skipping 28 matching lines...) Expand all
564 ResizeAndSaveWallpaper(*image, small_wallpaper_path, layout, 566 ResizeAndSaveWallpaper(*image, small_wallpaper_path, layout,
565 kSmallWallpaperMaxWidth, kSmallWallpaperMaxHeight, 567 kSmallWallpaperMaxWidth, kSmallWallpaperMaxHeight,
566 NULL); 568 NULL);
567 ResizeAndSaveWallpaper(*image, large_wallpaper_path, layout, 569 ResizeAndSaveWallpaper(*image, large_wallpaper_path, layout,
568 kLargeWallpaperMaxWidth, kLargeWallpaperMaxHeight, 570 kLargeWallpaperMaxWidth, kLargeWallpaperMaxHeight,
569 NULL); 571 NULL);
570 } 572 }
571 573
572 // static 574 // static
573 void WallpaperManagerBase::MoveCustomWallpapersOnWorker( 575 void WallpaperManagerBase::MoveCustomWallpapersOnWorker(
574 const std::string& user_id, 576 const user_manager::UserID& user_id,
575 const std::string& user_id_hash, 577 const std::string& user_id_hash,
576 base::WeakPtr<WallpaperManagerBase> weak_ptr) { 578 base::WeakPtr<WallpaperManagerBase> weak_ptr) {
577 if (MoveCustomWallpaperDirectory(kOriginalWallpaperSubDir, user_id, 579 if (MoveCustomWallpaperDirectory(kOriginalWallpaperSubDir, user_id,
578 user_id_hash)) { 580 user_id_hash)) {
579 // Consider success if the original wallpaper is moved to the new directory. 581 // Consider success if the original wallpaper is moved to the new directory.
580 // Original wallpaper is the fallback if the correct resolution wallpaper 582 // Original wallpaper is the fallback if the correct resolution wallpaper
581 // can not be found. 583 // can not be found.
582 BrowserThread::PostTask( 584 BrowserThread::PostTask(
583 BrowserThread::UI, FROM_HERE, 585 BrowserThread::UI, FROM_HERE,
584 base::Bind(&WallpaperManagerBase::MoveCustomWallpapersSuccess, weak_ptr, 586 base::Bind(&WallpaperManagerBase::MoveCustomWallpapersSuccess, weak_ptr,
585 user_id, user_id_hash)); 587 user_id, user_id_hash));
586 } 588 }
587 MoveCustomWallpaperDirectory(kLargeWallpaperSubDir, user_id, user_id_hash); 589 MoveCustomWallpaperDirectory(kLargeWallpaperSubDir, user_id, user_id_hash);
588 MoveCustomWallpaperDirectory(kSmallWallpaperSubDir, user_id, user_id_hash); 590 MoveCustomWallpaperDirectory(kSmallWallpaperSubDir, user_id, user_id_hash);
589 MoveCustomWallpaperDirectory(kThumbnailWallpaperSubDir, user_id, 591 MoveCustomWallpaperDirectory(kThumbnailWallpaperSubDir, user_id,
590 user_id_hash); 592 user_id_hash);
591 } 593 }
592 594
593 // static 595 // static
594 void WallpaperManagerBase::GetCustomWallpaperInternal( 596 void WallpaperManagerBase::GetCustomWallpaperInternal(
595 const std::string& user_id, 597 const user_manager::UserID& user_id,
596 const WallpaperInfo& info, 598 const WallpaperInfo& info,
597 const base::FilePath& wallpaper_path, 599 const base::FilePath& wallpaper_path,
598 bool update_wallpaper, 600 bool update_wallpaper,
599 MovableOnDestroyCallbackHolder on_finish, 601 MovableOnDestroyCallbackHolder on_finish,
600 base::WeakPtr<WallpaperManagerBase> weak_ptr) { 602 base::WeakPtr<WallpaperManagerBase> weak_ptr) {
601 base::FilePath valid_path = wallpaper_path; 603 base::FilePath valid_path = wallpaper_path;
602 if (!base::PathExists(wallpaper_path)) { 604 if (!base::PathExists(wallpaper_path)) {
603 // Falls back on original file if the correct resolution file does not 605 // Falls back on original file if the correct resolution file does not
604 // exist. This may happen when the original custom wallpaper is small or 606 // exist. This may happen when the original custom wallpaper is small or
605 // browser shutdown before resized wallpaper saved. 607 // browser shutdown before resized wallpaper saved.
606 valid_path = GetCustomWallpaperDir(kOriginalWallpaperSubDir); 608 valid_path = GetCustomWallpaperDir(kOriginalWallpaperSubDir);
607 valid_path = valid_path.Append(info.location); 609 valid_path = valid_path.Append(info.location);
608 } 610 }
609 611
610 if (!base::PathExists(valid_path)) { 612 if (!base::PathExists(valid_path)) {
611 // Falls back to custom wallpaper that uses email as part of its file path. 613 // Falls back to custom wallpaper that uses email as part of its file path.
612 // Note that email is used instead of user_id_hash here. 614 // Note that email is used instead of user_id_hash here.
613 valid_path = GetCustomWallpaperPath(kOriginalWallpaperSubDir, user_id, 615 valid_path = GetCustomWallpaperPath(kOriginalWallpaperSubDir, user_id.GetUse rEmail() /* FIXME! */,
614 info.location); 616 info.location);
615 } 617 }
616 618
617 if (!base::PathExists(valid_path)) { 619 if (!base::PathExists(valid_path)) {
618 LOG(ERROR) << "Failed to load previously selected custom wallpaper. " 620 LOG(ERROR) << "Failed to load previously selected custom wallpaper. "
619 << "Fallback to default wallpaper"; 621 << "Fallback to default wallpaper";
620 BrowserThread::PostTask( 622 BrowserThread::PostTask(
621 BrowserThread::UI, FROM_HERE, 623 BrowserThread::UI, FROM_HERE,
622 base::Bind(&WallpaperManagerBase::DoSetDefaultWallpaper, weak_ptr, 624 base::Bind(&WallpaperManagerBase::DoSetDefaultWallpaper, weak_ptr,
623 user_id, base::Passed(on_finish.Pass()))); 625 user_id, base::Passed(on_finish.Pass())));
624 } else { 626 } else {
625 BrowserThread::PostTask( 627 BrowserThread::PostTask(
626 BrowserThread::UI, FROM_HERE, 628 BrowserThread::UI, FROM_HERE,
627 base::Bind(&WallpaperManagerBase::StartLoad, weak_ptr, user_id, info, 629 base::Bind(&WallpaperManagerBase::StartLoad, weak_ptr, user_id, info,
628 update_wallpaper, valid_path, 630 update_wallpaper, valid_path,
629 base::Passed(on_finish.Pass()))); 631 base::Passed(on_finish.Pass())));
630 } 632 }
631 } 633 }
632 634
633 void WallpaperManagerBase::InitInitialUserWallpaper(const std::string& user_id, 635 void WallpaperManagerBase::InitInitialUserWallpaper(const user_manager::UserID& user_id,
634 bool is_persistent) { 636 bool is_persistent) {
635 current_user_wallpaper_info_.location = ""; 637 current_user_wallpaper_info_.location = "";
636 current_user_wallpaper_info_.layout = WALLPAPER_LAYOUT_CENTER_CROPPED; 638 current_user_wallpaper_info_.layout = WALLPAPER_LAYOUT_CENTER_CROPPED;
637 current_user_wallpaper_info_.type = user_manager::User::DEFAULT; 639 current_user_wallpaper_info_.type = user_manager::User::DEFAULT;
638 current_user_wallpaper_info_.date = base::Time::Now().LocalMidnight(); 640 current_user_wallpaper_info_.date = base::Time::Now().LocalMidnight();
639 641
640 WallpaperInfo info = current_user_wallpaper_info_; 642 WallpaperInfo info = current_user_wallpaper_info_;
641 SetUserWallpaperInfo(user_id, info, is_persistent); 643 SetUserWallpaperInfo(user_id, info, is_persistent);
642 } 644 }
643 645
644 void WallpaperManagerBase::SetUserWallpaperDelayed(const std::string& user_id) { 646 void WallpaperManagerBase::SetUserWallpaperDelayed(const user_manager::UserID& u ser_id) {
645 ScheduleSetUserWallpaper(user_id, true); 647 ScheduleSetUserWallpaper(user_id, true);
646 } 648 }
647 649
648 void WallpaperManagerBase::SetUserWallpaperNow(const std::string& user_id) { 650 void WallpaperManagerBase::SetUserWallpaperNow(const user_manager::UserID& user_ id) {
649 ScheduleSetUserWallpaper(user_id, false); 651 ScheduleSetUserWallpaper(user_id, false);
650 } 652 }
651 653
652 void WallpaperManagerBase::UpdateWallpaper(bool clear_cache) { 654 void WallpaperManagerBase::UpdateWallpaper(bool clear_cache) {
653 FOR_EACH_OBSERVER(Observer, observers_, OnUpdateWallpaperForTesting()); 655 FOR_EACH_OBSERVER(Observer, observers_, OnUpdateWallpaperForTesting());
654 if (clear_cache) 656 if (clear_cache)
655 wallpaper_cache_.clear(); 657 wallpaper_cache_.clear();
656 // For GAIA login flow, the last_selected_user_ may not be set before user 658 // For GAIA login flow, the last_selected_user_ may not be set before user
657 // login. If UpdateWallpaper is called at GAIA login screen, no wallpaper will 659 // login. If UpdateWallpaper is called at GAIA login screen, no wallpaper will
658 // be set. It could result a black screen on external monitors. 660 // be set. It could result a black screen on external monitors.
659 // See http://crbug.com/265689 for detail. 661 // See http://crbug.com/265689 for detail.
660 if (last_selected_user_.empty()) { 662 if (last_selected_user_.empty()) {
661 SetDefaultWallpaperNow(chromeos::login::kSignInUser); 663 SetDefaultWallpaperNow(chromeos::login::GetSignInUserID());
662 return; 664 return;
663 } 665 }
664 SetUserWallpaperNow(last_selected_user_); 666 SetUserWallpaperNow(last_selected_user_);
665 } 667 }
666 668
667 void WallpaperManagerBase::AddObserver( 669 void WallpaperManagerBase::AddObserver(
668 WallpaperManagerBase::Observer* observer) { 670 WallpaperManagerBase::Observer* observer) {
669 observers_.AddObserver(observer); 671 observers_.AddObserver(observer);
670 } 672 }
671 673
672 void WallpaperManagerBase::RemoveObserver( 674 void WallpaperManagerBase::RemoveObserver(
673 WallpaperManagerBase::Observer* observer) { 675 WallpaperManagerBase::Observer* observer) {
674 observers_.RemoveObserver(observer); 676 observers_.RemoveObserver(observer);
675 } 677 }
676 678
677 void WallpaperManagerBase::NotifyAnimationFinished() { 679 void WallpaperManagerBase::NotifyAnimationFinished() {
678 FOR_EACH_OBSERVER(Observer, observers_, 680 FOR_EACH_OBSERVER(Observer, observers_,
679 OnWallpaperAnimationFinished(last_selected_user_)); 681 OnWallpaperAnimationFinished(last_selected_user_));
680 } 682 }
681 683
682 // WallpaperManager, protected: ----------------------------------------------- 684 // WallpaperManager, protected: -----------------------------------------------
683 685
684 bool WallpaperManagerBase::GetWallpaperFromCache(const std::string& user_id, 686 bool WallpaperManagerBase::GetWallpaperFromCache(const user_manager::UserID& use r_id,
685 gfx::ImageSkia* image) { 687 gfx::ImageSkia* image) {
686 DCHECK_CURRENTLY_ON(BrowserThread::UI); 688 DCHECK_CURRENTLY_ON(BrowserThread::UI);
687 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id); 689 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id);
688 if (it != wallpaper_cache_.end() && !(*it).second.second.isNull()) { 690 if (it != wallpaper_cache_.end() && !(*it).second.second.isNull()) {
689 *image = (*it).second.second; 691 *image = (*it).second.second;
690 return true; 692 return true;
691 } 693 }
692 return false; 694 return false;
693 } 695 }
694 696
695 bool WallpaperManagerBase::GetPathFromCache(const std::string& user_id, 697 bool WallpaperManagerBase::GetPathFromCache(const user_manager::UserID& user_id,
696 base::FilePath* path) { 698 base::FilePath* path) {
697 DCHECK_CURRENTLY_ON(BrowserThread::UI); 699 DCHECK_CURRENTLY_ON(BrowserThread::UI);
698 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id); 700 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id);
699 if (it != wallpaper_cache_.end()) { 701 if (it != wallpaper_cache_.end()) {
700 *path = (*it).second.first; 702 *path = (*it).second.first;
701 return true; 703 return true;
702 } 704 }
703 return false; 705 return false;
704 } 706 }
705 707
706 int WallpaperManagerBase::loaded_wallpapers_for_test() const { 708 int WallpaperManagerBase::loaded_wallpapers_for_test() const {
707 return loaded_wallpapers_for_test_; 709 return loaded_wallpapers_for_test_;
708 } 710 }
709 711
710 void WallpaperManagerBase::CacheUsersWallpapers() { 712 void WallpaperManagerBase::CacheUsersWallpapers() {
711 // TODO(dpolukhin): crbug.com/408734. 713 // TODO(dpolukhin): crbug.com/408734.
712 DCHECK_CURRENTLY_ON(BrowserThread::UI); 714 DCHECK_CURRENTLY_ON(BrowserThread::UI);
713 user_manager::UserList users = user_manager::UserManager::Get()->GetUsers(); 715 user_manager::UserList users = user_manager::UserManager::Get()->GetUsers();
714 716
715 if (!users.empty()) { 717 if (!users.empty()) {
716 user_manager::UserList::const_iterator it = users.begin(); 718 user_manager::UserList::const_iterator it = users.begin();
717 // Skip the wallpaper of first user in the list. It should have been cached. 719 // Skip the wallpaper of first user in the list. It should have been cached.
718 it++; 720 it++;
719 for (int cached = 0; it != users.end() && cached < kMaxWallpapersToCache; 721 for (int cached = 0; it != users.end() && cached < kMaxWallpapersToCache;
720 ++it, ++cached) { 722 ++it, ++cached) {
721 std::string user_id = (*it)->email(); 723 CacheUserWallpaper((*it)->GetUserID());
722 CacheUserWallpaper(user_id);
723 } 724 }
724 } 725 }
725 } 726 }
726 727
727 void WallpaperManagerBase::CacheUserWallpaper(const std::string& user_id) { 728 void WallpaperManagerBase::CacheUserWallpaper(const user_manager::UserID& user_i d) {
728 CustomWallpaperMap::iterator it = wallpaper_cache_.find(user_id); 729 CustomWallpaperMap::iterator it = wallpaper_cache_.find(user_id);
729 if (it != wallpaper_cache_.end() && !it->second.second.isNull()) 730 if (it != wallpaper_cache_.end() && !it->second.second.isNull())
730 return; 731 return;
731 WallpaperInfo info; 732 WallpaperInfo info;
732 if (GetUserWallpaperInfo(user_id, &info)) { 733 if (GetUserWallpaperInfo(user_id, &info)) {
733 if (info.location.empty()) 734 if (info.location.empty())
734 return; 735 return;
735 736
736 base::FilePath wallpaper_dir; 737 base::FilePath wallpaper_dir;
737 base::FilePath wallpaper_path; 738 base::FilePath wallpaper_path;
(...skipping 12 matching lines...) Expand all
750 base::Passed(MovableOnDestroyCallbackHolder()), 751 base::Passed(MovableOnDestroyCallbackHolder()),
751 weak_factory_.GetWeakPtr())); 752 weak_factory_.GetWeakPtr()));
752 return; 753 return;
753 } 754 }
754 LoadWallpaper(user_id, info, false /* do not update wallpaper */, 755 LoadWallpaper(user_id, info, false /* do not update wallpaper */,
755 MovableOnDestroyCallbackHolder().Pass()); 756 MovableOnDestroyCallbackHolder().Pass());
756 } 757 }
757 } 758 }
758 759
759 void WallpaperManagerBase::DeleteUserWallpapers( 760 void WallpaperManagerBase::DeleteUserWallpapers(
760 const std::string& user_id, 761 const user_manager::UserID& user_id,
761 const std::string& path_to_file) { 762 const std::string& path_to_file) {
762 std::vector<base::FilePath> file_to_remove; 763 std::vector<base::FilePath> file_to_remove;
763 // Remove small user wallpaper. 764 // Remove small user wallpaper.
764 base::FilePath wallpaper_path = GetCustomWallpaperDir(kSmallWallpaperSubDir); 765 base::FilePath wallpaper_path = GetCustomWallpaperDir(kSmallWallpaperSubDir);
765 // Remove old directory if exists 766 // Remove old directory if exists
766 file_to_remove.push_back(wallpaper_path.Append(user_id)); 767 file_to_remove.push_back(wallpaper_path.Append(user_id.GetUserEmail()));
767 wallpaper_path = wallpaper_path.Append(path_to_file).DirName(); 768 wallpaper_path = wallpaper_path.Append(path_to_file).DirName();
768 file_to_remove.push_back(wallpaper_path); 769 file_to_remove.push_back(wallpaper_path);
769 770
770 // Remove large user wallpaper. 771 // Remove large user wallpaper.
771 wallpaper_path = GetCustomWallpaperDir(kLargeWallpaperSubDir); 772 wallpaper_path = GetCustomWallpaperDir(kLargeWallpaperSubDir);
772 file_to_remove.push_back(wallpaper_path.Append(user_id)); 773 file_to_remove.push_back(wallpaper_path.Append(user_id.GetUserEmail()));
773 wallpaper_path = wallpaper_path.Append(path_to_file); 774 wallpaper_path = wallpaper_path.Append(path_to_file);
774 file_to_remove.push_back(wallpaper_path); 775 file_to_remove.push_back(wallpaper_path);
775 776
776 // Remove user wallpaper thumbnail. 777 // Remove user wallpaper thumbnail.
777 wallpaper_path = GetCustomWallpaperDir(kThumbnailWallpaperSubDir); 778 wallpaper_path = GetCustomWallpaperDir(kThumbnailWallpaperSubDir);
778 file_to_remove.push_back(wallpaper_path.Append(user_id)); 779 file_to_remove.push_back(wallpaper_path.Append(user_id.GetUserEmail()));
779 wallpaper_path = wallpaper_path.Append(path_to_file); 780 wallpaper_path = wallpaper_path.Append(path_to_file);
780 file_to_remove.push_back(wallpaper_path); 781 file_to_remove.push_back(wallpaper_path);
781 782
782 // Remove original user wallpaper. 783 // Remove original user wallpaper.
783 wallpaper_path = GetCustomWallpaperDir(kOriginalWallpaperSubDir); 784 wallpaper_path = GetCustomWallpaperDir(kOriginalWallpaperSubDir);
784 file_to_remove.push_back(wallpaper_path.Append(user_id)); 785 file_to_remove.push_back(wallpaper_path.Append(user_id.GetUserEmail()));
785 wallpaper_path = wallpaper_path.Append(path_to_file); 786 wallpaper_path = wallpaper_path.Append(path_to_file);
786 file_to_remove.push_back(wallpaper_path); 787 file_to_remove.push_back(wallpaper_path);
787 788
788 base::WorkerPool::PostTask( 789 base::WorkerPool::PostTask(
789 FROM_HERE, base::Bind(&DeleteWallpaperInList, file_to_remove), false); 790 FROM_HERE, base::Bind(&DeleteWallpaperInList, file_to_remove), false);
790 } 791 }
791 792
792 void WallpaperManagerBase::SetCommandLineForTesting( 793 void WallpaperManagerBase::SetCommandLineForTesting(
793 base::CommandLine* command_line) { 794 base::CommandLine* command_line) {
794 command_line_for_testing_ = command_line; 795 command_line_for_testing_ = command_line;
795 SetDefaultWallpaperPathsFromCommandLine(command_line); 796 SetDefaultWallpaperPathsFromCommandLine(command_line);
796 } 797 }
797 798
798 base::CommandLine* WallpaperManagerBase::GetCommandLine() { 799 base::CommandLine* WallpaperManagerBase::GetCommandLine() {
799 base::CommandLine* command_line = 800 base::CommandLine* command_line =
800 command_line_for_testing_ ? command_line_for_testing_ 801 command_line_for_testing_ ? command_line_for_testing_
801 : base::CommandLine::ForCurrentProcess(); 802 : base::CommandLine::ForCurrentProcess();
802 return command_line; 803 return command_line;
803 } 804 }
804 805
805 void WallpaperManagerBase::LoadWallpaper( 806 void WallpaperManagerBase::LoadWallpaper(
806 const std::string& user_id, 807 const user_manager::UserID& user_id,
807 const WallpaperInfo& info, 808 const WallpaperInfo& info,
808 bool update_wallpaper, 809 bool update_wallpaper,
809 MovableOnDestroyCallbackHolder on_finish) { 810 MovableOnDestroyCallbackHolder on_finish) {
810 base::FilePath wallpaper_dir; 811 base::FilePath wallpaper_dir;
811 base::FilePath wallpaper_path; 812 base::FilePath wallpaper_path;
812 813
813 // Do a sanity check that file path information is not empty. 814 // Do a sanity check that file path information is not empty.
814 if (info.type == user_manager::User::ONLINE || 815 if (info.type == user_manager::User::ONLINE ||
815 info.type == user_manager::User::DEFAULT) { 816 info.type == user_manager::User::DEFAULT) {
816 if (info.location.empty()) { 817 if (info.location.empty()) {
817 if (base::SysInfo::IsRunningOnChromeOS()) { 818 if (base::SysInfo::IsRunningOnChromeOS()) {
818 NOTREACHED() << "User wallpaper info appears to be broken: " << user_id; 819 NOTREACHED() << "User wallpaper info appears to be broken: " << user_id. GetUserEmail();
819 } else { 820 } else {
820 // Filename might be empty on debug configurations when stub users 821 // Filename might be empty on debug configurations when stub users
821 // were created directly in Local State (for testing). Ignore such 822 // were created directly in Local State (for testing). Ignore such
822 // errors i.e. allowsuch type of debug configurations on the desktop. 823 // errors i.e. allowsuch type of debug configurations on the desktop.
823 LOG(WARNING) << "User wallpaper info is empty: " << user_id; 824 LOG(WARNING) << "User wallpaper info is empty: " << user_id.GetUserEmail ();
824 825
825 // |on_finish| callback will get called on destruction. 826 // |on_finish| callback will get called on destruction.
826 return; 827 return;
827 } 828 }
828 } 829 }
829 } 830 }
830 831
831 if (info.type == user_manager::User::ONLINE) { 832 if (info.type == user_manager::User::ONLINE) {
832 std::string file_name = GURL(info.location).ExtractFileName(); 833 std::string file_name = GURL(info.location).ExtractFileName();
833 WallpaperResolution resolution = GetAppropriateResolution(); 834 WallpaperResolution resolution = GetAppropriateResolution();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 on_finish.Pass()); 869 on_finish.Pass());
869 } else { 870 } else {
870 // In unexpected cases, revert to default wallpaper to fail safely. See 871 // In unexpected cases, revert to default wallpaper to fail safely. See
871 // crosbug.com/38429. 872 // crosbug.com/38429.
872 LOG(ERROR) << "Wallpaper reverts to default unexpected."; 873 LOG(ERROR) << "Wallpaper reverts to default unexpected.";
873 DoSetDefaultWallpaper(user_id, on_finish.Pass()); 874 DoSetDefaultWallpaper(user_id, on_finish.Pass());
874 } 875 }
875 } 876 }
876 877
877 void WallpaperManagerBase::MoveCustomWallpapersSuccess( 878 void WallpaperManagerBase::MoveCustomWallpapersSuccess(
878 const std::string& user_id, 879 const user_manager::UserID& user_id,
879 const std::string& user_id_hash) { 880 const std::string& user_id_hash) {
880 WallpaperInfo info; 881 WallpaperInfo info;
881 GetUserWallpaperInfo(user_id, &info); 882 GetUserWallpaperInfo(user_id, &info);
882 if (info.type == user_manager::User::CUSTOMIZED) { 883 if (info.type == user_manager::User::CUSTOMIZED) {
883 // New file field should include user id hash in addition to file name. 884 // New file field should include user id hash in addition to file name.
884 // This is needed because at login screen, user id hash is not available. 885 // This is needed because at login screen, user id hash is not available.
885 info.location = base::FilePath(user_id_hash).Append(info.location).value(); 886 info.location = base::FilePath(user_id_hash).Append(info.location).value();
886 bool is_persistent = 887 bool is_persistent =
887 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( 888 !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral(
888 user_id); 889 user_id);
889 SetUserWallpaperInfo(user_id, info, is_persistent); 890 SetUserWallpaperInfo(user_id, info, is_persistent);
890 } 891 }
891 } 892 }
892 893
893 void WallpaperManagerBase::MoveLoggedInUserCustomWallpaper() { 894 void WallpaperManagerBase::MoveLoggedInUserCustomWallpaper() {
894 const user_manager::User* logged_in_user = 895 const user_manager::User* logged_in_user =
895 user_manager::UserManager::Get()->GetLoggedInUser(); 896 user_manager::UserManager::Get()->GetLoggedInUser();
896 if (logged_in_user) { 897 if (logged_in_user) {
897 task_runner_->PostTask( 898 task_runner_->PostTask(
898 FROM_HERE, 899 FROM_HERE,
899 base::Bind(&WallpaperManagerBase::MoveCustomWallpapersOnWorker, 900 base::Bind(&WallpaperManagerBase::MoveCustomWallpapersOnWorker,
900 logged_in_user->email(), logged_in_user->username_hash(), 901 logged_in_user->GetUserID(), logged_in_user->username_hash(),
901 weak_factory_.GetWeakPtr())); 902 weak_factory_.GetWeakPtr()));
902 } 903 }
903 } 904 }
904 905
905 void WallpaperManagerBase::SaveLastLoadTime(const base::TimeDelta elapsed) { 906 void WallpaperManagerBase::SaveLastLoadTime(const base::TimeDelta elapsed) {
906 while (last_load_times_.size() >= kLastLoadsStatsMsMaxSize) 907 while (last_load_times_.size() >= kLastLoadsStatsMsMaxSize)
907 last_load_times_.pop_front(); 908 last_load_times_.pop_front();
908 909
909 if (elapsed > base::TimeDelta::FromMicroseconds(0)) { 910 if (elapsed > base::TimeDelta::FromMicroseconds(0)) {
910 last_load_times_.push_back(elapsed); 911 last_load_times_.push_back(elapsed);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { 1056 void WallpaperManagerBase::CreateSolidDefaultWallpaper() {
1056 loaded_wallpapers_for_test_++; 1057 loaded_wallpapers_for_test_++;
1057 SkBitmap bitmap; 1058 SkBitmap bitmap;
1058 bitmap.allocN32Pixels(1, 1); 1059 bitmap.allocN32Pixels(1, 1);
1059 bitmap.eraseColor(kDefaultWallpaperColor); 1060 bitmap.eraseColor(kDefaultWallpaperColor);
1060 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); 1061 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
1061 default_wallpaper_image_.reset(new user_manager::UserImage(image)); 1062 default_wallpaper_image_.reset(new user_manager::UserImage(image));
1062 } 1063 }
1063 1064
1064 } // namespace wallpaper 1065 } // namespace wallpaper
OLDNEW
« components/user_manager/user_id.cc ('K') | « components/wallpaper/wallpaper_manager_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698