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

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

Issue 1631923004: Sync 3rd party wallpaper app name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address tbarzic@'s comments. Created 4 years, 10 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 <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 wallpaper_api_util::RecordCustomWallpaperLayout(layout); 146 wallpaper_api_util::RecordCustomWallpaperLayout(layout);
147 147
148 bool update_wallpaper = 148 bool update_wallpaper =
149 account_id_ == 149 account_id_ ==
150 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); 150 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId();
151 wallpaper_manager->SetCustomWallpaper( 151 wallpaper_manager->SetCustomWallpaper(
152 account_id_, user_id_hash_, params_->details.filename, layout, 152 account_id_, user_id_hash_, params_->details.filename, layout,
153 user_manager::User::CUSTOMIZED, image, update_wallpaper); 153 user_manager::User::CUSTOMIZED, image, update_wallpaper);
154 unsafe_wallpaper_decoder_ = NULL; 154 unsafe_wallpaper_decoder_ = NULL;
155 155
156 // Save current extenion name. It will be displayed in the component
157 // wallpaper picker app. If current extension is the component wallpaper
158 // picker, set an empty string.
159 Profile* profile = Profile::FromBrowserContext(browser_context());
160 if (extension()->id() == extension_misc::kWallpaperManagerId) {
161 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
162 std::string());
163 } else {
164 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
165 extension()->name());
166 }
167
168 if (!params_->details.thumbnail) 156 if (!params_->details.thumbnail)
169 SendResponse(true); 157 SendResponse(true);
170 158
171 // We need to generate thumbnail image anyway to make the current third party 159 // We need to generate thumbnail image anyway to make the current third party
172 // wallpaper syncable through different devices. 160 // wallpaper syncable through different devices.
173 image.EnsureRepsForSupportedScales(); 161 image.EnsureRepsForSupportedScales();
174 scoped_ptr<gfx::ImageSkia> deep_copy(image.DeepCopy()); 162 scoped_ptr<gfx::ImageSkia> deep_copy(image.DeepCopy());
175 // Generates thumbnail before call api function callback. We can then 163 // Generates thumbnail before call api function callback. We can then
176 // request thumbnail in the javascript callback. 164 // request thumbnail in the javascript callback.
177 task_runner->PostTask( 165 task_runner->PostTask(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 reinterpret_cast<const char*>(thumbnail_data->front()), 200 reinterpret_cast<const char*>(thumbnail_data->front()),
213 thumbnail_data->size()); 201 thumbnail_data->size());
214 202
215 if (params_->details.thumbnail) { 203 if (params_->details.thumbnail) {
216 SetResult(thumbnail_result); 204 SetResult(thumbnail_result);
217 SendResponse(true); 205 SendResponse(true);
218 } 206 }
219 207
220 // Inform the native Wallpaper Picker Application that the current wallpaper 208 // Inform the native Wallpaper Picker Application that the current wallpaper
221 // has been modified by a third party application. 209 // has been modified by a third party application.
210 std::string third_party_appname;
211 if (extension()->id() != extension_misc::kWallpaperManagerId)
212 third_party_appname = extension()->name();
222 Profile* profile = Profile::FromBrowserContext(browser_context()); 213 Profile* profile = Profile::FromBrowserContext(browser_context());
223 extensions::EventRouter* event_router = extensions::EventRouter::Get(profile); 214 extensions::EventRouter* event_router = extensions::EventRouter::Get(profile);
224 scoped_ptr<base::ListValue> event_args(new base::ListValue()); 215 scoped_ptr<base::ListValue> event_args(new base::ListValue());
225 event_args->Append(original_result); 216 event_args->Append(original_result);
226 event_args->Append(thumbnail_result); 217 event_args->Append(thumbnail_result);
227 event_args->Append(new base::StringValue( 218 event_args->Append(new base::StringValue(
228 extensions::api::wallpaper::ToString(params_->details.layout))); 219 extensions::api::wallpaper::ToString(params_->details.layout)));
220 event_args->Append(new base::StringValue(third_party_appname));
229 scoped_ptr<extensions::Event> event(new extensions::Event( 221 scoped_ptr<extensions::Event> event(new extensions::Event(
230 extensions::events::WALLPAPER_PRIVATE_ON_WALLPAPER_CHANGED_BY_3RD_PARTY, 222 extensions::events::WALLPAPER_PRIVATE_ON_WALLPAPER_CHANGED_BY_3RD_PARTY,
231 extensions::api::wallpaper_private::OnWallpaperChangedBy3rdParty:: 223 extensions::api::wallpaper_private::OnWallpaperChangedBy3rdParty::
232 kEventName, 224 kEventName,
233 std::move(event_args))); 225 std::move(event_args)));
234 event_router->DispatchEventToExtension(extension_misc::kWallpaperManagerId, 226 event_router->DispatchEventToExtension(extension_misc::kWallpaperManagerId,
235 std::move(event)); 227 std::move(event));
236 } 228 }
237 229
238 void WallpaperSetWallpaperFunction::OnWallpaperFetched( 230 void WallpaperSetWallpaperFunction::OnWallpaperFetched(
239 bool success, 231 bool success,
240 const std::string& response) { 232 const std::string& response) {
241 if (success) { 233 if (success) {
242 params_->details.data.reset( 234 params_->details.data.reset(
243 new std::vector<char>(response.begin(), response.end())); 235 new std::vector<char>(response.begin(), response.end()));
244 StartDecode(*params_->details.data); 236 StartDecode(*params_->details.data);
245 } else { 237 } else {
246 SetError(response); 238 SetError(response);
247 SendResponse(false); 239 SendResponse(false);
248 } 240 }
249 } 241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698