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

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

Issue 2236703002: [Extensions] Convert some SyncExtensionFunctions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nulltpr Created 4 years, 4 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_private_api.h" 5 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 return user_manager::User::DEFAULT; 298 return user_manager::User::DEFAULT;
299 case wallpaper_private::WALLPAPER_SOURCE_THIRDPARTY: 299 case wallpaper_private::WALLPAPER_SOURCE_THIRDPARTY:
300 return user_manager::User::THIRDPARTY; 300 return user_manager::User::THIRDPARTY;
301 default: 301 default:
302 return user_manager::User::ONLINE; 302 return user_manager::User::ONLINE;
303 } 303 }
304 } 304 }
305 305
306 } // namespace 306 } // namespace
307 307
308 bool WallpaperPrivateGetStringsFunction::RunSync() { 308 ExtensionFunction::ResponseAction WallpaperPrivateGetStringsFunction::Run() {
309 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 309 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
310 310
311 #define SET_STRING(id, idr) \ 311 #define SET_STRING(id, idr) \
312 dict->SetString(id, l10n_util::GetStringUTF16(idr)) 312 dict->SetString(id, l10n_util::GetStringUTF16(idr))
313 SET_STRING("webFontFamily", IDS_WEB_FONT_FAMILY); 313 SET_STRING("webFontFamily", IDS_WEB_FONT_FAMILY);
314 SET_STRING("webFontSize", IDS_WEB_FONT_SIZE); 314 SET_STRING("webFontSize", IDS_WEB_FONT_SIZE);
315 SET_STRING("allCategoryLabel", IDS_WALLPAPER_MANAGER_ALL_CATEGORY_LABEL); 315 SET_STRING("allCategoryLabel", IDS_WALLPAPER_MANAGER_ALL_CATEGORY_LABEL);
316 SET_STRING("deleteCommandLabel", IDS_WALLPAPER_MANAGER_DELETE_COMMAND_LABEL); 316 SET_STRING("deleteCommandLabel", IDS_WALLPAPER_MANAGER_DELETE_COMMAND_LABEL);
317 SET_STRING("customCategoryLabel", 317 SET_STRING("customCategoryLabel",
318 IDS_WALLPAPER_MANAGER_CUSTOM_CATEGORY_LABEL); 318 IDS_WALLPAPER_MANAGER_CUSTOM_CATEGORY_LABEL);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 Profile* profile = Profile::FromBrowserContext(browser_context()); 354 Profile* profile = Profile::FromBrowserContext(browser_context());
355 std::string app_name( 355 std::string app_name(
356 profile->GetPrefs()->GetString(prefs::kCurrentWallpaperAppName)); 356 profile->GetPrefs()->GetString(prefs::kCurrentWallpaperAppName));
357 if (!app_name.empty()) 357 if (!app_name.empty())
358 dict->SetString("wallpaperAppName", app_name); 358 dict->SetString("wallpaperAppName", app_name);
359 359
360 dict->SetBoolean("isOEMDefaultWallpaper", IsOEMDefaultWallpaper()); 360 dict->SetBoolean("isOEMDefaultWallpaper", IsOEMDefaultWallpaper());
361 dict->SetString("canceledWallpaper", 361 dict->SetString("canceledWallpaper",
362 wallpaper_api_util::kCancelWallpaperMessage); 362 wallpaper_api_util::kCancelWallpaperMessage);
363 363
364 SetResult(std::move(dict)); 364 return RespondNow(OneArgument(std::move(dict)));
365 return true;
366 } 365 }
367 366
368 bool WallpaperPrivateGetSyncSettingFunction::RunSync() { 367 ExtensionFunction::ResponseAction
368 WallpaperPrivateGetSyncSettingFunction::Run() {
369 Profile* profile = Profile::FromBrowserContext(browser_context()); 369 Profile* profile = Profile::FromBrowserContext(browser_context());
370 ProfileSyncService* sync = 370 ProfileSyncService* sync =
371 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); 371 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
372 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 372 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
373 dict->SetBoolean("syncThemes", 373 dict->SetBoolean("syncThemes",
374 sync->GetActiveDataTypes().Has(syncer::THEMES)); 374 sync->GetActiveDataTypes().Has(syncer::THEMES));
375 SetResult(std::move(dict)); 375 return RespondNow(OneArgument(std::move(dict)));
376 return true;
377 } 376 }
378 377
379 WallpaperPrivateSetWallpaperIfExistsFunction:: 378 WallpaperPrivateSetWallpaperIfExistsFunction::
380 WallpaperPrivateSetWallpaperIfExistsFunction() {} 379 WallpaperPrivateSetWallpaperIfExistsFunction() {}
381 380
382 WallpaperPrivateSetWallpaperIfExistsFunction:: 381 WallpaperPrivateSetWallpaperIfExistsFunction::
383 ~WallpaperPrivateSetWallpaperIfExistsFunction() {} 382 ~WallpaperPrivateSetWallpaperIfExistsFunction() {}
384 383
385 bool WallpaperPrivateSetWallpaperIfExistsFunction::RunAsync() { 384 bool WallpaperPrivateSetWallpaperIfExistsFunction::RunAsync() {
386 params = set_wallpaper_if_exists::Params::Create(*args_); 385 params = set_wallpaper_if_exists::Params::Create(*args_);
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 } 963 }
965 964
966 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( 965 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete(
967 const std::vector<std::string>& file_list) { 966 const std::vector<std::string>& file_list) {
968 std::unique_ptr<base::ListValue> results(new base::ListValue()); 967 std::unique_ptr<base::ListValue> results(new base::ListValue());
969 results->AppendStrings(file_list); 968 results->AppendStrings(file_list);
970 SetResult(std::move(results)); 969 SetResult(std::move(results));
971 SendResponse(true); 970 SendResponse(true);
972 } 971 }
973 972
974 bool WallpaperPrivateRecordWallpaperUMAFunction::RunSync() { 973 ExtensionFunction::ResponseAction
974 WallpaperPrivateRecordWallpaperUMAFunction::Run() {
975 std::unique_ptr<record_wallpaper_uma::Params> params( 975 std::unique_ptr<record_wallpaper_uma::Params> params(
976 record_wallpaper_uma::Params::Create(*args_)); 976 record_wallpaper_uma::Params::Create(*args_));
977 EXTENSION_FUNCTION_VALIDATE(params); 977 EXTENSION_FUNCTION_VALIDATE(params);
978 978
979 user_manager::User::WallpaperType source = getWallpaperType(params->source); 979 user_manager::User::WallpaperType source = getWallpaperType(params->source);
980 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Source", source, 980 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Source", source,
981 user_manager::User::WALLPAPER_TYPE_COUNT); 981 user_manager::User::WALLPAPER_TYPE_COUNT);
982 return true; 982 return RespondNow(NoArguments());
983 } 983 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698