| 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "ash/desktop_background/desktop_background_controller.h" | 13 #include "ash/desktop_background/desktop_background_controller.h" |
| 13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 14 #include "ash/wm/mru_window_tracker.h" | 15 #include "ash/wm/mru_window_tracker.h" |
| 15 #include "ash/wm/window_state.h" | 16 #include "ash/wm/window_state.h" |
| 16 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
| 17 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 18 #include "base/files/file_enumerator.h" | 19 #include "base/files/file_enumerator.h" |
| 19 #include "base/files/file_util.h" | 20 #include "base/files/file_util.h" |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 void WallpaperPrivateSetWallpaperFunction::SaveToFile() { | 491 void WallpaperPrivateSetWallpaperFunction::SaveToFile() { |
| 491 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( | 492 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
| 492 sequence_token_)); | 493 sequence_token_)); |
| 493 std::string file_name = GURL(params->url).ExtractFileName(); | 494 std::string file_name = GURL(params->url).ExtractFileName(); |
| 494 if (SaveData(chrome::DIR_CHROMEOS_WALLPAPERS, file_name, params->wallpaper)) { | 495 if (SaveData(chrome::DIR_CHROMEOS_WALLPAPERS, file_name, params->wallpaper)) { |
| 495 wallpaper_.EnsureRepsForSupportedScales(); | 496 wallpaper_.EnsureRepsForSupportedScales(); |
| 496 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper_.DeepCopy()); | 497 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper_.DeepCopy()); |
| 497 // ImageSkia is not RefCountedThreadSafe. Use a deep copied ImageSkia if | 498 // ImageSkia is not RefCountedThreadSafe. Use a deep copied ImageSkia if |
| 498 // post to another thread. | 499 // post to another thread. |
| 499 BrowserThread::PostTask( | 500 BrowserThread::PostTask( |
| 500 BrowserThread::UI, | 501 BrowserThread::UI, FROM_HERE, |
| 501 FROM_HERE, | |
| 502 base::Bind(&WallpaperPrivateSetWallpaperFunction::SetDecodedWallpaper, | 502 base::Bind(&WallpaperPrivateSetWallpaperFunction::SetDecodedWallpaper, |
| 503 this, | 503 this, base::Passed(std::move(deep_copy)))); |
| 504 base::Passed(deep_copy.Pass()))); | |
| 505 | 504 |
| 506 base::FilePath wallpaper_dir; | 505 base::FilePath wallpaper_dir; |
| 507 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, &wallpaper_dir)); | 506 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, &wallpaper_dir)); |
| 508 base::FilePath file_path = | 507 base::FilePath file_path = |
| 509 wallpaper_dir.Append(file_name) | 508 wallpaper_dir.Append(file_name) |
| 510 .InsertBeforeExtension(wallpaper::kSmallWallpaperSuffix); | 509 .InsertBeforeExtension(wallpaper::kSmallWallpaperSuffix); |
| 511 if (base::PathExists(file_path)) | 510 if (base::PathExists(file_path)) |
| 512 return; | 511 return; |
| 513 // Generates and saves small resolution wallpaper. Uses CENTER_CROPPED to | 512 // Generates and saves small resolution wallpaper. Uses CENTER_CROPPED to |
| 514 // maintain the aspect ratio after resize. | 513 // maintain the aspect ratio after resize. |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 this, file_list)); | 927 this, file_list)); |
| 929 } | 928 } |
| 930 | 929 |
| 931 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 930 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
| 932 const std::vector<std::string>& file_list) { | 931 const std::vector<std::string>& file_list) { |
| 933 base::ListValue* results = new base::ListValue(); | 932 base::ListValue* results = new base::ListValue(); |
| 934 results->AppendStrings(file_list); | 933 results->AppendStrings(file_list); |
| 935 SetResult(results); | 934 SetResult(results); |
| 936 SendResponse(true); | 935 SendResponse(true); |
| 937 } | 936 } |
| OLD | NEW |