Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/window_cycle_controller.h" | 10 #include "ash/wm/window_cycle_controller.h" |
| 11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 17 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
| 18 #include "base/synchronization/cancellation_flag.h" | 18 #include "base/synchronization/cancellation_flag.h" |
| 19 #include "base/threading/sequenced_worker_pool.h" | 19 #include "base/threading/sequenced_worker_pool.h" |
| 20 #include "base/threading/worker_pool.h" | 20 #include "base/threading/worker_pool.h" |
| 21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/chromeos/login/user.h" | |
| 22 #include "chrome/browser/chromeos/login/user_image.h" | 23 #include "chrome/browser/chromeos/login/user_image.h" |
| 23 #include "chrome/browser/chromeos/login/user_manager.h" | 24 #include "chrome/browser/chromeos/login/user_manager.h" |
| 24 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 25 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
| 25 #include "chrome/browser/extensions/event_router.h" | 26 #include "chrome/browser/extensions/event_router.h" |
| 26 #include "chrome/browser/image_decoder.h" | 27 #include "chrome/browser/image_decoder.h" |
| 27 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 28 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 29 #include "net/url_request/url_fetcher.h" | 30 #include "net/url_request/url_fetcher.h" |
| 30 #include "net/url_request/url_fetcher_delegate.h" | 31 #include "net/url_request/url_fetcher_delegate.h" |
| 31 #include "net/url_request/url_request_status.h" | 32 #include "net/url_request/url_request_status.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 } // namespace | 176 } // namespace |
| 176 | 177 |
| 177 bool WallpaperPrivateGetStringsFunction::RunImpl() { | 178 bool WallpaperPrivateGetStringsFunction::RunImpl() { |
| 178 DictionaryValue* dict = new DictionaryValue(); | 179 DictionaryValue* dict = new DictionaryValue(); |
| 179 SetResult(dict); | 180 SetResult(dict); |
| 180 | 181 |
| 181 #define SET_STRING(id, idr) \ | 182 #define SET_STRING(id, idr) \ |
| 182 dict->SetString(id, l10n_util::GetStringUTF16(idr)) | 183 dict->SetString(id, l10n_util::GetStringUTF16(idr)) |
| 183 SET_STRING("webFontFamily", IDS_WEB_FONT_FAMILY); | 184 SET_STRING("webFontFamily", IDS_WEB_FONT_FAMILY); |
| 184 SET_STRING("webFontSize", IDS_WEB_FONT_SIZE); | 185 SET_STRING("webFontSize", IDS_WEB_FONT_SIZE); |
| 185 SET_STRING("searchTextLabel", IDS_WALLPAPER_MANAGER_SEARCH_TEXT_LABEL); | |
| 186 SET_STRING("allCategoryLabel", IDS_WALLPAPER_MANAGER_ALL_CATEGORY_LABEL); | 186 SET_STRING("allCategoryLabel", IDS_WALLPAPER_MANAGER_ALL_CATEGORY_LABEL); |
| 187 SET_STRING("deleteCommandLabel", IDS_WALLPAPER_MANAGER_DELETE_COMMAND_LABEL); | |
| 187 SET_STRING("customCategoryLabel", | 188 SET_STRING("customCategoryLabel", |
| 188 IDS_WALLPAPER_MANAGER_CUSTOM_CATEGORY_LABEL); | 189 IDS_WALLPAPER_MANAGER_CUSTOM_CATEGORY_LABEL); |
| 189 SET_STRING("selectCustomLabel", | 190 SET_STRING("selectCustomLabel", |
| 190 IDS_WALLPAPER_MANAGER_SELECT_CUSTOM_LABEL); | 191 IDS_WALLPAPER_MANAGER_SELECT_CUSTOM_LABEL); |
| 191 SET_STRING("positionLabel", IDS_WALLPAPER_MANAGER_POSITION_LABEL); | 192 SET_STRING("positionLabel", IDS_WALLPAPER_MANAGER_POSITION_LABEL); |
| 192 SET_STRING("colorLabel", IDS_WALLPAPER_MANAGER_COLOR_LABEL); | 193 SET_STRING("colorLabel", IDS_WALLPAPER_MANAGER_COLOR_LABEL); |
| 193 SET_STRING("previewLabel", IDS_WALLPAPER_MANAGER_PREVIEW_LABEL); | |
| 194 SET_STRING("downloadingLabel", IDS_WALLPAPER_MANAGER_DOWNLOADING_LABEL); | |
| 195 SET_STRING("setWallpaperDaily", IDS_OPTIONS_SET_WALLPAPER_DAILY); | |
| 196 SET_STRING("searchTextLabel", IDS_WALLPAPER_MANAGER_SEARCH_TEXT_LABEL); | |
| 197 SET_STRING("centerCroppedLayout", | 194 SET_STRING("centerCroppedLayout", |
| 198 IDS_OPTIONS_WALLPAPER_CENTER_CROPPED_LAYOUT); | 195 IDS_OPTIONS_WALLPAPER_CENTER_CROPPED_LAYOUT); |
| 199 SET_STRING("centerLayout", IDS_OPTIONS_WALLPAPER_CENTER_LAYOUT); | 196 SET_STRING("centerLayout", IDS_OPTIONS_WALLPAPER_CENTER_LAYOUT); |
| 200 SET_STRING("stretchLayout", IDS_OPTIONS_WALLPAPER_STRETCH_LAYOUT); | 197 SET_STRING("stretchLayout", IDS_OPTIONS_WALLPAPER_STRETCH_LAYOUT); |
| 201 SET_STRING("connectionFailed", IDS_WALLPAPER_MANAGER_ACCESS_FAIL); | 198 SET_STRING("connectionFailed", IDS_WALLPAPER_MANAGER_ACCESS_FAIL); |
| 202 SET_STRING("downloadFailed", IDS_WALLPAPER_MANAGER_DOWNLOAD_FAIL); | 199 SET_STRING("downloadFailed", IDS_WALLPAPER_MANAGER_DOWNLOAD_FAIL); |
| 203 SET_STRING("downloadCanceled", IDS_WALLPAPER_MANAGER_DOWNLOAD_CANCEL); | 200 SET_STRING("downloadCanceled", IDS_WALLPAPER_MANAGER_DOWNLOAD_CANCEL); |
| 204 SET_STRING("customWallpaperWarning", | 201 SET_STRING("customWallpaperWarning", |
| 205 IDS_WALLPAPER_MANAGER_SHOW_CUSTOM_WALLPAPER_ON_START_WARNING); | 202 IDS_WALLPAPER_MANAGER_SHOW_CUSTOM_WALLPAPER_ON_START_WARNING); |
| 206 SET_STRING("accessFileFailure", IDS_WALLPAPER_MANAGER_ACCESS_FILE_FAILURE); | 203 SET_STRING("accessFileFailure", IDS_WALLPAPER_MANAGER_ACCESS_FILE_FAILURE); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 chromeos::WallpaperInfo info = { | 499 chromeos::WallpaperInfo info = { |
| 503 url_, | 500 url_, |
| 504 layout_, | 501 layout_, |
| 505 chromeos::User::ONLINE, | 502 chromeos::User::ONLINE, |
| 506 base::Time::Now().LocalMidnight() | 503 base::Time::Now().LocalMidnight() |
| 507 }; | 504 }; |
| 508 wallpaper_manager->SetUserWallpaperInfo(email_, info, is_persistent); | 505 wallpaper_manager->SetUserWallpaperInfo(email_, info, is_persistent); |
| 509 SendResponse(true); | 506 SendResponse(true); |
| 510 } | 507 } |
| 511 | 508 |
| 509 WallpaperPrivateResetWallpaperFunction:: | |
| 510 WallpaperPrivateResetWallpaperFunction() {} | |
| 511 | |
| 512 WallpaperPrivateResetWallpaperFunction:: | |
| 513 ~WallpaperPrivateResetWallpaperFunction() {} | |
| 514 | |
| 515 bool WallpaperPrivateResetWallpaperFunction::RunImpl() { | |
| 516 chromeos::WallpaperManager* wallpaper_manager = | |
| 517 chromeos::WallpaperManager::Get(); | |
| 518 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | |
| 519 | |
| 520 std::string email = user_manager->GetLoggedInUser()->email(); | |
| 521 wallpaper_manager->RemoveUserWallpaperInfo(email); | |
|
miket_OOO
2013/03/21 16:58:30
Could this parameter be const?
bshe
2013/03/22 15:11:57
Sorry. You mean the parameter of RemoveUserWallpap
| |
| 522 | |
| 523 chromeos::WallpaperInfo info = { | |
| 524 "", | |
| 525 ash::WALLPAPER_LAYOUT_CENTER, | |
| 526 chromeos::User::DEFAULT, | |
| 527 base::Time::Now().LocalMidnight() | |
| 528 }; | |
| 529 bool is_persistent = | |
| 530 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); | |
| 531 wallpaper_manager->SetUserWallpaperInfo(email, info, is_persistent); | |
| 532 wallpaper_manager->SetDefaultWallpaper(); | |
| 533 return true; | |
| 534 } | |
| 535 | |
| 512 WallpaperPrivateSetCustomWallpaperFunction:: | 536 WallpaperPrivateSetCustomWallpaperFunction:: |
| 513 WallpaperPrivateSetCustomWallpaperFunction() {} | 537 WallpaperPrivateSetCustomWallpaperFunction() {} |
| 514 | 538 |
| 515 WallpaperPrivateSetCustomWallpaperFunction:: | 539 WallpaperPrivateSetCustomWallpaperFunction:: |
| 516 ~WallpaperPrivateSetCustomWallpaperFunction() {} | 540 ~WallpaperPrivateSetCustomWallpaperFunction() {} |
| 517 | 541 |
| 518 bool WallpaperPrivateSetCustomWallpaperFunction::RunImpl() { | 542 bool WallpaperPrivateSetCustomWallpaperFunction::RunImpl() { |
| 519 BinaryValue* input = NULL; | 543 BinaryValue* input = NULL; |
| 520 EXTENSION_FUNCTION_VALIDATE(args_->GetBinary(0, &input)); | 544 EXTENSION_FUNCTION_VALIDATE(args_->GetBinary(0, &input)); |
| 521 | 545 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 878 this, file_list)); | 902 this, file_list)); |
| 879 } | 903 } |
| 880 | 904 |
| 881 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 905 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
| 882 const std::vector<std::string>& file_list) { | 906 const std::vector<std::string>& file_list) { |
| 883 ListValue* results = new ListValue(); | 907 ListValue* results = new ListValue(); |
| 884 results->AppendStrings(file_list); | 908 results->AppendStrings(file_list); |
| 885 SetResult(results); | 909 SetResult(results); |
| 886 SendResponse(true); | 910 SendResponse(true); |
| 887 } | 911 } |
| OLD | NEW |