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 <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 bool WallpaperSetWallpaperFunction::RunAsync() { | 117 bool WallpaperSetWallpaperFunction::RunAsync() { |
118 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 118 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
119 params_ = set_wallpaper::Params::Create(*args_); | 119 params_ = set_wallpaper::Params::Create(*args_); |
120 EXTENSION_FUNCTION_VALIDATE(params_); | 120 EXTENSION_FUNCTION_VALIDATE(params_); |
121 | 121 |
122 // Gets account id from the caller, ensuring multiprofile compatibility. | 122 // Gets account id from the caller, ensuring multiprofile compatibility. |
123 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); | 123 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); |
124 account_id_ = user->GetAccountId(); | 124 account_id_ = user->GetAccountId(); |
125 chromeos::WallpaperManager* wallpaper_manager = | 125 chromeos::WallpaperManager* wallpaper_manager = |
126 chromeos::WallpaperManager::Get(); | 126 chromeos::WallpaperManager::Get(); |
127 wallpaper_files_id_ = wallpaper_manager->GetFilesId(*user); | 127 wallpaper_files_id_ = wallpaper_manager->GetFilesId(account_id_); |
128 | 128 |
129 if (params_->details.data) { | 129 if (params_->details.data) { |
130 StartDecode(*params_->details.data); | 130 StartDecode(*params_->details.data); |
131 } else if (params_->details.url) { | 131 } else if (params_->details.url) { |
132 GURL wallpaper_url(*params_->details.url); | 132 GURL wallpaper_url(*params_->details.url); |
133 if (wallpaper_url.is_valid()) { | 133 if (wallpaper_url.is_valid()) { |
134 g_wallpaper_fetcher.Get().FetchWallpaper( | 134 g_wallpaper_fetcher.Get().FetchWallpaper( |
135 wallpaper_url, | 135 wallpaper_url, |
136 base::Bind(&WallpaperSetWallpaperFunction::OnWallpaperFetched, this)); | 136 base::Bind(&WallpaperSetWallpaperFunction::OnWallpaperFetched, this)); |
137 } else { | 137 } else { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 const std::string& response) { | 264 const std::string& response) { |
265 if (success) { | 265 if (success) { |
266 params_->details.data.reset( | 266 params_->details.data.reset( |
267 new std::vector<char>(response.begin(), response.end())); | 267 new std::vector<char>(response.begin(), response.end())); |
268 StartDecode(*params_->details.data); | 268 StartDecode(*params_->details.data); |
269 } else { | 269 } else { |
270 SetError(response); | 270 SetError(response); |
271 SendResponse(false); | 271 SendResponse(false); |
272 } | 272 } |
273 } | 273 } |
OLD | NEW |