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 <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 std::vector<std::string> file_list; | 912 std::vector<std::string> file_list; |
913 base::FilePath wallpaper_dir; | 913 base::FilePath wallpaper_dir; |
914 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, &wallpaper_dir)); | 914 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, &wallpaper_dir)); |
915 if (base::DirectoryExists(wallpaper_dir)) { | 915 if (base::DirectoryExists(wallpaper_dir)) { |
916 base::FileEnumerator files(wallpaper_dir, false, | 916 base::FileEnumerator files(wallpaper_dir, false, |
917 base::FileEnumerator::FILES); | 917 base::FileEnumerator::FILES); |
918 for (base::FilePath current = files.Next(); !current.empty(); | 918 for (base::FilePath current = files.Next(); !current.empty(); |
919 current = files.Next()) { | 919 current = files.Next()) { |
920 std::string file_name = current.BaseName().RemoveExtension().value(); | 920 std::string file_name = current.BaseName().RemoveExtension().value(); |
921 // Do not add file name of small resolution wallpaper to the list. | 921 // Do not add file name of small resolution wallpaper to the list. |
922 if (!EndsWith(file_name, wallpaper::kSmallWallpaperSuffix, true)) | 922 if (!base::EndsWith(file_name, wallpaper::kSmallWallpaperSuffix, true)) |
923 file_list.push_back(current.BaseName().value()); | 923 file_list.push_back(current.BaseName().value()); |
924 } | 924 } |
925 } | 925 } |
926 BrowserThread::PostTask( | 926 BrowserThread::PostTask( |
927 BrowserThread::UI, FROM_HERE, | 927 BrowserThread::UI, FROM_HERE, |
928 base::Bind(&WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete, | 928 base::Bind(&WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete, |
929 this, file_list)); | 929 this, file_list)); |
930 } | 930 } |
931 | 931 |
932 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 932 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
933 const std::vector<std::string>& file_list) { | 933 const std::vector<std::string>& file_list) { |
934 base::ListValue* results = new base::ListValue(); | 934 base::ListValue* results = new base::ListValue(); |
935 results->AppendStrings(file_list); | 935 results->AppendStrings(file_list); |
936 SetResult(results); | 936 SetResult(results); |
937 SendResponse(true); | 937 SendResponse(true); |
938 } | 938 } |
OLD | NEW |