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/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 file_name).InsertBeforeExtension(chromeos::kSmallWallpaperSuffix); | 438 file_name).InsertBeforeExtension(chromeos::kSmallWallpaperSuffix); |
439 if (base::PathExists(file_path)) | 439 if (base::PathExists(file_path)) |
440 return; | 440 return; |
441 // Generates and saves small resolution wallpaper. Uses CENTER_CROPPED to | 441 // Generates and saves small resolution wallpaper. Uses CENTER_CROPPED to |
442 // maintain the aspect ratio after resize. | 442 // maintain the aspect ratio after resize. |
443 chromeos::WallpaperManager::Get()->ResizeAndSaveWallpaper( | 443 chromeos::WallpaperManager::Get()->ResizeAndSaveWallpaper( |
444 wallpaper, | 444 wallpaper, |
445 file_path, | 445 file_path, |
446 ash::WALLPAPER_LAYOUT_CENTER_CROPPED, | 446 ash::WALLPAPER_LAYOUT_CENTER_CROPPED, |
447 ash::kSmallWallpaperMaxWidth, | 447 ash::kSmallWallpaperMaxWidth, |
448 ash::kSmallWallpaperMaxHeight); | 448 ash::kSmallWallpaperMaxHeight, |
| 449 NULL); |
449 } else { | 450 } else { |
450 std::string error = base::StringPrintf( | 451 std::string error = base::StringPrintf( |
451 "Failed to create/write wallpaper to %s.", file_name.c_str()); | 452 "Failed to create/write wallpaper to %s.", file_name.c_str()); |
452 BrowserThread::PostTask( | 453 BrowserThread::PostTask( |
453 BrowserThread::UI, FROM_HERE, | 454 BrowserThread::UI, FROM_HERE, |
454 base::Bind(&WallpaperPrivateSetWallpaperFunction::OnFailure, | 455 base::Bind(&WallpaperPrivateSetWallpaperFunction::OnFailure, |
455 this, error)); | 456 this, error)); |
456 } | 457 } |
457 } | 458 } |
458 | 459 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 chromeos::UserImage wallpaper(*image.get()); | 582 chromeos::UserImage wallpaper(*image.get()); |
582 if (!base::PathExists(thumbnail_path.DirName())) | 583 if (!base::PathExists(thumbnail_path.DirName())) |
583 base::CreateDirectory(thumbnail_path.DirName()); | 584 base::CreateDirectory(thumbnail_path.DirName()); |
584 | 585 |
585 scoped_refptr<base::RefCountedBytes> data; | 586 scoped_refptr<base::RefCountedBytes> data; |
586 chromeos::WallpaperManager::Get()->ResizeWallpaper( | 587 chromeos::WallpaperManager::Get()->ResizeWallpaper( |
587 wallpaper, | 588 wallpaper, |
588 ash::WALLPAPER_LAYOUT_STRETCH, | 589 ash::WALLPAPER_LAYOUT_STRETCH, |
589 ash::kWallpaperThumbnailWidth, | 590 ash::kWallpaperThumbnailWidth, |
590 ash::kWallpaperThumbnailHeight, | 591 ash::kWallpaperThumbnailHeight, |
591 &data); | 592 &data, |
| 593 NULL); |
592 BrowserThread::PostTask( | 594 BrowserThread::PostTask( |
593 BrowserThread::UI, FROM_HERE, | 595 BrowserThread::UI, FROM_HERE, |
594 base::Bind( | 596 base::Bind( |
595 &WallpaperPrivateSetCustomWallpaperFunction::ThumbnailGenerated, | 597 &WallpaperPrivateSetCustomWallpaperFunction::ThumbnailGenerated, |
596 this, data)); | 598 this, data)); |
597 } | 599 } |
598 | 600 |
599 void WallpaperPrivateSetCustomWallpaperFunction::ThumbnailGenerated( | 601 void WallpaperPrivateSetCustomWallpaperFunction::ThumbnailGenerated( |
600 base::RefCountedBytes* data) { | 602 base::RefCountedBytes* data) { |
601 BinaryValue* result = BinaryValue::CreateWithCopiedBuffer( | 603 BinaryValue* result = BinaryValue::CreateWithCopiedBuffer( |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 this, file_list)); | 851 this, file_list)); |
850 } | 852 } |
851 | 853 |
852 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 854 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
853 const std::vector<std::string>& file_list) { | 855 const std::vector<std::string>& file_list) { |
854 base::ListValue* results = new base::ListValue(); | 856 base::ListValue* results = new base::ListValue(); |
855 results->AppendStrings(file_list); | 857 results->AppendStrings(file_list); |
856 SetResult(results); | 858 SetResult(results); |
857 SendResponse(true); | 859 SendResponse(true); |
858 } | 860 } |
OLD | NEW |