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

Unified Diff: chrome/browser/chromeos/extensions/wallpaper_private_api.cc

Issue 11092078: Add some error messages for setting wallpaper failures on Chrome(c++) side. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Using localized string Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
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 7d44c40556027a7386f2550bc3747a4218a69c7e..5c0f2635e547541bef618f39fee6135b3fefcb85 100644
--- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
+++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
@@ -101,7 +101,7 @@ class WallpaperFunctionBase::WallpaperDecoder : public ImageDecoder::Delegate {
gfx::ImageSkia final_image(decoded_image);
final_image.MakeThreadSafe();
if (cancel_flag_.IsSet()) {
- function_->OnFailureOrCancel();
+ function_->OnFailureOrCancel("");
delete this;
return;
}
@@ -110,8 +110,8 @@ class WallpaperFunctionBase::WallpaperDecoder : public ImageDecoder::Delegate {
}
virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE {
- function_->OnFailureOrCancel();
- // TODO(bshe): Dispatches an encoding error event.
+ function_->OnFailureOrCancel(
+ l10n_util::GetStringUTF8(IDS_WALLPAPER_MANAGER_INVALID_FORMAT));
delete this;
}
@@ -132,6 +132,12 @@ WallpaperFunctionBase::WallpaperFunctionBase() {
WallpaperFunctionBase::~WallpaperFunctionBase() {
}
+void WallpaperFunctionBase::OnFailureOrCancel(const std::string& error) {
+ wallpaper_decoder_ = NULL;
+ SetResult(Value::CreateStringValue(error));
Mihai Parparita -not on Chrome 2012/10/18 00:30:54 The more idiomatic (with other APIs) way of doing
bshe 2012/10/18 17:34:59 I made the change and use SetError as you suggeste
+ SendResponse(false);
+}
+
WallpaperSetWallpaperFunction::WallpaperSetWallpaperFunction() {
}
@@ -174,11 +180,6 @@ void WallpaperSetWallpaperFunction::OnWallpaperDecoded(
this));
}
-void WallpaperSetWallpaperFunction::OnFailureOrCancel() {
- wallpaper_decoder_ = NULL;
- SendResponse(false);
-}
-
void WallpaperSetWallpaperFunction::SaveToFile() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
FilePath wallpaper_dir;
@@ -188,7 +189,8 @@ void WallpaperSetWallpaperFunction::SaveToFile() {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&WallpaperSetWallpaperFunction::OnFailureOrCancel,
- this));
+ this, ""));
+ LOG(ERROR) << "Failed to create wallpaper directory.";
return;
}
std::string file_name = GURL(url_).ExtractFileName();
@@ -214,7 +216,8 @@ void WallpaperSetWallpaperFunction::SaveToFile() {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&WallpaperSetWallpaperFunction::OnFailureOrCancel,
- this));
+ this, ""));
+ LOG(ERROR) << "Failed to save downloaded wallpaper.";
}
}
@@ -231,6 +234,7 @@ void WallpaperSetWallpaperFunction::SetDecodedWallpaper() {
base::Time::Now().LocalMidnight()
};
wallpaper_manager->SetUserWallpaperInfo(email_, info, is_persistent);
+ SetResult(Value::CreateStringValue(""));
SendResponse(true);
}
@@ -274,10 +278,6 @@ void WallpaperSetCustomWallpaperFunction::OnWallpaperDecoded(
email_, layout_, chromeos::User::CUSTOMIZED,
base::WeakPtr<chromeos::WallpaperDelegate>(), image);
wallpaper_decoder_ = NULL;
+ SetResult(Value::CreateStringValue(""));
SendResponse(true);
}
-
-void WallpaperSetCustomWallpaperFunction::OnFailureOrCancel() {
- wallpaper_decoder_ = NULL;
- SendResponse(false);
-}

Powered by Google App Engine
This is Rietveld 408576698