Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: chrome/browser/chromeos/extensions/wallpaper_api.cc

Issue 1989653002: [Retry] Fix the browser crash when changing wallpaper with chrome.wallpaper API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/wallpaper/test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 BrowserThread::PostTask( 222 BrowserThread::PostTask(
223 BrowserThread::UI, FROM_HERE, 223 BrowserThread::UI, FROM_HERE,
224 base::Bind(&WallpaperSetWallpaperFunction::ThumbnailGenerated, this, 224 base::Bind(&WallpaperSetWallpaperFunction::ThumbnailGenerated, this,
225 base::RetainedRef(original_data), 225 base::RetainedRef(original_data),
226 base::RetainedRef(thumbnail_data))); 226 base::RetainedRef(thumbnail_data)));
227 } 227 }
228 228
229 void WallpaperSetWallpaperFunction::ThumbnailGenerated( 229 void WallpaperSetWallpaperFunction::ThumbnailGenerated(
230 base::RefCountedBytes* original_data, 230 base::RefCountedBytes* original_data,
231 base::RefCountedBytes* thumbnail_data) { 231 base::RefCountedBytes* thumbnail_data) {
232 BinaryValue* original_result = BinaryValue::CreateWithCopiedBuffer( 232 std::unique_ptr<BinaryValue> original_result =
233 reinterpret_cast<const char*>(original_data->front()), 233 base::WrapUnique(BinaryValue::CreateWithCopiedBuffer(
234 original_data->size()); 234 reinterpret_cast<const char*>(original_data->front()),
235 BinaryValue* thumbnail_result = BinaryValue::CreateWithCopiedBuffer( 235 original_data->size()));
236 reinterpret_cast<const char*>(thumbnail_data->front()), 236 std::unique_ptr<BinaryValue> thumbnail_result =
237 thumbnail_data->size()); 237 base::WrapUnique(BinaryValue::CreateWithCopiedBuffer(
238 reinterpret_cast<const char*>(thumbnail_data->front()),
239 thumbnail_data->size()));
238 240
239 if (params_->details.thumbnail) { 241 if (params_->details.thumbnail) {
240 SetResult(base::WrapUnique(thumbnail_result)); 242 SetResult(base::WrapUnique(thumbnail_result->DeepCopy()));
241 SendResponse(true); 243 SendResponse(true);
242 } 244 }
243 245
244 // Inform the native Wallpaper Picker Application that the current wallpaper 246 // Inform the native Wallpaper Picker Application that the current wallpaper
245 // has been modified by a third party application. 247 // has been modified by a third party application.
246 if (extension()->id() != extension_misc::kWallpaperManagerId) { 248 if (extension()->id() != extension_misc::kWallpaperManagerId) {
247 Profile* profile = Profile::FromBrowserContext(browser_context()); 249 Profile* profile = Profile::FromBrowserContext(browser_context());
248 extensions::EventRouter* event_router = 250 extensions::EventRouter* event_router =
249 extensions::EventRouter::Get(profile); 251 extensions::EventRouter::Get(profile);
250 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); 252 std::unique_ptr<base::ListValue> event_args(new base::ListValue());
251 event_args->Append(original_result); 253 event_args->Append(original_result->DeepCopy());
252 event_args->Append(thumbnail_result); 254 event_args->Append(thumbnail_result->DeepCopy());
253 event_args->Append(new base::StringValue( 255 event_args->Append(new base::StringValue(
254 extensions::api::wallpaper::ToString(params_->details.layout))); 256 extensions::api::wallpaper::ToString(params_->details.layout)));
255 // Setting wallpaper from right click menu in 'Files' app is a feature that 257 // Setting wallpaper from right click menu in 'Files' app is a feature that
256 // was implemented in crbug.com/578935. Since 'Files' app is a built-in v1 258 // was implemented in crbug.com/578935. Since 'Files' app is a built-in v1
257 // app in ChromeOS, we should treat it slightly differently with other third 259 // app in ChromeOS, we should treat it slightly differently with other third
258 // party apps: the wallpaper set by the 'Files' app should still be syncable 260 // party apps: the wallpaper set by the 'Files' app should still be syncable
259 // and it should not appear in the wallpaper grid in the Wallpaper Picker. 261 // and it should not appear in the wallpaper grid in the Wallpaper Picker.
260 // But we should not display the 'wallpaper-set-by-mesage' since it might 262 // But we should not display the 'wallpaper-set-by-mesage' since it might
261 // introduce confusion as shown in crbug.com/599407. 263 // introduce confusion as shown in crbug.com/599407.
262 event_args->Append(new base::StringValue( 264 event_args->Append(new base::StringValue(
(...skipping 15 matching lines...) Expand all
278 const std::string& response) { 280 const std::string& response) {
279 if (success) { 281 if (success) {
280 params_->details.data.reset( 282 params_->details.data.reset(
281 new std::vector<char>(response.begin(), response.end())); 283 new std::vector<char>(response.begin(), response.end()));
282 StartDecode(*params_->details.data); 284 StartDecode(*params_->details.data);
283 } else { 285 } else {
284 SetError(response); 286 SetError(response);
285 SendResponse(false); 287 SendResponse(false);
286 } 288 }
287 } 289 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/wallpaper/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698