| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extensions/wallpaper_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 dict->SetBoolean("isOEMDefaultWallpaper", IsOEMDefaultWallpaper()); | 278 dict->SetBoolean("isOEMDefaultWallpaper", IsOEMDefaultWallpaper()); |
| 279 return true; | 279 return true; |
| 280 } | 280 } |
| 281 | 281 |
| 282 WallpaperPrivateSetWallpaperIfExistsFunction:: | 282 WallpaperPrivateSetWallpaperIfExistsFunction:: |
| 283 WallpaperPrivateSetWallpaperIfExistsFunction() {} | 283 WallpaperPrivateSetWallpaperIfExistsFunction() {} |
| 284 | 284 |
| 285 WallpaperPrivateSetWallpaperIfExistsFunction:: | 285 WallpaperPrivateSetWallpaperIfExistsFunction:: |
| 286 ~WallpaperPrivateSetWallpaperIfExistsFunction() {} | 286 ~WallpaperPrivateSetWallpaperIfExistsFunction() {} |
| 287 | 287 |
| 288 bool WallpaperPrivateSetWallpaperIfExistsFunction::RunImpl() { | 288 bool WallpaperPrivateSetWallpaperIfExistsFunction::RunAsync() { |
| 289 params = set_wallpaper_if_exists::Params::Create(*args_); | 289 params = set_wallpaper_if_exists::Params::Create(*args_); |
| 290 EXTENSION_FUNCTION_VALIDATE(params); | 290 EXTENSION_FUNCTION_VALIDATE(params); |
| 291 | 291 |
| 292 user_id_ = chromeos::UserManager::Get()->GetActiveUser()->email(); | 292 user_id_ = chromeos::UserManager::Get()->GetActiveUser()->email(); |
| 293 | 293 |
| 294 base::FilePath wallpaper_path; | 294 base::FilePath wallpaper_path; |
| 295 base::FilePath fallback_path; | 295 base::FilePath fallback_path; |
| 296 chromeos::WallpaperManager::WallpaperResolution resolution = | 296 chromeos::WallpaperManager::WallpaperResolution resolution = |
| 297 chromeos::WallpaperManager::GetAppropriateResolution(); | 297 chromeos::WallpaperManager::GetAppropriateResolution(); |
| 298 | 298 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 SetResult(base::Value::CreateBooleanValue(false)); | 381 SetResult(base::Value::CreateBooleanValue(false)); |
| 382 OnFailure(error); | 382 OnFailure(error); |
| 383 }; | 383 }; |
| 384 | 384 |
| 385 WallpaperPrivateSetWallpaperFunction::WallpaperPrivateSetWallpaperFunction() { | 385 WallpaperPrivateSetWallpaperFunction::WallpaperPrivateSetWallpaperFunction() { |
| 386 } | 386 } |
| 387 | 387 |
| 388 WallpaperPrivateSetWallpaperFunction::~WallpaperPrivateSetWallpaperFunction() { | 388 WallpaperPrivateSetWallpaperFunction::~WallpaperPrivateSetWallpaperFunction() { |
| 389 } | 389 } |
| 390 | 390 |
| 391 bool WallpaperPrivateSetWallpaperFunction::RunImpl() { | 391 bool WallpaperPrivateSetWallpaperFunction::RunAsync() { |
| 392 params = set_wallpaper::Params::Create(*args_); | 392 params = set_wallpaper::Params::Create(*args_); |
| 393 EXTENSION_FUNCTION_VALIDATE(params); | 393 EXTENSION_FUNCTION_VALIDATE(params); |
| 394 | 394 |
| 395 // Gets email address while at UI thread. | 395 // Gets email address while at UI thread. |
| 396 user_id_ = chromeos::UserManager::Get()->GetActiveUser()->email(); | 396 user_id_ = chromeos::UserManager::Get()->GetActiveUser()->email(); |
| 397 | 397 |
| 398 StartDecode(params->wallpaper); | 398 StartDecode(params->wallpaper); |
| 399 | 399 |
| 400 return true; | 400 return true; |
| 401 } | 401 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent); | 482 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent); |
| 483 SendResponse(true); | 483 SendResponse(true); |
| 484 } | 484 } |
| 485 | 485 |
| 486 WallpaperPrivateResetWallpaperFunction:: | 486 WallpaperPrivateResetWallpaperFunction:: |
| 487 WallpaperPrivateResetWallpaperFunction() {} | 487 WallpaperPrivateResetWallpaperFunction() {} |
| 488 | 488 |
| 489 WallpaperPrivateResetWallpaperFunction:: | 489 WallpaperPrivateResetWallpaperFunction:: |
| 490 ~WallpaperPrivateResetWallpaperFunction() {} | 490 ~WallpaperPrivateResetWallpaperFunction() {} |
| 491 | 491 |
| 492 bool WallpaperPrivateResetWallpaperFunction::RunImpl() { | 492 bool WallpaperPrivateResetWallpaperFunction::RunAsync() { |
| 493 chromeos::WallpaperManager* wallpaper_manager = | 493 chromeos::WallpaperManager* wallpaper_manager = |
| 494 chromeos::WallpaperManager::Get(); | 494 chromeos::WallpaperManager::Get(); |
| 495 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | 495 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
| 496 | 496 |
| 497 std::string user_id = user_manager->GetActiveUser()->email(); | 497 std::string user_id = user_manager->GetActiveUser()->email(); |
| 498 wallpaper_manager->RemoveUserWallpaperInfo(user_id); | 498 wallpaper_manager->RemoveUserWallpaperInfo(user_id); |
| 499 | 499 |
| 500 chromeos::WallpaperInfo info = { | 500 chromeos::WallpaperInfo info = { |
| 501 "", | 501 "", |
| 502 ash::WALLPAPER_LAYOUT_CENTER, | 502 ash::WALLPAPER_LAYOUT_CENTER, |
| 503 chromeos::User::DEFAULT, | 503 chromeos::User::DEFAULT, |
| 504 base::Time::Now().LocalMidnight() | 504 base::Time::Now().LocalMidnight() |
| 505 }; | 505 }; |
| 506 bool is_persistent = | 506 bool is_persistent = |
| 507 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); | 507 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 508 wallpaper_manager->SetUserWallpaperInfo(user_id, info, is_persistent); | 508 wallpaper_manager->SetUserWallpaperInfo(user_id, info, is_persistent); |
| 509 | 509 |
| 510 wallpaper_manager->SetDefaultWallpaperNow(user_id); | 510 wallpaper_manager->SetDefaultWallpaperNow(user_id); |
| 511 return true; | 511 return true; |
| 512 } | 512 } |
| 513 | 513 |
| 514 WallpaperPrivateSetCustomWallpaperFunction:: | 514 WallpaperPrivateSetCustomWallpaperFunction:: |
| 515 WallpaperPrivateSetCustomWallpaperFunction() {} | 515 WallpaperPrivateSetCustomWallpaperFunction() {} |
| 516 | 516 |
| 517 WallpaperPrivateSetCustomWallpaperFunction:: | 517 WallpaperPrivateSetCustomWallpaperFunction:: |
| 518 ~WallpaperPrivateSetCustomWallpaperFunction() {} | 518 ~WallpaperPrivateSetCustomWallpaperFunction() {} |
| 519 | 519 |
| 520 bool WallpaperPrivateSetCustomWallpaperFunction::RunImpl() { | 520 bool WallpaperPrivateSetCustomWallpaperFunction::RunAsync() { |
| 521 params = set_custom_wallpaper::Params::Create(*args_); | 521 params = set_custom_wallpaper::Params::Create(*args_); |
| 522 EXTENSION_FUNCTION_VALIDATE(params); | 522 EXTENSION_FUNCTION_VALIDATE(params); |
| 523 | 523 |
| 524 // Gets email address and username hash while at UI thread. | 524 // Gets email address and username hash while at UI thread. |
| 525 user_id_ = chromeos::UserManager::Get()->GetActiveUser()->email(); | 525 user_id_ = chromeos::UserManager::Get()->GetActiveUser()->email(); |
| 526 user_id_hash_ = | 526 user_id_hash_ = |
| 527 chromeos::UserManager::Get()->GetActiveUser()->username_hash(); | 527 chromeos::UserManager::Get()->GetActiveUser()->username_hash(); |
| 528 | 528 |
| 529 StartDecode(params->wallpaper); | 529 StartDecode(params->wallpaper); |
| 530 | 530 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 SetResult(result); | 602 SetResult(result); |
| 603 SendResponse(true); | 603 SendResponse(true); |
| 604 } | 604 } |
| 605 | 605 |
| 606 WallpaperPrivateSetCustomWallpaperLayoutFunction:: | 606 WallpaperPrivateSetCustomWallpaperLayoutFunction:: |
| 607 WallpaperPrivateSetCustomWallpaperLayoutFunction() {} | 607 WallpaperPrivateSetCustomWallpaperLayoutFunction() {} |
| 608 | 608 |
| 609 WallpaperPrivateSetCustomWallpaperLayoutFunction:: | 609 WallpaperPrivateSetCustomWallpaperLayoutFunction:: |
| 610 ~WallpaperPrivateSetCustomWallpaperLayoutFunction() {} | 610 ~WallpaperPrivateSetCustomWallpaperLayoutFunction() {} |
| 611 | 611 |
| 612 bool WallpaperPrivateSetCustomWallpaperLayoutFunction::RunImpl() { | 612 bool WallpaperPrivateSetCustomWallpaperLayoutFunction::RunAsync() { |
| 613 scoped_ptr<set_custom_wallpaper_layout::Params> params( | 613 scoped_ptr<set_custom_wallpaper_layout::Params> params( |
| 614 set_custom_wallpaper_layout::Params::Create(*args_)); | 614 set_custom_wallpaper_layout::Params::Create(*args_)); |
| 615 EXTENSION_FUNCTION_VALIDATE(params); | 615 EXTENSION_FUNCTION_VALIDATE(params); |
| 616 | 616 |
| 617 chromeos::WallpaperManager* wallpaper_manager = | 617 chromeos::WallpaperManager* wallpaper_manager = |
| 618 chromeos::WallpaperManager::Get(); | 618 chromeos::WallpaperManager::Get(); |
| 619 chromeos::WallpaperInfo info; | 619 chromeos::WallpaperInfo info; |
| 620 wallpaper_manager->GetLoggedInUserWallpaperInfo(&info); | 620 wallpaper_manager->GetLoggedInUserWallpaperInfo(&info); |
| 621 if (info.type != chromeos::User::CUSTOMIZED) { | 621 if (info.type != chromeos::User::CUSTOMIZED) { |
| 622 SetError("Only custom wallpaper can change layout."); | 622 SetError("Only custom wallpaper can change layout."); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 638 } | 638 } |
| 639 | 639 |
| 640 WallpaperPrivateMinimizeInactiveWindowsFunction:: | 640 WallpaperPrivateMinimizeInactiveWindowsFunction:: |
| 641 WallpaperPrivateMinimizeInactiveWindowsFunction() { | 641 WallpaperPrivateMinimizeInactiveWindowsFunction() { |
| 642 } | 642 } |
| 643 | 643 |
| 644 WallpaperPrivateMinimizeInactiveWindowsFunction:: | 644 WallpaperPrivateMinimizeInactiveWindowsFunction:: |
| 645 ~WallpaperPrivateMinimizeInactiveWindowsFunction() { | 645 ~WallpaperPrivateMinimizeInactiveWindowsFunction() { |
| 646 } | 646 } |
| 647 | 647 |
| 648 bool WallpaperPrivateMinimizeInactiveWindowsFunction::RunImpl() { | 648 bool WallpaperPrivateMinimizeInactiveWindowsFunction::RunAsync() { |
| 649 WindowStateManager::MinimizeInactiveWindows( | 649 WindowStateManager::MinimizeInactiveWindows( |
| 650 chromeos::UserManager::Get()->GetActiveUser()->username_hash()); | 650 chromeos::UserManager::Get()->GetActiveUser()->username_hash()); |
| 651 return true; | 651 return true; |
| 652 } | 652 } |
| 653 | 653 |
| 654 WallpaperPrivateRestoreMinimizedWindowsFunction:: | 654 WallpaperPrivateRestoreMinimizedWindowsFunction:: |
| 655 WallpaperPrivateRestoreMinimizedWindowsFunction() { | 655 WallpaperPrivateRestoreMinimizedWindowsFunction() { |
| 656 } | 656 } |
| 657 | 657 |
| 658 WallpaperPrivateRestoreMinimizedWindowsFunction:: | 658 WallpaperPrivateRestoreMinimizedWindowsFunction:: |
| 659 ~WallpaperPrivateRestoreMinimizedWindowsFunction() { | 659 ~WallpaperPrivateRestoreMinimizedWindowsFunction() { |
| 660 } | 660 } |
| 661 | 661 |
| 662 bool WallpaperPrivateRestoreMinimizedWindowsFunction::RunImpl() { | 662 bool WallpaperPrivateRestoreMinimizedWindowsFunction::RunAsync() { |
| 663 WindowStateManager::RestoreWindows( | 663 WindowStateManager::RestoreWindows( |
| 664 chromeos::UserManager::Get()->GetActiveUser()->username_hash()); | 664 chromeos::UserManager::Get()->GetActiveUser()->username_hash()); |
| 665 return true; | 665 return true; |
| 666 } | 666 } |
| 667 | 667 |
| 668 WallpaperPrivateGetThumbnailFunction::WallpaperPrivateGetThumbnailFunction() { | 668 WallpaperPrivateGetThumbnailFunction::WallpaperPrivateGetThumbnailFunction() { |
| 669 } | 669 } |
| 670 | 670 |
| 671 WallpaperPrivateGetThumbnailFunction::~WallpaperPrivateGetThumbnailFunction() { | 671 WallpaperPrivateGetThumbnailFunction::~WallpaperPrivateGetThumbnailFunction() { |
| 672 } | 672 } |
| 673 | 673 |
| 674 bool WallpaperPrivateGetThumbnailFunction::RunImpl() { | 674 bool WallpaperPrivateGetThumbnailFunction::RunAsync() { |
| 675 scoped_ptr<get_thumbnail::Params> params( | 675 scoped_ptr<get_thumbnail::Params> params( |
| 676 get_thumbnail::Params::Create(*args_)); | 676 get_thumbnail::Params::Create(*args_)); |
| 677 EXTENSION_FUNCTION_VALIDATE(params); | 677 EXTENSION_FUNCTION_VALIDATE(params); |
| 678 | 678 |
| 679 base::FilePath thumbnail_path; | 679 base::FilePath thumbnail_path; |
| 680 std::string email = chromeos::UserManager::Get()->GetActiveUser()->email(); | 680 std::string email = chromeos::UserManager::Get()->GetActiveUser()->email(); |
| 681 if (params->source == get_thumbnail::Params::SOURCE_ONLINE) { | 681 if (params->source == get_thumbnail::Params::SOURCE_ONLINE) { |
| 682 std::string file_name = GURL(params->url_or_file).ExtractFileName(); | 682 std::string file_name = GURL(params->url_or_file).ExtractFileName(); |
| 683 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, | 683 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, |
| 684 &thumbnail_path)); | 684 &thumbnail_path)); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 path.BaseName().value())); | 751 path.BaseName().value())); |
| 752 } | 752 } |
| 753 } | 753 } |
| 754 | 754 |
| 755 WallpaperPrivateSaveThumbnailFunction::WallpaperPrivateSaveThumbnailFunction() { | 755 WallpaperPrivateSaveThumbnailFunction::WallpaperPrivateSaveThumbnailFunction() { |
| 756 } | 756 } |
| 757 | 757 |
| 758 WallpaperPrivateSaveThumbnailFunction:: | 758 WallpaperPrivateSaveThumbnailFunction:: |
| 759 ~WallpaperPrivateSaveThumbnailFunction() {} | 759 ~WallpaperPrivateSaveThumbnailFunction() {} |
| 760 | 760 |
| 761 bool WallpaperPrivateSaveThumbnailFunction::RunImpl() { | 761 bool WallpaperPrivateSaveThumbnailFunction::RunAsync() { |
| 762 scoped_ptr<save_thumbnail::Params> params( | 762 scoped_ptr<save_thumbnail::Params> params( |
| 763 save_thumbnail::Params::Create(*args_)); | 763 save_thumbnail::Params::Create(*args_)); |
| 764 EXTENSION_FUNCTION_VALIDATE(params); | 764 EXTENSION_FUNCTION_VALIDATE(params); |
| 765 | 765 |
| 766 sequence_token_ = BrowserThread::GetBlockingPool()-> | 766 sequence_token_ = BrowserThread::GetBlockingPool()-> |
| 767 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); | 767 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); |
| 768 scoped_refptr<base::SequencedTaskRunner> task_runner = | 768 scoped_refptr<base::SequencedTaskRunner> task_runner = |
| 769 BrowserThread::GetBlockingPool()-> | 769 BrowserThread::GetBlockingPool()-> |
| 770 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, | 770 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, |
| 771 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 771 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 } | 804 } |
| 805 | 805 |
| 806 WallpaperPrivateGetOfflineWallpaperListFunction:: | 806 WallpaperPrivateGetOfflineWallpaperListFunction:: |
| 807 WallpaperPrivateGetOfflineWallpaperListFunction() { | 807 WallpaperPrivateGetOfflineWallpaperListFunction() { |
| 808 } | 808 } |
| 809 | 809 |
| 810 WallpaperPrivateGetOfflineWallpaperListFunction:: | 810 WallpaperPrivateGetOfflineWallpaperListFunction:: |
| 811 ~WallpaperPrivateGetOfflineWallpaperListFunction() { | 811 ~WallpaperPrivateGetOfflineWallpaperListFunction() { |
| 812 } | 812 } |
| 813 | 813 |
| 814 bool WallpaperPrivateGetOfflineWallpaperListFunction::RunImpl() { | 814 bool WallpaperPrivateGetOfflineWallpaperListFunction::RunAsync() { |
| 815 sequence_token_ = BrowserThread::GetBlockingPool()-> | 815 sequence_token_ = BrowserThread::GetBlockingPool()-> |
| 816 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); | 816 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); |
| 817 scoped_refptr<base::SequencedTaskRunner> task_runner = | 817 scoped_refptr<base::SequencedTaskRunner> task_runner = |
| 818 BrowserThread::GetBlockingPool()-> | 818 BrowserThread::GetBlockingPool()-> |
| 819 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, | 819 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, |
| 820 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 820 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 821 | 821 |
| 822 task_runner->PostTask(FROM_HERE, | 822 task_runner->PostTask(FROM_HERE, |
| 823 base::Bind(&WallpaperPrivateGetOfflineWallpaperListFunction::GetList, | 823 base::Bind(&WallpaperPrivateGetOfflineWallpaperListFunction::GetList, |
| 824 this)); | 824 this)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 848 this, file_list)); | 848 this, file_list)); |
| 849 } | 849 } |
| 850 | 850 |
| 851 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 851 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
| 852 const std::vector<std::string>& file_list) { | 852 const std::vector<std::string>& file_list) { |
| 853 base::ListValue* results = new base::ListValue(); | 853 base::ListValue* results = new base::ListValue(); |
| 854 results->AppendStrings(file_list); | 854 results->AppendStrings(file_list); |
| 855 SetResult(results); | 855 SetResult(results); |
| 856 SendResponse(true); | 856 SendResponse(true); |
| 857 } | 857 } |
| OLD | NEW |