| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/mru_window_tracker.h" | 10 #include "ash/wm/mru_window_tracker.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 363 |
| 364 task_runner->PostTask(FROM_HERE, | 364 task_runner->PostTask(FROM_HERE, |
| 365 base::Bind(&WallpaperPrivateSetWallpaperFunction::SaveToFile, this)); | 365 base::Bind(&WallpaperPrivateSetWallpaperFunction::SaveToFile, this)); |
| 366 } | 366 } |
| 367 | 367 |
| 368 void WallpaperPrivateSetWallpaperFunction::SaveToFile() { | 368 void WallpaperPrivateSetWallpaperFunction::SaveToFile() { |
| 369 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( | 369 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
| 370 sequence_token_)); | 370 sequence_token_)); |
| 371 std::string file_name = GURL(url_).ExtractFileName(); | 371 std::string file_name = GURL(url_).ExtractFileName(); |
| 372 if (SaveData(chrome::DIR_CHROMEOS_WALLPAPERS, file_name, image_data_)) { | 372 if (SaveData(chrome::DIR_CHROMEOS_WALLPAPERS, file_name, image_data_)) { |
| 373 wallpaper_.EnsureRepsForSupportedScaleFactors(); | 373 wallpaper_.EnsureRepsForSupportedScales(); |
| 374 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper_.DeepCopy()); | 374 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper_.DeepCopy()); |
| 375 // ImageSkia is not RefCountedThreadSafe. Use a deep copied ImageSkia if | 375 // ImageSkia is not RefCountedThreadSafe. Use a deep copied ImageSkia if |
| 376 // post to another thread. | 376 // post to another thread. |
| 377 BrowserThread::PostTask( | 377 BrowserThread::PostTask( |
| 378 BrowserThread::UI, FROM_HERE, | 378 BrowserThread::UI, FROM_HERE, |
| 379 base::Bind(&WallpaperPrivateSetWallpaperFunction::SetDecodedWallpaper, | 379 base::Bind(&WallpaperPrivateSetWallpaperFunction::SetDecodedWallpaper, |
| 380 this, base::Passed(&deep_copy))); | 380 this, base::Passed(&deep_copy))); |
| 381 chromeos::UserImage wallpaper(wallpaper_); | 381 chromeos::UserImage wallpaper(wallpaper_); |
| 382 | 382 |
| 383 base::FilePath wallpaper_dir; | 383 base::FilePath wallpaper_dir; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | 495 base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
| 496 | 496 |
| 497 // In the new wallpaper picker UI, we do not depend on WallpaperDelegate | 497 // In the new wallpaper picker UI, we do not depend on WallpaperDelegate |
| 498 // to refresh thumbnail. Uses a null delegate here. | 498 // to refresh thumbnail. Uses a null delegate here. |
| 499 wallpaper_manager->SetCustomWallpaper(email_, file_name_, layout_, | 499 wallpaper_manager->SetCustomWallpaper(email_, file_name_, layout_, |
| 500 chromeos::User::CUSTOMIZED, | 500 chromeos::User::CUSTOMIZED, |
| 501 image); | 501 image); |
| 502 unsafe_wallpaper_decoder_ = NULL; | 502 unsafe_wallpaper_decoder_ = NULL; |
| 503 | 503 |
| 504 if (generate_thumbnail_) { | 504 if (generate_thumbnail_) { |
| 505 wallpaper.EnsureRepsForSupportedScaleFactors(); | 505 wallpaper.EnsureRepsForSupportedScales(); |
| 506 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy()); | 506 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy()); |
| 507 // Generates thumbnail before call api function callback. We can then | 507 // Generates thumbnail before call api function callback. We can then |
| 508 // request thumbnail in the javascript callback. | 508 // request thumbnail in the javascript callback. |
| 509 task_runner->PostTask(FROM_HERE, | 509 task_runner->PostTask(FROM_HERE, |
| 510 base::Bind( | 510 base::Bind( |
| 511 &WallpaperPrivateSetCustomWallpaperFunction::GenerateThumbnail, | 511 &WallpaperPrivateSetCustomWallpaperFunction::GenerateThumbnail, |
| 512 this, thumbnail_path, base::Passed(&deep_copy))); | 512 this, thumbnail_path, base::Passed(&deep_copy))); |
| 513 } else { | 513 } else { |
| 514 SendResponse(true); | 514 SendResponse(true); |
| 515 } | 515 } |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 this, file_list)); | 803 this, file_list)); |
| 804 } | 804 } |
| 805 | 805 |
| 806 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 806 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
| 807 const std::vector<std::string>& file_list) { | 807 const std::vector<std::string>& file_list) { |
| 808 ListValue* results = new ListValue(); | 808 ListValue* results = new ListValue(); |
| 809 results->AppendStrings(file_list); | 809 results->AppendStrings(file_list); |
| 810 SetResult(results); | 810 SetResult(results); |
| 811 SendResponse(true); | 811 SendResponse(true); |
| 812 } | 812 } |
| OLD | NEW |