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 <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/files/file_util.h" | 22 #include "base/files/file_util.h" |
23 #include "base/macros.h" | 23 #include "base/macros.h" |
24 #include "base/memory/ptr_util.h" | 24 #include "base/memory/ptr_util.h" |
25 #include "base/memory/ref_counted_memory.h" | 25 #include "base/memory/ref_counted_memory.h" |
26 #include "base/metrics/histogram_macros.h" | 26 #include "base/metrics/histogram_macros.h" |
27 #include "base/path_service.h" | 27 #include "base/path_service.h" |
28 #include "base/strings/string_number_conversions.h" | 28 #include "base/strings/string_number_conversions.h" |
29 #include "base/strings/stringprintf.h" | 29 #include "base/strings/stringprintf.h" |
30 #include "base/threading/sequenced_worker_pool.h" | 30 #include "base/threading/sequenced_worker_pool.h" |
31 #include "base/threading/worker_pool.h" | 31 #include "base/threading/worker_pool.h" |
| 32 #include "base/values.h" |
32 #include "chrome/browser/browser_process.h" | 33 #include "chrome/browser/browser_process.h" |
33 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 34 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
34 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 35 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
35 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
36 #include "chrome/browser/sync/profile_sync_service_factory.h" | 37 #include "chrome/browser/sync/profile_sync_service_factory.h" |
37 #include "chrome/browser/ui/ash/ash_util.h" | 38 #include "chrome/browser/ui/ash/ash_util.h" |
38 #include "chrome/common/chrome_paths.h" | 39 #include "chrome/common/chrome_paths.h" |
39 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
40 #include "chrome/grit/generated_resources.h" | 41 #include "chrome/grit/generated_resources.h" |
41 #include "chromeos/chromeos_switches.h" | 42 #include "chromeos/chromeos_switches.h" |
42 #include "components/browser_sync/profile_sync_service.h" | 43 #include "components/browser_sync/profile_sync_service.h" |
43 #include "components/prefs/pref_service.h" | 44 #include "components/prefs/pref_service.h" |
44 #include "components/strings/grit/components_strings.h" | 45 #include "components/strings/grit/components_strings.h" |
45 #include "components/user_manager/user.h" | 46 #include "components/user_manager/user.h" |
46 #include "components/user_manager/user_manager.h" | 47 #include "components/user_manager/user_manager.h" |
47 #include "components/wallpaper/wallpaper_layout.h" | 48 #include "components/wallpaper/wallpaper_layout.h" |
48 #include "content/public/browser/browser_thread.h" | 49 #include "content/public/browser/browser_thread.h" |
49 #include "extensions/browser/event_router.h" | 50 #include "extensions/browser/event_router.h" |
50 #include "ui/base/l10n/l10n_util.h" | 51 #include "ui/base/l10n/l10n_util.h" |
51 #include "ui/base/webui/web_ui_util.h" | 52 #include "ui/base/webui/web_ui_util.h" |
52 #include "ui/strings/grit/app_locale_settings.h" | 53 #include "ui/strings/grit/app_locale_settings.h" |
53 #include "url/gurl.h" | 54 #include "url/gurl.h" |
54 | 55 |
55 using base::BinaryValue; | 56 using base::Value; |
56 using content::BrowserThread; | 57 using content::BrowserThread; |
57 | 58 |
58 namespace wallpaper_base = extensions::api::wallpaper; | 59 namespace wallpaper_base = extensions::api::wallpaper; |
59 namespace wallpaper_private = extensions::api::wallpaper_private; | 60 namespace wallpaper_private = extensions::api::wallpaper_private; |
60 namespace set_wallpaper_if_exists = wallpaper_private::SetWallpaperIfExists; | 61 namespace set_wallpaper_if_exists = wallpaper_private::SetWallpaperIfExists; |
61 namespace set_wallpaper = wallpaper_private::SetWallpaper; | 62 namespace set_wallpaper = wallpaper_private::SetWallpaper; |
62 namespace set_custom_wallpaper = wallpaper_private::SetCustomWallpaper; | 63 namespace set_custom_wallpaper = wallpaper_private::SetCustomWallpaper; |
63 namespace set_custom_wallpaper_layout = | 64 namespace set_custom_wallpaper_layout = |
64 wallpaper_private::SetCustomWallpaperLayout; | 65 wallpaper_private::SetCustomWallpaperLayout; |
65 namespace get_thumbnail = wallpaper_private::GetThumbnail; | 66 namespace get_thumbnail = wallpaper_private::GetThumbnail; |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 &data, NULL); | 692 &data, NULL); |
692 BrowserThread::PostTask( | 693 BrowserThread::PostTask( |
693 BrowserThread::UI, FROM_HERE, | 694 BrowserThread::UI, FROM_HERE, |
694 base::Bind( | 695 base::Bind( |
695 &WallpaperPrivateSetCustomWallpaperFunction::ThumbnailGenerated, this, | 696 &WallpaperPrivateSetCustomWallpaperFunction::ThumbnailGenerated, this, |
696 base::RetainedRef(data))); | 697 base::RetainedRef(data))); |
697 } | 698 } |
698 | 699 |
699 void WallpaperPrivateSetCustomWallpaperFunction::ThumbnailGenerated( | 700 void WallpaperPrivateSetCustomWallpaperFunction::ThumbnailGenerated( |
700 base::RefCountedBytes* data) { | 701 base::RefCountedBytes* data) { |
701 SetResult(BinaryValue::CreateWithCopiedBuffer( | 702 SetResult(Value::CreateWithCopiedBuffer( |
702 reinterpret_cast<const char*>(data->front()), data->size())); | 703 reinterpret_cast<const char*>(data->front()), data->size())); |
703 SendResponse(true); | 704 SendResponse(true); |
704 } | 705 } |
705 | 706 |
706 WallpaperPrivateSetCustomWallpaperLayoutFunction:: | 707 WallpaperPrivateSetCustomWallpaperLayoutFunction:: |
707 WallpaperPrivateSetCustomWallpaperLayoutFunction() {} | 708 WallpaperPrivateSetCustomWallpaperLayoutFunction() {} |
708 | 709 |
709 WallpaperPrivateSetCustomWallpaperLayoutFunction:: | 710 WallpaperPrivateSetCustomWallpaperLayoutFunction:: |
710 ~WallpaperPrivateSetCustomWallpaperLayoutFunction() {} | 711 ~WallpaperPrivateSetCustomWallpaperLayoutFunction() {} |
711 | 712 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 file_name.c_str())); | 817 file_name.c_str())); |
817 SendResponse(false); | 818 SendResponse(false); |
818 } | 819 } |
819 | 820 |
820 void WallpaperPrivateGetThumbnailFunction::FileNotLoaded() { | 821 void WallpaperPrivateGetThumbnailFunction::FileNotLoaded() { |
821 SendResponse(true); | 822 SendResponse(true); |
822 } | 823 } |
823 | 824 |
824 void WallpaperPrivateGetThumbnailFunction::FileLoaded( | 825 void WallpaperPrivateGetThumbnailFunction::FileLoaded( |
825 const std::string& data) { | 826 const std::string& data) { |
826 SetResult(BinaryValue::CreateWithCopiedBuffer(data.c_str(), data.size())); | 827 SetResult(Value::CreateWithCopiedBuffer(data.c_str(), data.size())); |
827 SendResponse(true); | 828 SendResponse(true); |
828 } | 829 } |
829 | 830 |
830 void WallpaperPrivateGetThumbnailFunction::Get(const base::FilePath& path) { | 831 void WallpaperPrivateGetThumbnailFunction::Get(const base::FilePath& path) { |
831 wallpaper::AssertCalledOnWallpaperSequence(); | 832 wallpaper::AssertCalledOnWallpaperSequence(); |
832 std::string data; | 833 std::string data; |
833 if (GetData(path, &data)) { | 834 if (GetData(path, &data)) { |
834 if (data.empty()) { | 835 if (data.empty()) { |
835 BrowserThread::PostTask( | 836 BrowserThread::PostTask( |
836 BrowserThread::UI, FROM_HERE, | 837 BrowserThread::UI, FROM_HERE, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 WallpaperPrivateRecordWallpaperUMAFunction::Run() { | 957 WallpaperPrivateRecordWallpaperUMAFunction::Run() { |
957 std::unique_ptr<record_wallpaper_uma::Params> params( | 958 std::unique_ptr<record_wallpaper_uma::Params> params( |
958 record_wallpaper_uma::Params::Create(*args_)); | 959 record_wallpaper_uma::Params::Create(*args_)); |
959 EXTENSION_FUNCTION_VALIDATE(params); | 960 EXTENSION_FUNCTION_VALIDATE(params); |
960 | 961 |
961 user_manager::User::WallpaperType source = getWallpaperType(params->source); | 962 user_manager::User::WallpaperType source = getWallpaperType(params->source); |
962 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Source", source, | 963 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Source", source, |
963 user_manager::User::WALLPAPER_TYPE_COUNT); | 964 user_manager::User::WALLPAPER_TYPE_COUNT); |
964 return RespondNow(NoArguments()); | 965 return RespondNow(NoArguments()); |
965 } | 966 } |
OLD | NEW |