Index: chrome/browser/chromeos/extensions/wallpaper_private_api.cc |
diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc |
index 6111c33d548a67566181c5eee76b45bc21ec2cfb..228207e55d1ff02514425381ef666394b4441b18 100644 |
--- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc |
+++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc |
@@ -27,6 +27,7 @@ |
#include "chrome/browser/extensions/event_router.h" |
#include "chrome/browser/image_decoder.h" |
#include "chrome/common/chrome_paths.h" |
+#include "chromeos/login/login_state.h" |
#include "content/public/browser/browser_thread.h" |
#include "googleurl/src/gurl.h" |
#include "grit/app_locale_settings.h" |
@@ -236,11 +237,16 @@ class WallpaperFunctionBase::WallpaperDecoder : public ImageDecoder::Delegate { |
void Start(const std::string& image_data) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- image_decoder_ = new ImageDecoder(this, image_data, |
- ImageDecoder::ROBUST_JPEG_CODEC); |
+ |
+ // This function can only be called after user login. It is fine to use |
+ // unsafe image decoder here. Before user login, a robust jpeg decoder will |
+ // be used. |
+ CHECK(chromeos::LoginState::Get()->IsUserLoggedIn()); |
+ unsafe_image_decoder_ = new ImageDecoder(this, image_data, |
+ ImageDecoder::DEFAULT_CODEC); |
scoped_refptr<base::MessageLoopProxy> task_runner = |
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
- image_decoder_->Start(task_runner); |
+ unsafe_image_decoder_->Start(task_runner); |
} |
void Cancel() { |
@@ -273,7 +279,7 @@ class WallpaperFunctionBase::WallpaperDecoder : public ImageDecoder::Delegate { |
private: |
scoped_refptr<WallpaperFunctionBase> function_; |
- scoped_refptr<ImageDecoder> image_decoder_; |
+ scoped_refptr<ImageDecoder> unsafe_image_decoder_; |
base::CancellationFlag cancel_flag_; |
DISALLOW_COPY_AND_ASSIGN(WallpaperDecoder); |
@@ -882,6 +888,8 @@ void WallpaperPrivateGetOfflineWallpaperListFunction::GetList( |
DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
sequence_token_)); |
std::vector<std::string> file_list; |
+ // TODO(bshe): This api function is only used for ONLINE wallpapers. Remove |
+ // source. |
if (source == kOnlineSource) { |
base::FilePath wallpaper_dir; |
CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, &wallpaper_dir)); |
@@ -896,22 +904,6 @@ void WallpaperPrivateGetOfflineWallpaperListFunction::GetList( |
file_list.push_back(current.BaseName().value()); |
} |
} |
- } else { |
- base::FilePath custom_thumbnails_dir = chromeos::WallpaperManager::Get()-> |
- GetCustomWallpaperPath(chromeos::kThumbnailWallpaperSubDir, email, ""); |
- if (file_util::DirectoryExists(custom_thumbnails_dir)) { |
- base::FileEnumerator files(custom_thumbnails_dir, false, |
- base::FileEnumerator::FILES); |
- std::set<std::string> file_name_set; |
- for (base::FilePath current = files.Next(); !current.empty(); |
- current = files.Next()) { |
- file_name_set.insert(current.BaseName().value()); |
- } |
- for (std::set<std::string>::reverse_iterator rit = file_name_set.rbegin(); |
- rit != file_name_set.rend(); ++rit) { |
- file_list.push_back(*rit); |
- } |
- } |
} |
BrowserThread::PostTask( |
BrowserThread::UI, FROM_HERE, |