| 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 chromeos::WallpaperInfo info = { | 506 chromeos::WallpaperInfo info = { |
| 510 url_, | 507 url_, |
| 511 layout_, | 508 layout_, |
| 512 chromeos::User::ONLINE, | 509 chromeos::User::ONLINE, |
| 513 base::Time::Now().LocalMidnight() | 510 base::Time::Now().LocalMidnight() |
| 514 }; | 511 }; |
| 515 wallpaper_manager->SetUserWallpaperInfo(email_, info, is_persistent); | 512 wallpaper_manager->SetUserWallpaperInfo(email_, info, is_persistent); |
| 516 SendResponse(true); | 513 SendResponse(true); |
| 517 } | 514 } |
| 518 | 515 |
| 516 WallpaperPrivateResetWallpaperFunction:: |
| 517 WallpaperPrivateResetWallpaperFunction() {} |
| 518 |
| 519 WallpaperPrivateResetWallpaperFunction:: |
| 520 ~WallpaperPrivateResetWallpaperFunction() {} |
| 521 |
| 522 bool WallpaperPrivateResetWallpaperFunction::RunImpl() { |
| 523 chromeos::WallpaperManager* wallpaper_manager = |
| 524 chromeos::WallpaperManager::Get(); |
| 525 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
| 526 |
| 527 std::string email = user_manager->GetLoggedInUser()->email(); |
| 528 wallpaper_manager->RemoveUserWallpaperInfo(email); |
| 529 |
| 530 chromeos::WallpaperInfo info = { |
| 531 "", |
| 532 ash::WALLPAPER_LAYOUT_CENTER, |
| 533 chromeos::User::DEFAULT, |
| 534 base::Time::Now().LocalMidnight() |
| 535 }; |
| 536 bool is_persistent = |
| 537 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 538 wallpaper_manager->SetUserWallpaperInfo(email, info, is_persistent); |
| 539 wallpaper_manager->SetDefaultWallpaper(); |
| 540 return true; |
| 541 } |
| 542 |
| 519 WallpaperPrivateSetCustomWallpaperFunction:: | 543 WallpaperPrivateSetCustomWallpaperFunction:: |
| 520 WallpaperPrivateSetCustomWallpaperFunction() {} | 544 WallpaperPrivateSetCustomWallpaperFunction() {} |
| 521 | 545 |
| 522 WallpaperPrivateSetCustomWallpaperFunction:: | 546 WallpaperPrivateSetCustomWallpaperFunction:: |
| 523 ~WallpaperPrivateSetCustomWallpaperFunction() {} | 547 ~WallpaperPrivateSetCustomWallpaperFunction() {} |
| 524 | 548 |
| 525 bool WallpaperPrivateSetCustomWallpaperFunction::RunImpl() { | 549 bool WallpaperPrivateSetCustomWallpaperFunction::RunImpl() { |
| 526 BinaryValue* input = NULL; | 550 BinaryValue* input = NULL; |
| 527 EXTENSION_FUNCTION_VALIDATE(args_->GetBinary(0, &input)); | 551 EXTENSION_FUNCTION_VALIDATE(args_->GetBinary(0, &input)); |
| 528 | 552 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 this, file_list)); | 909 this, file_list)); |
| 886 } | 910 } |
| 887 | 911 |
| 888 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 912 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
| 889 const std::vector<std::string>& file_list) { | 913 const std::vector<std::string>& file_list) { |
| 890 ListValue* results = new ListValue(); | 914 ListValue* results = new ListValue(); |
| 891 results->AppendStrings(file_list); | 915 results->AppendStrings(file_list); |
| 892 SetResult(results); | 916 SetResult(results); |
| 893 SendResponse(true); | 917 SendResponse(true); |
| 894 } | 918 } |
| OLD | NEW |