| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_api.h" | 5 #include "chrome/browser/chromeos/extensions/wallpaper_api.h" |
| 6 | 6 |
| 7 #include "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 chromeos::UserImage wallpaper(*image.get()); | 171 chromeos::UserImage wallpaper(*image.get()); |
| 172 if (!base::PathExists(thumbnail_path.DirName())) | 172 if (!base::PathExists(thumbnail_path.DirName())) |
| 173 base::CreateDirectory(thumbnail_path.DirName()); | 173 base::CreateDirectory(thumbnail_path.DirName()); |
| 174 | 174 |
| 175 scoped_refptr<base::RefCountedBytes> data; | 175 scoped_refptr<base::RefCountedBytes> data; |
| 176 chromeos::WallpaperManager::Get()->ResizeWallpaper( | 176 chromeos::WallpaperManager::Get()->ResizeWallpaper( |
| 177 wallpaper, | 177 wallpaper, |
| 178 ash::WALLPAPER_LAYOUT_STRETCH, | 178 ash::WALLPAPER_LAYOUT_STRETCH, |
| 179 ash::kWallpaperThumbnailWidth, | 179 ash::kWallpaperThumbnailWidth, |
| 180 ash::kWallpaperThumbnailHeight, | 180 ash::kWallpaperThumbnailHeight, |
| 181 &data); | 181 &data, |
| 182 NULL); |
| 182 BrowserThread::PostTask( | 183 BrowserThread::PostTask( |
| 183 BrowserThread::UI, FROM_HERE, | 184 BrowserThread::UI, FROM_HERE, |
| 184 base::Bind( | 185 base::Bind( |
| 185 &WallpaperSetWallpaperFunction::ThumbnailGenerated, | 186 &WallpaperSetWallpaperFunction::ThumbnailGenerated, |
| 186 this, data)); | 187 this, data)); |
| 187 } | 188 } |
| 188 | 189 |
| 189 void WallpaperSetWallpaperFunction::ThumbnailGenerated( | 190 void WallpaperSetWallpaperFunction::ThumbnailGenerated( |
| 190 base::RefCountedBytes* data) { | 191 base::RefCountedBytes* data) { |
| 191 BinaryValue* result = BinaryValue::CreateWithCopiedBuffer( | 192 BinaryValue* result = BinaryValue::CreateWithCopiedBuffer( |
| 192 reinterpret_cast<const char*>(data->front()), data->size()); | 193 reinterpret_cast<const char*>(data->front()), data->size()); |
| 193 SetResult(result); | 194 SetResult(result); |
| 194 SendResponse(true); | 195 SendResponse(true); |
| 195 } | 196 } |
| 196 | 197 |
| 197 void WallpaperSetWallpaperFunction::OnWallpaperFetched( | 198 void WallpaperSetWallpaperFunction::OnWallpaperFetched( |
| 198 bool success, | 199 bool success, |
| 199 const std::string& response) { | 200 const std::string& response) { |
| 200 if (success) { | 201 if (success) { |
| 201 params_->details.wallpaper_data.reset(new std::string(response)); | 202 params_->details.wallpaper_data.reset(new std::string(response)); |
| 202 StartDecode(*params_->details.wallpaper_data); | 203 StartDecode(*params_->details.wallpaper_data); |
| 203 } else { | 204 } else { |
| 204 SetError(response); | 205 SetError(response); |
| 205 SendResponse(false); | 206 SendResponse(false); |
| 206 } | 207 } |
| 207 } | 208 } |
| OLD | NEW |