OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/desktop_background/desktop_background_controller.h" | |
10 #include "ash/desktop_background/desktop_background_resources.h" | |
11 #include "ash/shell.h" | 9 #include "ash/shell.h" |
12 #include "base/command_line.h" | 10 #include "base/command_line.h" |
13 #include "base/logging.h" | 11 #include "base/logging.h" |
14 #include "base/file_path.h" | 12 #include "base/file_path.h" |
15 #include "base/file_util.h" | 13 #include "base/file_util.h" |
16 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
17 #include "base/path_service.h" | 15 #include "base/path_service.h" |
18 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
19 #include "base/string_util.h" | 17 #include "base/string_util.h" |
20 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
(...skipping 28 matching lines...) Expand all Loading... |
49 | 47 |
50 // A dictionary pref that maps usernames to file paths to their wallpapers. | 48 // A dictionary pref that maps usernames to file paths to their wallpapers. |
51 // Deprecated. Will remove this const char after done migration. | 49 // Deprecated. Will remove this const char after done migration. |
52 const char kUserWallpapers[] = "UserWallpapers"; | 50 const char kUserWallpapers[] = "UserWallpapers"; |
53 | 51 |
54 const int kThumbnailWidth = 128; | 52 const int kThumbnailWidth = 128; |
55 const int kThumbnailHeight = 80; | 53 const int kThumbnailHeight = 80; |
56 | 54 |
57 const int kCacheWallpaperDelayMs = 500; | 55 const int kCacheWallpaperDelayMs = 500; |
58 | 56 |
59 // Default wallpaper index used in OOBE (first boot). | |
60 // Defined here because Chromium default index differs. | |
61 // Also see ash::WallpaperInfo kDefaultWallpapers in | |
62 // desktop_background_resources.cc | |
63 #if defined(GOOGLE_CHROME_BUILD) | |
64 const int kDefaultOOBEWallpaperIndex = 1; // IDR_AURA_WALLPAPERS_2_LANDSCAPE8 | |
65 #else | |
66 const int kDefaultOOBEWallpaperIndex = 0; // IDR_AURA_WALLPAPERS_5_GRADIENT5 | |
67 #endif | |
68 | |
69 // A dictionary pref that maps usernames to wallpaper properties. | 57 // A dictionary pref that maps usernames to wallpaper properties. |
70 const char kUserWallpapersProperties[] = "UserWallpapersProperties"; | 58 const char kUserWallpapersProperties[] = "UserWallpapersProperties"; |
71 | 59 |
72 // Names of nodes with info about wallpaper in |kUserWallpapersProperties| | 60 // Names of nodes with info about wallpaper in |kUserWallpapersProperties| |
73 // dictionary. | 61 // dictionary. |
74 const char kNewWallpaperDateNodeName[] = "date"; | 62 const char kNewWallpaperDateNodeName[] = "date"; |
75 const char kNewWallpaperLayoutNodeName[] = "layout"; | 63 const char kNewWallpaperLayoutNodeName[] = "layout"; |
76 const char kNewWallpaperFileNodeName[] = "file"; | 64 const char kNewWallpaperFileNodeName[] = "file"; |
77 const char kNewWallpaperTypeNodeName[] = "type"; | 65 const char kNewWallpaperTypeNodeName[] = "type"; |
78 | 66 |
(...skipping 28 matching lines...) Expand all Loading... |
107 | 95 |
108 // static | 96 // static |
109 WallpaperManager* WallpaperManager::Get() { | 97 WallpaperManager* WallpaperManager::Get() { |
110 if (!g_wallpaper_manager) | 98 if (!g_wallpaper_manager) |
111 g_wallpaper_manager = new WallpaperManager(); | 99 g_wallpaper_manager = new WallpaperManager(); |
112 return g_wallpaper_manager; | 100 return g_wallpaper_manager; |
113 } | 101 } |
114 | 102 |
115 WallpaperManager::WallpaperManager() | 103 WallpaperManager::WallpaperManager() |
116 : loaded_wallpapers_(0), | 104 : loaded_wallpapers_(0), |
117 ALLOW_THIS_IN_INITIALIZER_LIST(current_default_wallpaper_index_( | |
118 ash::GetInvalidWallpaperIndex())), | |
119 ALLOW_THIS_IN_INITIALIZER_LIST(wallpaper_loader_( | 105 ALLOW_THIS_IN_INITIALIZER_LIST(wallpaper_loader_( |
120 new UserImageLoader(ImageDecoder::ROBUST_JPEG_CODEC))), | 106 new UserImageLoader(ImageDecoder::ROBUST_JPEG_CODEC))), |
121 should_cache_wallpaper_(false), | 107 should_cache_wallpaper_(false), |
122 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 108 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
123 RestartTimer(); | 109 RestartTimer(); |
124 registrar_.Add(this, | 110 registrar_.Add(this, |
125 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 111 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
126 content::NotificationService::AllSources()); | 112 content::NotificationService::AllSources()); |
127 registrar_.Add(this, | 113 registrar_.Add(this, |
128 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, | 114 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 223 } |
238 | 224 |
239 bool disable_new_oobe = CommandLine::ForCurrentProcess()-> | 225 bool disable_new_oobe = CommandLine::ForCurrentProcess()-> |
240 HasSwitch(switches::kDisableNewOobe); | 226 HasSwitch(switches::kDisableNewOobe); |
241 bool disable_boot_animation = CommandLine::ForCurrentProcess()-> | 227 bool disable_boot_animation = CommandLine::ForCurrentProcess()-> |
242 HasSwitch(switches::kDisableBootAnimation); | 228 HasSwitch(switches::kDisableBootAnimation); |
243 | 229 |
244 if (!user_manager->IsUserLoggedIn()) { | 230 if (!user_manager->IsUserLoggedIn()) { |
245 if (!disable_new_oobe) { | 231 if (!disable_new_oobe) { |
246 if (!WizardController::IsDeviceRegistered()) { | 232 if (!WizardController::IsDeviceRegistered()) { |
247 SetDefaultWallpaper(kDefaultOOBEWallpaperIndex); | 233 SetDefaultWallpaper(); |
248 } else { | 234 } else { |
249 bool show_users = true; | 235 bool show_users = true; |
250 bool result = CrosSettings::Get()->GetBoolean( | 236 bool result = CrosSettings::Get()->GetBoolean( |
251 kAccountsPrefShowUserNamesOnSignIn, &show_users); | 237 kAccountsPrefShowUserNamesOnSignIn, &show_users); |
252 DCHECK(result) << "Unable to fetch setting " | 238 DCHECK(result) << "Unable to fetch setting " |
253 << kAccountsPrefShowUserNamesOnSignIn; | 239 << kAccountsPrefShowUserNamesOnSignIn; |
254 const chromeos::UserList& users = user_manager->GetUsers(); | 240 const chromeos::UserList& users = user_manager->GetUsers(); |
255 if (!show_users || users.empty()) { | 241 if (!show_users || users.empty()) { |
256 // Boot into sign in form, preload default wallpaper. | 242 // Boot into sign in form, preload default wallpaper. |
257 SetDefaultWallpaper(kDefaultOOBEWallpaperIndex); | 243 SetDefaultWallpaper(); |
258 return; | 244 return; |
259 } | 245 } |
260 | 246 |
261 if (!disable_boot_animation) { | 247 if (!disable_boot_animation) { |
262 // Normal boot, load user wallpaper. | 248 // Normal boot, load user wallpaper. |
263 // If normal boot animation is disabled wallpaper would be set | 249 // If normal boot animation is disabled wallpaper would be set |
264 // asynchronously once user pods are loaded. | 250 // asynchronously once user pods are loaded. |
265 SetUserWallpaper(users[0]->email()); | 251 SetUserWallpaper(users[0]->email()); |
266 } | 252 } |
267 } | 253 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 User::WallpaperType type, | 385 User::WallpaperType type, |
400 const UserImage& wallpaper) { | 386 const UserImage& wallpaper) { |
401 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 387 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
402 | 388 |
403 std::string wallpaper_path = | 389 std::string wallpaper_path = |
404 GetOriginalWallpaperPathForUser(username).value(); | 390 GetOriginalWallpaperPathForUser(username).value(); |
405 | 391 |
406 // If decoded wallpaper is empty, we are probably failed to decode the file. | 392 // If decoded wallpaper is empty, we are probably failed to decode the file. |
407 // Use default wallpaper in this case. | 393 // Use default wallpaper in this case. |
408 if (wallpaper.image().isNull()) { | 394 if (wallpaper.image().isNull()) { |
409 SetDefaultWallpaper(ash::GetDefaultWallpaperIndex()); | 395 SetDefaultWallpaper(); |
410 return; | 396 return; |
411 } | 397 } |
412 | 398 |
413 bool is_persistent = ShouldPersistDataForUser(username); | 399 bool is_persistent = ShouldPersistDataForUser(username); |
414 | 400 |
415 wallpaper.image().EnsureRepsForSupportedScaleFactors(); | 401 wallpaper.image().EnsureRepsForSupportedScaleFactors(); |
416 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy()); | 402 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy()); |
417 | 403 |
418 WallpaperInfo wallpaper_info = { | 404 WallpaperInfo wallpaper_info = { |
419 wallpaper_path, | 405 wallpaper_path, |
(...skipping 21 matching lines...) Expand all Loading... |
441 // DUMMY as file name here. | 427 // DUMMY as file name here. |
442 WallpaperInfo info = { | 428 WallpaperInfo info = { |
443 "DUMMY", | 429 "DUMMY", |
444 layout, | 430 layout, |
445 User::CUSTOMIZED, | 431 User::CUSTOMIZED, |
446 base::Time::Now().LocalMidnight() | 432 base::Time::Now().LocalMidnight() |
447 }; | 433 }; |
448 SetUserWallpaperInfo(username, info, is_persistent); | 434 SetUserWallpaperInfo(username, info, is_persistent); |
449 } | 435 } |
450 | 436 |
451 void WallpaperManager::SetDefaultWallpaper(int index) { | 437 void WallpaperManager::SetDefaultWallpaper() { |
| 438 ash::DesktopBackgroundController* controller = |
| 439 ash::Shell::GetInstance()->desktop_background_controller(); |
| 440 ash::WallpaperResolution resolution = controller->GetAppropriateResolution(); |
| 441 ash::WallpaperInfo info; |
| 442 if (UserManager::Get()->IsLoggedInAsGuest()) { |
| 443 info = (resolution == ash::LARGE) ? ash::kGuestLargeWallpaper : |
| 444 ash::kGuestSmallWallpaper; |
| 445 } else { |
| 446 info = (resolution == ash::LARGE) ? ash::kDefaultLargeWallpaper : |
| 447 ash::kDefaultSmallWallpaper; |
| 448 } |
| 449 |
452 // Prevents loading of the same wallpaper as the currently loading/loaded one. | 450 // Prevents loading of the same wallpaper as the currently loading/loaded one. |
453 if (current_default_wallpaper_index_ == index) | 451 if (controller->GetWallpaperIDR() == info.idr) |
454 return; | 452 return; |
455 current_default_wallpaper_index_ = index; | 453 |
456 current_wallpaper_path_ = FilePath(""); | 454 current_wallpaper_path_ = FilePath(""); |
457 loaded_wallpapers_++; | 455 loaded_wallpapers_++; |
458 ash::Shell::GetInstance()->desktop_background_controller()-> | 456 controller->SetDefaultWallpaper(info); |
459 SetDefaultWallpaper(index); | |
460 } | 457 } |
461 | 458 |
462 void WallpaperManager::SetInitialUserWallpaper(const std::string& username, | 459 void WallpaperManager::SetInitialUserWallpaper(const std::string& username, |
463 bool is_persistent) { | 460 bool is_persistent) { |
464 current_user_wallpaper_info_.file = ""; | 461 current_user_wallpaper_info_.file = ""; |
465 current_user_wallpaper_info_.layout = ash::CENTER_CROPPED; | 462 current_user_wallpaper_info_.layout = ash::CENTER_CROPPED; |
466 current_user_wallpaper_info_.type = User::DEFAULT; | 463 current_user_wallpaper_info_.type = User::DEFAULT; |
467 current_user_wallpaper_info_.date = base::Time::Now().LocalMidnight(); | 464 current_user_wallpaper_info_.date = base::Time::Now().LocalMidnight(); |
468 | 465 |
469 WallpaperInfo info = current_user_wallpaper_info_; | 466 WallpaperInfo info = current_user_wallpaper_info_; |
470 SetUserWallpaperInfo(username, info, is_persistent); | 467 SetUserWallpaperInfo(username, info, is_persistent); |
471 | 468 |
472 // Some browser tests do not have shell instance. And it is not necessary to | 469 // Some browser tests do not have shell instance. And it is not necessary to |
473 // create a wallpaper for these tests. Add HasInstance check to prevent tests | 470 // create a wallpaper for these tests. Add HasInstance check to prevent tests |
474 // crash and speed up the tests by avoid loading wallpaper. | 471 // crash and speed up the tests by avoid loading wallpaper. |
475 if (ash::Shell::HasInstance()) { | 472 if (ash::Shell::HasInstance()) |
476 if (username == kGuestUser) | 473 SetDefaultWallpaper(); |
477 SetDefaultWallpaper(ash::GetGuestWallpaperIndex()); | |
478 else | |
479 SetDefaultWallpaper(ash::GetDefaultWallpaperIndex()); | |
480 } | |
481 } | 474 } |
482 | 475 |
483 void WallpaperManager::SetUserWallpaperInfo(const std::string& username, | 476 void WallpaperManager::SetUserWallpaperInfo(const std::string& username, |
484 const WallpaperInfo& info, | 477 const WallpaperInfo& info, |
485 bool is_persistent) { | 478 bool is_persistent) { |
486 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 479 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
487 current_user_wallpaper_info_ = info; | 480 current_user_wallpaper_info_ = info; |
488 if (!is_persistent) | 481 if (!is_persistent) |
489 return; | 482 return; |
490 | 483 |
(...skipping 11 matching lines...) Expand all Loading... |
502 } | 495 } |
503 | 496 |
504 void WallpaperManager::SetLastSelectedUser( | 497 void WallpaperManager::SetLastSelectedUser( |
505 const std::string& last_selected_user) { | 498 const std::string& last_selected_user) { |
506 last_selected_user_ = last_selected_user; | 499 last_selected_user_ = last_selected_user; |
507 } | 500 } |
508 | 501 |
509 void WallpaperManager::SetUserWallpaper(const std::string& email) { | 502 void WallpaperManager::SetUserWallpaper(const std::string& email) { |
510 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 503 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
511 if (email == kGuestUser) { | 504 if (email == kGuestUser) { |
512 SetDefaultWallpaper(ash::GetGuestWallpaperIndex()); | 505 SetDefaultWallpaper(); |
513 return; | 506 return; |
514 } | 507 } |
515 | 508 |
516 if (!UserManager::Get()->IsKnownUser(email)) | 509 if (!UserManager::Get()->IsKnownUser(email)) |
517 return; | 510 return; |
518 | 511 |
519 SetLastSelectedUser(email); | 512 SetLastSelectedUser(email); |
520 | 513 |
521 WallpaperInfo info; | 514 WallpaperInfo info; |
522 | 515 |
523 if (GetUserWallpaperInfo(email, &info)) { | 516 if (GetUserWallpaperInfo(email, &info)) { |
524 gfx::ImageSkia user_wallpaper; | 517 gfx::ImageSkia user_wallpaper; |
525 if (GetWallpaperFromCache(email, &user_wallpaper)) { | 518 if (GetWallpaperFromCache(email, &user_wallpaper)) { |
526 ash::Shell::GetInstance()->desktop_background_controller()-> | 519 ash::Shell::GetInstance()->desktop_background_controller()-> |
527 SetCustomWallpaper(user_wallpaper, info.layout); | 520 SetCustomWallpaper(user_wallpaper, info.layout); |
528 } else { | 521 } else { |
529 if (info.type == User::CUSTOMIZED) { | 522 if (info.type == User::CUSTOMIZED) { |
530 ash::WallpaperResolution resolution = ash::Shell::GetInstance()-> | 523 ash::WallpaperResolution resolution = ash::Shell::GetInstance()-> |
531 desktop_background_controller()->GetAppropriateResolution(); | 524 desktop_background_controller()->GetAppropriateResolution(); |
532 bool is_small = (resolution == ash::SMALL); | 525 bool is_small = (resolution == ash::SMALL); |
533 FilePath wallpaper_path = GetWallpaperPathForUser(email, is_small); | 526 FilePath wallpaper_path = GetWallpaperPathForUser(email, is_small); |
534 if (current_wallpaper_path_ == wallpaper_path) | 527 if (current_wallpaper_path_ == wallpaper_path) |
535 return; | 528 return; |
536 current_wallpaper_path_ = wallpaper_path; | 529 current_wallpaper_path_ = wallpaper_path; |
537 current_default_wallpaper_index_ = ash::GetInvalidWallpaperIndex(); | |
538 loaded_wallpapers_++; | 530 loaded_wallpapers_++; |
539 | 531 |
540 BrowserThread::PostTask( | 532 BrowserThread::PostTask( |
541 BrowserThread::FILE, FROM_HERE, | 533 BrowserThread::FILE, FROM_HERE, |
542 base::Bind(&WallpaperManager::GetCustomWallpaperInternal, | 534 base::Bind(&WallpaperManager::GetCustomWallpaperInternal, |
543 base::Unretained(this), email, info, wallpaper_path, | 535 base::Unretained(this), email, info, wallpaper_path, |
544 true /* update wallpaper */)); | 536 true /* update wallpaper */)); |
545 return; | 537 return; |
546 } | 538 } |
547 | 539 |
548 if (info.file.empty()) { | 540 if (info.file.empty()) { |
549 // Uses default built-in wallpaper when file is empty. Eventually, we | 541 // Uses default built-in wallpaper when file is empty. Eventually, we |
550 // will only ship one built-in wallpaper in ChromeOS image. | 542 // will only ship one built-in wallpaper in ChromeOS image. |
551 SetDefaultWallpaper(ash::GetDefaultWallpaperIndex()); | 543 SetDefaultWallpaper(); |
552 return; | 544 return; |
553 } | 545 } |
554 | 546 |
555 // Load downloaded ONLINE or converted DEFAULT wallpapers. | 547 // Load downloaded ONLINE or converted DEFAULT wallpapers. |
556 LoadWallpaper(email, info, true /* update wallpaper */); | 548 LoadWallpaper(email, info, true /* update wallpaper */); |
557 } | 549 } |
558 } else { | 550 } else { |
559 SetInitialUserWallpaper(email, true); | 551 SetInitialUserWallpaper(email, true); |
560 } | 552 } |
561 } | 553 } |
562 | 554 |
563 void WallpaperManager::SetSigninWallpaper() { | |
564 SetDefaultWallpaper(kDefaultOOBEWallpaperIndex); | |
565 } | |
566 | |
567 void WallpaperManager::SetWallpaperFromImageSkia( | 555 void WallpaperManager::SetWallpaperFromImageSkia( |
568 const gfx::ImageSkia& wallpaper, | 556 const gfx::ImageSkia& wallpaper, |
569 ash::WallpaperLayout layout) { | 557 ash::WallpaperLayout layout) { |
570 ash::Shell::GetInstance()->desktop_background_controller()-> | 558 ash::Shell::GetInstance()->desktop_background_controller()-> |
571 SetCustomWallpaper(wallpaper, layout); | 559 SetCustomWallpaper(wallpaper, layout); |
572 } | 560 } |
573 | 561 |
574 void WallpaperManager::UpdateWallpaper() { | 562 void WallpaperManager::UpdateWallpaper() { |
575 ClearWallpaperCache(); | 563 ClearWallpaperCache(); |
576 SetUserWallpaper(last_selected_user_); | 564 SetUserWallpaper(last_selected_user_); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 // Only solid color wallpapers have stretch layout and they have only one | 680 // Only solid color wallpapers have stretch layout and they have only one |
693 // resolution. | 681 // resolution. |
694 if (info.layout != ash::STRETCH && resolution == ash::SMALL) { | 682 if (info.layout != ash::STRETCH && resolution == ash::SMALL) { |
695 file_name = FilePath(file_name).InsertBeforeExtension( | 683 file_name = FilePath(file_name).InsertBeforeExtension( |
696 kSmallWallpaperSuffix).value(); | 684 kSmallWallpaperSuffix).value(); |
697 } | 685 } |
698 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, &wallpaper_dir)); | 686 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, &wallpaper_dir)); |
699 wallpaper_path = wallpaper_dir.Append(file_name); | 687 wallpaper_path = wallpaper_dir.Append(file_name); |
700 if (current_wallpaper_path_ == wallpaper_path) | 688 if (current_wallpaper_path_ == wallpaper_path) |
701 return; | 689 return; |
702 if (update_wallpaper) { | 690 if (update_wallpaper) |
703 current_wallpaper_path_ = wallpaper_path; | 691 current_wallpaper_path_ = wallpaper_path; |
704 current_default_wallpaper_index_ = ash::GetInvalidWallpaperIndex(); | |
705 } | |
706 loaded_wallpapers_++; | 692 loaded_wallpapers_++; |
707 StartLoad(email, info, update_wallpaper, wallpaper_path); | 693 StartLoad(email, info, update_wallpaper, wallpaper_path); |
708 } else { | 694 } else { |
709 // For custom wallpapers, we have increment |loaded_wallpapers_| in | 695 // For custom wallpapers, we have increment |loaded_wallpapers_| in |
710 // SetUserWallpaper(). We should not increment it again here. | 696 // SetUserWallpaper(). We should not increment it again here. |
711 FilePath user_data_dir; | 697 FilePath user_data_dir; |
712 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 698 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
713 wallpaper_path = user_data_dir.Append(info.file); | 699 wallpaper_path = user_data_dir.Append(info.file); |
714 base::WorkerPool::PostTask( | 700 base::WorkerPool::PostTask( |
715 FROM_HERE, | 701 FROM_HERE, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 if (wallpaper.image().isNull()) { | 801 if (wallpaper.image().isNull()) { |
816 // Updates user pref to default wallpaper. | 802 // Updates user pref to default wallpaper. |
817 WallpaperInfo info = { | 803 WallpaperInfo info = { |
818 "", | 804 "", |
819 ash::CENTER_CROPPED, | 805 ash::CENTER_CROPPED, |
820 User::DEFAULT, | 806 User::DEFAULT, |
821 base::Time::Now().LocalMidnight() | 807 base::Time::Now().LocalMidnight() |
822 }; | 808 }; |
823 SetUserWallpaperInfo(email, info, true); | 809 SetUserWallpaperInfo(email, info, true); |
824 | 810 |
825 if (update_wallpaper) { | 811 if (update_wallpaper) |
826 SetDefaultWallpaper(ash::GetDefaultWallpaperIndex()); | 812 SetDefaultWallpaper(); |
827 } else { | |
828 ash::Shell::GetInstance()->desktop_background_controller()-> | |
829 CacheDefaultWallpaper(ash::GetDefaultWallpaperIndex()); | |
830 } | |
831 return; | 813 return; |
832 } | 814 } |
833 // Generate all reps before passing to another thread. | 815 // Generate all reps before passing to another thread. |
834 wallpaper.image().EnsureRepsForSupportedScaleFactors(); | 816 wallpaper.image().EnsureRepsForSupportedScaleFactors(); |
835 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy()); | 817 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy()); |
836 | 818 |
837 BrowserThread::PostTask( | 819 BrowserThread::PostTask( |
838 BrowserThread::FILE, | 820 BrowserThread::FILE, |
839 FROM_HERE, | 821 FROM_HERE, |
840 base::Bind(&WallpaperManager::CacheThumbnail, | 822 base::Bind(&WallpaperManager::CacheThumbnail, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 ash::kSmallWallpaperMaxWidth, | 873 ash::kSmallWallpaperMaxWidth, |
892 ash::kSmallWallpaperMaxHeight); | 874 ash::kSmallWallpaperMaxHeight); |
893 ResizeAndSaveWallpaper(wallpaper, large_wallpaper_path, layout, | 875 ResizeAndSaveWallpaper(wallpaper, large_wallpaper_path, layout, |
894 ash::kLargeWallpaperMaxWidth, | 876 ash::kLargeWallpaperMaxWidth, |
895 ash::kLargeWallpaperMaxHeight); | 877 ash::kLargeWallpaperMaxHeight); |
896 } | 878 } |
897 | 879 |
898 void WallpaperManager::RecordUma(User::WallpaperType type, int index) { | 880 void WallpaperManager::RecordUma(User::WallpaperType type, int index) { |
899 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", type, | 881 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", type, |
900 User::WALLPAPER_TYPE_COUNT); | 882 User::WALLPAPER_TYPE_COUNT); |
901 if (type == User::DEFAULT) { | |
902 if (index >= 0) { | |
903 // TODO(sschmitz): Remove "if" when the index for new UI is available. | |
904 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.DefaultIndex", index, | |
905 ash::GetWallpaperCount()); | |
906 } | |
907 } | |
908 } | 883 } |
909 | 884 |
910 void WallpaperManager::SaveWallpaperInternal(const FilePath& path, | 885 void WallpaperManager::SaveWallpaperInternal(const FilePath& path, |
911 const char* data, | 886 const char* data, |
912 int size) { | 887 int size) { |
913 int written_bytes = file_util::WriteFile(path, data, size); | 888 int written_bytes = file_util::WriteFile(path, data, size); |
914 DCHECK(written_bytes == size); | 889 DCHECK(written_bytes == size); |
915 } | 890 } |
916 | 891 |
917 bool WallpaperManager::ShouldPersistDataForUser(const std::string& email) { | 892 bool WallpaperManager::ShouldPersistDataForUser(const std::string& email) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 FROM_HERE, | 933 FROM_HERE, |
959 base::Bind(&WallpaperManager::StartLoad, | 934 base::Bind(&WallpaperManager::StartLoad, |
960 base::Unretained(this), | 935 base::Unretained(this), |
961 email, | 936 email, |
962 info, | 937 info, |
963 update_wallpaper, | 938 update_wallpaper, |
964 valid_path)); | 939 valid_path)); |
965 } | 940 } |
966 | 941 |
967 } // chromeos | 942 } // chromeos |
OLD | NEW |