| 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 "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/threading/worker_pool.h" | 13 #include "base/threading/worker_pool.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chromeos/login/users/user.h" | |
| 16 #include "chrome/browser/chromeos/login/users/user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 17 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 16 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 20 #include "chrome/common/extensions/extension_constants.h" | 19 #include "chrome/common/extensions/extension_constants.h" |
| 21 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "components/user_manager/user.h" |
| 22 #include "net/base/load_flags.h" | 22 #include "net/base/load_flags.h" |
| 23 #include "net/http/http_status_code.h" | 23 #include "net/http/http_status_code.h" |
| 24 #include "net/url_request/url_fetcher.h" | 24 #include "net/url_request/url_fetcher.h" |
| 25 #include "net/url_request/url_fetcher_delegate.h" | 25 #include "net/url_request/url_fetcher_delegate.h" |
| 26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 27 | 27 |
| 28 using base::BinaryValue; | 28 using base::BinaryValue; |
| 29 using content::BrowserThread; | 29 using content::BrowserThread; |
| 30 | 30 |
| 31 typedef base::Callback<void(bool success, const std::string&)> FetchCallback; | 31 typedef base::Callback<void(bool success, const std::string&)> FetchCallback; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, | 136 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, |
| 137 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | 137 base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
| 138 ash::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( | 138 ash::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( |
| 139 set_wallpaper::Params::Details::ToString(params_->details.layout)); | 139 set_wallpaper::Params::Details::ToString(params_->details.layout)); |
| 140 bool update_wallpaper = | 140 bool update_wallpaper = |
| 141 user_id_ == chromeos::UserManager::Get()->GetActiveUser()->email(); | 141 user_id_ == chromeos::UserManager::Get()->GetActiveUser()->email(); |
| 142 wallpaper_manager->SetCustomWallpaper(user_id_, | 142 wallpaper_manager->SetCustomWallpaper(user_id_, |
| 143 user_id_hash_, | 143 user_id_hash_, |
| 144 params_->details.name, | 144 params_->details.name, |
| 145 layout, | 145 layout, |
| 146 chromeos::User::CUSTOMIZED, | 146 user_manager::User::CUSTOMIZED, |
| 147 image, | 147 image, |
| 148 update_wallpaper); | 148 update_wallpaper); |
| 149 unsafe_wallpaper_decoder_ = NULL; | 149 unsafe_wallpaper_decoder_ = NULL; |
| 150 | 150 |
| 151 if (params_->details.thumbnail) { | 151 if (params_->details.thumbnail) { |
| 152 image.EnsureRepsForSupportedScales(); | 152 image.EnsureRepsForSupportedScales(); |
| 153 scoped_ptr<gfx::ImageSkia> deep_copy(image.DeepCopy()); | 153 scoped_ptr<gfx::ImageSkia> deep_copy(image.DeepCopy()); |
| 154 // Generates thumbnail before call api function callback. We can then | 154 // Generates thumbnail before call api function callback. We can then |
| 155 // request thumbnail in the javascript callback. | 155 // request thumbnail in the javascript callback. |
| 156 task_runner->PostTask( | 156 task_runner->PostTask( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 bool success, | 209 bool success, |
| 210 const std::string& response) { | 210 const std::string& response) { |
| 211 if (success) { | 211 if (success) { |
| 212 params_->details.wallpaper_data.reset(new std::string(response)); | 212 params_->details.wallpaper_data.reset(new std::string(response)); |
| 213 StartDecode(*params_->details.wallpaper_data); | 213 StartDecode(*params_->details.wallpaper_data); |
| 214 } else { | 214 } else { |
| 215 SetError(response); | 215 SetError(response); |
| 216 SendResponse(false); | 216 SendResponse(false); |
| 217 } | 217 } |
| 218 } | 218 } |
| OLD | NEW |