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

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

Issue 1556783002: Convert Pass()→std::move() for CrOS extension code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
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 <vector> 9 #include <vector>
9 10
10 #include "ash/desktop_background/desktop_background_controller.h" 11 #include "ash/desktop_background/desktop_background_controller.h"
11 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
12 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
13 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/threading/worker_pool.h" 16 #include "base/threading/worker_pool.h"
16 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" 18 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 user_manager::User::CUSTOMIZED, image, update_wallpaper); 153 user_manager::User::CUSTOMIZED, image, update_wallpaper);
153 unsafe_wallpaper_decoder_ = NULL; 154 unsafe_wallpaper_decoder_ = NULL;
154 155
155 if (params_->details.thumbnail) { 156 if (params_->details.thumbnail) {
156 image.EnsureRepsForSupportedScales(); 157 image.EnsureRepsForSupportedScales();
157 scoped_ptr<gfx::ImageSkia> deep_copy(image.DeepCopy()); 158 scoped_ptr<gfx::ImageSkia> deep_copy(image.DeepCopy());
158 // Generates thumbnail before call api function callback. We can then 159 // Generates thumbnail before call api function callback. We can then
159 // request thumbnail in the javascript callback. 160 // request thumbnail in the javascript callback.
160 task_runner->PostTask( 161 task_runner->PostTask(
161 FROM_HERE, 162 FROM_HERE,
162 base::Bind(&WallpaperSetWallpaperFunction::GenerateThumbnail, 163 base::Bind(&WallpaperSetWallpaperFunction::GenerateThumbnail, this,
163 this, 164 thumbnail_path, base::Passed(std::move(deep_copy))));
164 thumbnail_path,
165 base::Passed(deep_copy.Pass())));
166 } else { 165 } else {
167 // Save current extenion name. It will be displayed in the component 166 // Save current extenion name. It will be displayed in the component
168 // wallpaper picker app. If current extension is the component wallpaper 167 // wallpaper picker app. If current extension is the component wallpaper
169 // picker, set an empty string. 168 // picker, set an empty string.
170 Profile* profile = Profile::FromBrowserContext(browser_context()); 169 Profile* profile = Profile::FromBrowserContext(browser_context());
171 if (extension()->id() == extension_misc::kWallpaperManagerId) { 170 if (extension()->id() == extension_misc::kWallpaperManagerId) {
172 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, 171 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
173 std::string()); 172 std::string());
174 } else { 173 } else {
175 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, 174 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
176 extension()->name()); 175 extension()->name());
177 } 176 }
178 SendResponse(true); 177 SendResponse(true);
179 } 178 }
180 179
181 // Inform the native Wallpaper Picker Application that the current wallpaper 180 // Inform the native Wallpaper Picker Application that the current wallpaper
182 // has been modified by a third party application. 181 // has been modified by a third party application.
183 Profile* profile = Profile::FromBrowserContext(browser_context()); 182 Profile* profile = Profile::FromBrowserContext(browser_context());
184 extensions::EventRouter* event_router = extensions::EventRouter::Get(profile); 183 extensions::EventRouter* event_router = extensions::EventRouter::Get(profile);
185 scoped_ptr<base::ListValue> event_args(new base::ListValue()); 184 scoped_ptr<base::ListValue> event_args(new base::ListValue());
186 scoped_ptr<extensions::Event> event(new extensions::Event( 185 scoped_ptr<extensions::Event> event(new extensions::Event(
187 extensions::events::WALLPAPER_PRIVATE_ON_WALLPAPER_CHANGED_BY_3RD_PARTY, 186 extensions::events::WALLPAPER_PRIVATE_ON_WALLPAPER_CHANGED_BY_3RD_PARTY,
188 extensions::api::wallpaper_private::OnWallpaperChangedBy3rdParty:: 187 extensions::api::wallpaper_private::OnWallpaperChangedBy3rdParty::
189 kEventName, 188 kEventName,
190 event_args.Pass())); 189 std::move(event_args)));
191 event_router->DispatchEventToExtension(extension_misc::kWallpaperManagerId, 190 event_router->DispatchEventToExtension(extension_misc::kWallpaperManagerId,
192 event.Pass()); 191 std::move(event));
193 } 192 }
194 193
195 void WallpaperSetWallpaperFunction::GenerateThumbnail( 194 void WallpaperSetWallpaperFunction::GenerateThumbnail(
196 const base::FilePath& thumbnail_path, scoped_ptr<gfx::ImageSkia> image) { 195 const base::FilePath& thumbnail_path, scoped_ptr<gfx::ImageSkia> image) {
197 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( 196 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread(
198 sequence_token_)); 197 sequence_token_));
199 if (!base::PathExists(thumbnail_path.DirName())) 198 if (!base::PathExists(thumbnail_path.DirName()))
200 base::CreateDirectory(thumbnail_path.DirName()); 199 base::CreateDirectory(thumbnail_path.DirName());
201 200
202 scoped_refptr<base::RefCountedBytes> data; 201 scoped_refptr<base::RefCountedBytes> data;
(...skipping 21 matching lines...) Expand all
224 const std::string& response) { 223 const std::string& response) {
225 if (success) { 224 if (success) {
226 params_->details.data.reset( 225 params_->details.data.reset(
227 new std::vector<char>(response.begin(), response.end())); 226 new std::vector<char>(response.begin(), response.end()));
228 StartDecode(*params_->details.data); 227 StartDecode(*params_->details.data);
229 } else { 228 } else {
230 SetError(response); 229 SetError(response);
231 SendResponse(false); 230 SendResponse(false);
232 } 231 }
233 } 232 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698