| 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 "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/threading/worker_pool.h" | 9 #include "base/threading/worker_pool.h" |
| 10 #include "chrome/browser/chromeos/login/user.h" | 10 #include "chrome/browser/chromeos/login/user.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | 65 base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
| 66 | 66 |
| 67 // In the new wallpaper picker UI, we do not depend on WallpaperDelegate | 67 // In the new wallpaper picker UI, we do not depend on WallpaperDelegate |
| 68 // to refresh thumbnail. Uses a null delegate here. | 68 // to refresh thumbnail. Uses a null delegate here. |
| 69 wallpaper_manager->SetCustomWallpaper(email_, file_name_, layout_, | 69 wallpaper_manager->SetCustomWallpaper(email_, file_name_, layout_, |
| 70 chromeos::User::CUSTOMIZED, | 70 chromeos::User::CUSTOMIZED, |
| 71 image); | 71 image); |
| 72 unsafe_wallpaper_decoder_ = NULL; | 72 unsafe_wallpaper_decoder_ = NULL; |
| 73 | 73 |
| 74 if (generate_thumbnail_) { | 74 if (generate_thumbnail_) { |
| 75 wallpaper.EnsureRepsForSupportedScaleFactors(); | 75 wallpaper.EnsureRepsForSupportedScales(); |
| 76 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy()); | 76 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy()); |
| 77 // Generates thumbnail before call api function callback. We can then | 77 // Generates thumbnail before call api function callback. We can then |
| 78 // request thumbnail in the javascript callback. | 78 // request thumbnail in the javascript callback. |
| 79 task_runner->PostTask(FROM_HERE, | 79 task_runner->PostTask(FROM_HERE, |
| 80 base::Bind( | 80 base::Bind( |
| 81 &WallpaperSetWallpaperFunction::GenerateThumbnail, | 81 &WallpaperSetWallpaperFunction::GenerateThumbnail, |
| 82 this, thumbnail_path, base::Passed(&deep_copy))); | 82 this, thumbnail_path, base::Passed(&deep_copy))); |
| 83 } else { | 83 } else { |
| 84 SendResponse(true); | 84 SendResponse(true); |
| 85 } | 85 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 107 this, data)); | 107 this, data)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void WallpaperSetWallpaperFunction::ThumbnailGenerated( | 110 void WallpaperSetWallpaperFunction::ThumbnailGenerated( |
| 111 base::RefCountedBytes* data) { | 111 base::RefCountedBytes* data) { |
| 112 BinaryValue* result = BinaryValue::CreateWithCopiedBuffer( | 112 BinaryValue* result = BinaryValue::CreateWithCopiedBuffer( |
| 113 reinterpret_cast<const char*>(data->front()), data->size()); | 113 reinterpret_cast<const char*>(data->front()), data->size()); |
| 114 SetResult(result); | 114 SetResult(result); |
| 115 SendResponse(true); | 115 SendResponse(true); |
| 116 } | 116 } |
| OLD | NEW |