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

Side by Side Diff: chrome/browser/chromeos/extensions/wallpaper_private_api.cc

Issue 2017113002: [Extensions] DCHECK that ExtensionFunctions respond (and only once) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 (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 <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 std::unique_ptr<set_custom_wallpaper_layout::Params> params( 718 std::unique_ptr<set_custom_wallpaper_layout::Params> params(
719 set_custom_wallpaper_layout::Params::Create(*args_)); 719 set_custom_wallpaper_layout::Params::Create(*args_));
720 EXTENSION_FUNCTION_VALIDATE(params); 720 EXTENSION_FUNCTION_VALIDATE(params);
721 721
722 chromeos::WallpaperManager* wallpaper_manager = 722 chromeos::WallpaperManager* wallpaper_manager =
723 chromeos::WallpaperManager::Get(); 723 chromeos::WallpaperManager::Get();
724 wallpaper::WallpaperInfo info; 724 wallpaper::WallpaperInfo info;
725 wallpaper_manager->GetLoggedInUserWallpaperInfo(&info); 725 wallpaper_manager->GetLoggedInUserWallpaperInfo(&info);
726 if (info.type != user_manager::User::CUSTOMIZED) { 726 if (info.type != user_manager::User::CUSTOMIZED) {
727 SetError("Only custom wallpaper can change layout."); 727 SetError("Only custom wallpaper can change layout.");
728 SendResponse(false);
729 return false; 728 return false;
730 } 729 }
731 info.layout = wallpaper_api_util::GetLayoutEnum( 730 info.layout = wallpaper_api_util::GetLayoutEnum(
732 wallpaper_base::ToString(params->layout)); 731 wallpaper_base::ToString(params->layout));
733 wallpaper_api_util::RecordCustomWallpaperLayout(info.layout); 732 wallpaper_api_util::RecordCustomWallpaperLayout(info.layout);
734 733
735 const AccountId& account_id = 734 const AccountId& account_id =
736 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); 735 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId();
737 bool is_persistent = !user_manager::UserManager::Get() 736 bool is_persistent = !user_manager::UserManager::Get()
738 ->IsCurrentUserNonCryptohomeDataEphemeral(); 737 ->IsCurrentUserNonCryptohomeDataEphemeral();
739 wallpaper_manager->SetUserWallpaperInfo(account_id, info, is_persistent); 738 wallpaper_manager->SetUserWallpaperInfo(account_id, info, is_persistent);
740 wallpaper_manager->UpdateWallpaper(false /* clear_cache */); 739 wallpaper_manager->UpdateWallpaper(false /* clear_cache */);
741 SendResponse(true); 740 SendResponse(true);
742 741
743 return true; 742 return true;
744 } 743 }
745 744
746 WallpaperPrivateMinimizeInactiveWindowsFunction:: 745 WallpaperPrivateMinimizeInactiveWindowsFunction::
747 WallpaperPrivateMinimizeInactiveWindowsFunction() { 746 WallpaperPrivateMinimizeInactiveWindowsFunction() {
748 } 747 }
749 748
750 WallpaperPrivateMinimizeInactiveWindowsFunction:: 749 WallpaperPrivateMinimizeInactiveWindowsFunction::
751 ~WallpaperPrivateMinimizeInactiveWindowsFunction() { 750 ~WallpaperPrivateMinimizeInactiveWindowsFunction() {
752 } 751 }
753 752
754 bool WallpaperPrivateMinimizeInactiveWindowsFunction::RunAsync() { 753 ExtensionFunction::ResponseAction
754 WallpaperPrivateMinimizeInactiveWindowsFunction::Run() {
755 WindowStateManager::MinimizeInactiveWindows( 755 WindowStateManager::MinimizeInactiveWindows(
756 user_manager::UserManager::Get()->GetActiveUser()->username_hash()); 756 user_manager::UserManager::Get()->GetActiveUser()->username_hash());
757 return true; 757 return RespondNow(NoArguments());
758 } 758 }
759 759
760 WallpaperPrivateRestoreMinimizedWindowsFunction:: 760 WallpaperPrivateRestoreMinimizedWindowsFunction::
761 WallpaperPrivateRestoreMinimizedWindowsFunction() { 761 WallpaperPrivateRestoreMinimizedWindowsFunction() {
762 } 762 }
763 763
764 WallpaperPrivateRestoreMinimizedWindowsFunction:: 764 WallpaperPrivateRestoreMinimizedWindowsFunction::
765 ~WallpaperPrivateRestoreMinimizedWindowsFunction() { 765 ~WallpaperPrivateRestoreMinimizedWindowsFunction() {
766 } 766 }
767 767
768 bool WallpaperPrivateRestoreMinimizedWindowsFunction::RunAsync() { 768 ExtensionFunction::ResponseAction
769 WallpaperPrivateRestoreMinimizedWindowsFunction::Run() {
769 WindowStateManager::RestoreWindows( 770 WindowStateManager::RestoreWindows(
770 user_manager::UserManager::Get()->GetActiveUser()->username_hash()); 771 user_manager::UserManager::Get()->GetActiveUser()->username_hash());
771 return true; 772 return RespondNow(NoArguments());
772 } 773 }
773 774
774 WallpaperPrivateGetThumbnailFunction::WallpaperPrivateGetThumbnailFunction() { 775 WallpaperPrivateGetThumbnailFunction::WallpaperPrivateGetThumbnailFunction() {
775 } 776 }
776 777
777 WallpaperPrivateGetThumbnailFunction::~WallpaperPrivateGetThumbnailFunction() { 778 WallpaperPrivateGetThumbnailFunction::~WallpaperPrivateGetThumbnailFunction() {
778 } 779 }
779 780
780 bool WallpaperPrivateGetThumbnailFunction::RunAsync() { 781 bool WallpaperPrivateGetThumbnailFunction::RunAsync() {
781 std::unique_ptr<get_thumbnail::Params> params( 782 std::unique_ptr<get_thumbnail::Params> params(
782 get_thumbnail::Params::Create(*args_)); 783 get_thumbnail::Params::Create(*args_));
783 EXTENSION_FUNCTION_VALIDATE(params); 784 EXTENSION_FUNCTION_VALIDATE(params);
784 785
785 base::FilePath thumbnail_path; 786 base::FilePath thumbnail_path;
786 if (params->source == wallpaper_private::WALLPAPER_SOURCE_ONLINE) { 787 if (params->source == wallpaper_private::WALLPAPER_SOURCE_ONLINE) {
787 std::string file_name = GURL(params->url_or_file).ExtractFileName(); 788 std::string file_name = GURL(params->url_or_file).ExtractFileName();
788 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, 789 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS,
789 &thumbnail_path)); 790 &thumbnail_path));
790 thumbnail_path = thumbnail_path.Append(file_name); 791 thumbnail_path = thumbnail_path.Append(file_name);
791 } else { 792 } else {
792 if (!IsOEMDefaultWallpaper()) { 793 if (!IsOEMDefaultWallpaper()) {
793 SetError("No OEM wallpaper."); 794 SetError("No OEM wallpaper.");
794 SendResponse(false);
795 return false; 795 return false;
796 } 796 }
797 797
798 // TODO(bshe): Small resolution wallpaper is used here as wallpaper 798 // TODO(bshe): Small resolution wallpaper is used here as wallpaper
799 // thumbnail. We should either resize it or include a wallpaper thumbnail in 799 // thumbnail. We should either resize it or include a wallpaper thumbnail in
800 // addition to large and small wallpaper resolutions. 800 // addition to large and small wallpaper resolutions.
801 thumbnail_path = base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( 801 thumbnail_path = base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
802 chromeos::switches::kDefaultWallpaperSmall); 802 chromeos::switches::kDefaultWallpaperSmall);
803 } 803 }
804 804
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 bool WallpaperPrivateRecordWallpaperUMAFunction::RunSync() { 965 bool WallpaperPrivateRecordWallpaperUMAFunction::RunSync() {
966 std::unique_ptr<record_wallpaper_uma::Params> params( 966 std::unique_ptr<record_wallpaper_uma::Params> params(
967 record_wallpaper_uma::Params::Create(*args_)); 967 record_wallpaper_uma::Params::Create(*args_));
968 EXTENSION_FUNCTION_VALIDATE(params); 968 EXTENSION_FUNCTION_VALIDATE(params);
969 969
970 user_manager::User::WallpaperType source = getWallpaperType(params->source); 970 user_manager::User::WallpaperType source = getWallpaperType(params->source);
971 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Source", source, 971 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Source", source,
972 user_manager::User::WALLPAPER_TYPE_COUNT); 972 user_manager::User::WALLPAPER_TYPE_COUNT);
973 return true; 973 return true;
974 } 974 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698