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 |
11 #include "ash/desktop_background/desktop_background_controller.h" | 11 #include "ash/desktop_background/desktop_background_controller.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/memory/ptr_util.h" | |
15 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
16 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
17 #include "base/threading/worker_pool.h" | 16 #include "base/threading/worker_pool.h" |
18 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" | 18 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" |
20 #include "chrome/browser/chromeos/file_manager/app_id.h" | 19 #include "chrome/browser/chromeos/file_manager/app_id.h" |
21 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 20 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
22 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 21 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
23 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 BrowserThread::UI, FROM_HERE, | 222 BrowserThread::UI, FROM_HERE, |
224 base::Bind(&WallpaperSetWallpaperFunction::ThumbnailGenerated, this, | 223 base::Bind(&WallpaperSetWallpaperFunction::ThumbnailGenerated, this, |
225 base::RetainedRef(original_data), | 224 base::RetainedRef(original_data), |
226 base::RetainedRef(thumbnail_data))); | 225 base::RetainedRef(thumbnail_data))); |
227 } | 226 } |
228 | 227 |
229 void WallpaperSetWallpaperFunction::ThumbnailGenerated( | 228 void WallpaperSetWallpaperFunction::ThumbnailGenerated( |
230 base::RefCountedBytes* original_data, | 229 base::RefCountedBytes* original_data, |
231 base::RefCountedBytes* thumbnail_data) { | 230 base::RefCountedBytes* thumbnail_data) { |
232 std::unique_ptr<BinaryValue> original_result = | 231 std::unique_ptr<BinaryValue> original_result = |
233 base::WrapUnique(BinaryValue::CreateWithCopiedBuffer( | 232 BinaryValue::CreateWithCopiedBuffer( |
234 reinterpret_cast<const char*>(original_data->front()), | 233 reinterpret_cast<const char*>(original_data->front()), |
235 original_data->size())); | 234 original_data->size()); |
236 std::unique_ptr<BinaryValue> thumbnail_result = | 235 std::unique_ptr<BinaryValue> thumbnail_result = |
237 base::WrapUnique(BinaryValue::CreateWithCopiedBuffer( | 236 BinaryValue::CreateWithCopiedBuffer( |
238 reinterpret_cast<const char*>(thumbnail_data->front()), | 237 reinterpret_cast<const char*>(thumbnail_data->front()), |
239 thumbnail_data->size())); | 238 thumbnail_data->size()); |
240 | 239 |
241 if (params_->details.thumbnail) { | 240 if (params_->details.thumbnail) { |
242 SetResult(base::WrapUnique(thumbnail_result->DeepCopy())); | 241 SetResult(thumbnail_result->CreateDeepCopy()); |
dcheng
2016/06/15 08:34:03
Strictly speaking, not directly related, but may a
| |
243 SendResponse(true); | 242 SendResponse(true); |
244 } | 243 } |
245 | 244 |
246 // Inform the native Wallpaper Picker Application that the current wallpaper | 245 // Inform the native Wallpaper Picker Application that the current wallpaper |
247 // has been modified by a third party application. | 246 // has been modified by a third party application. |
248 if (extension()->id() != extension_misc::kWallpaperManagerId) { | 247 if (extension()->id() != extension_misc::kWallpaperManagerId) { |
249 Profile* profile = Profile::FromBrowserContext(browser_context()); | 248 Profile* profile = Profile::FromBrowserContext(browser_context()); |
250 extensions::EventRouter* event_router = | 249 extensions::EventRouter* event_router = |
251 extensions::EventRouter::Get(profile); | 250 extensions::EventRouter::Get(profile); |
252 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); | 251 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); |
(...skipping 27 matching lines...) Expand all Loading... | |
280 const std::string& response) { | 279 const std::string& response) { |
281 if (success) { | 280 if (success) { |
282 params_->details.data.reset( | 281 params_->details.data.reset( |
283 new std::vector<char>(response.begin(), response.end())); | 282 new std::vector<char>(response.begin(), response.end())); |
284 StartDecode(*params_->details.data); | 283 StartDecode(*params_->details.data); |
285 } else { | 284 } else { |
286 SetError(response); | 285 SetError(response); |
287 SendResponse(false); | 286 SendResponse(false); |
288 } | 287 } |
289 } | 288 } |
OLD | NEW |