| 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/desktop_background/desktop_background_controller.h" | 9 #include "ash/desktop_background/desktop_background_controller.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 wallpaper_private::GetOfflineWallpaperList; | 55 wallpaper_private::GetOfflineWallpaperList; |
| 56 | 56 |
| 57 namespace { | 57 namespace { |
| 58 | 58 |
| 59 #if defined(GOOGLE_CHROME_BUILD) | 59 #if defined(GOOGLE_CHROME_BUILD) |
| 60 const char kWallpaperManifestBaseURL[] = | 60 const char kWallpaperManifestBaseURL[] = |
| 61 "https://storage.googleapis.com/chromeos-wallpaper-public/manifest_"; | 61 "https://storage.googleapis.com/chromeos-wallpaper-public/manifest_"; |
| 62 #endif | 62 #endif |
| 63 | 63 |
| 64 bool IsOEMDefaultWallpaper() { | 64 bool IsOEMDefaultWallpaper() { |
| 65 return CommandLine::ForCurrentProcess()->HasSwitch( | 65 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 66 chromeos::switches::kDefaultWallpaperIsOem); | 66 chromeos::switches::kDefaultWallpaperIsOem); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Saves |data| as |file_name| to directory with |key|. Return false if the | 69 // Saves |data| as |file_name| to directory with |key|. Return false if the |
| 70 // directory can not be found/created or failed to write file. | 70 // directory can not be found/created or failed to write file. |
| 71 bool SaveData(int key, const std::string& file_name, const std::string& data) { | 71 bool SaveData(int key, const std::string& file_name, const std::string& data) { |
| 72 base::FilePath data_dir; | 72 base::FilePath data_dir; |
| 73 CHECK(PathService::Get(key, &data_dir)); | 73 CHECK(PathService::Get(key, &data_dir)); |
| 74 if (!base::DirectoryExists(data_dir) && | 74 if (!base::DirectoryExists(data_dir) && |
| 75 !base::CreateDirectory(data_dir)) { | 75 !base::CreateDirectory(data_dir)) { |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 } else { | 732 } else { |
| 733 if (!IsOEMDefaultWallpaper()) { | 733 if (!IsOEMDefaultWallpaper()) { |
| 734 SetError("No OEM wallpaper."); | 734 SetError("No OEM wallpaper."); |
| 735 SendResponse(false); | 735 SendResponse(false); |
| 736 return false; | 736 return false; |
| 737 } | 737 } |
| 738 | 738 |
| 739 // TODO(bshe): Small resolution wallpaper is used here as wallpaper | 739 // TODO(bshe): Small resolution wallpaper is used here as wallpaper |
| 740 // thumbnail. We should either resize it or include a wallpaper thumbnail in | 740 // thumbnail. We should either resize it or include a wallpaper thumbnail in |
| 741 // addition to large and small wallpaper resolutions. | 741 // addition to large and small wallpaper resolutions. |
| 742 thumbnail_path = CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 742 thumbnail_path = base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 743 chromeos::switches::kDefaultWallpaperSmall); | 743 chromeos::switches::kDefaultWallpaperSmall); |
| 744 } | 744 } |
| 745 | 745 |
| 746 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken( | 746 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken( |
| 747 wallpaper::kWallpaperSequenceTokenName); | 747 wallpaper::kWallpaperSequenceTokenName); |
| 748 scoped_refptr<base::SequencedTaskRunner> task_runner = | 748 scoped_refptr<base::SequencedTaskRunner> task_runner = |
| 749 BrowserThread::GetBlockingPool()-> | 749 BrowserThread::GetBlockingPool()-> |
| 750 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, | 750 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, |
| 751 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 751 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 752 | 752 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 this, file_list)); | 894 this, file_list)); |
| 895 } | 895 } |
| 896 | 896 |
| 897 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 897 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
| 898 const std::vector<std::string>& file_list) { | 898 const std::vector<std::string>& file_list) { |
| 899 base::ListValue* results = new base::ListValue(); | 899 base::ListValue* results = new base::ListValue(); |
| 900 results->AppendStrings(file_list); | 900 results->AppendStrings(file_list); |
| 901 SetResult(results); | 901 SetResult(results); |
| 902 SendResponse(true); | 902 SendResponse(true); |
| 903 } | 903 } |
| OLD | NEW |