OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/arc/wallpaper/arc_wallpaper_service.h" | 5 #include "chrome/browser/chromeos/arc/wallpaper/arc_wallpaper_service.h" |
6 | 6 |
7 #include "ash/common/wallpaper/wallpaper_controller.h" | 7 #include "ash/common/wallpaper/wallpaper_controller.h" |
8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/task_runner_util.h" | 11 #include "base/task_runner_util.h" |
12 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 12 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
13 #include "components/arc/arc_bridge_service.h" | 13 #include "components/arc/arc_bridge_service.h" |
14 #include "components/signin/core/account_id/account_id.h" | 14 #include "components/signin/core/account_id/account_id.h" |
15 #include "components/user_manager/user_manager.h" | 15 #include "components/user_manager/user_manager.h" |
16 #include "components/wallpaper/wallpaper_files_id.h" | 16 #include "components/wallpaper/wallpaper_files_id.h" |
17 #include "components/wallpaper/wallpaper_layout.h" | 17 #include "components/wallpaper/wallpaper_layout.h" |
18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
19 #include "ui/gfx/codec/png_codec.h" | 19 #include "ui/gfx/codec/png_codec.h" |
| 20 #include "ui/gfx/geometry/size.h" |
20 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
21 #include "ui/gfx/image/image_skia.h" | 22 #include "ui/gfx/image/image_skia.h" |
22 #include "ui/gfx/image/image_util.h" | 23 #include "ui/gfx/image/image_util.h" |
23 | 24 |
24 using user_manager::UserManager; | 25 using user_manager::UserManager; |
25 | 26 |
26 namespace arc { | 27 namespace arc { |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 void ArcWallpaperService::OnInstanceClosed() { | 103 void ArcWallpaperService::OnInstanceClosed() { |
103 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 104 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
104 ash::WallpaperController* wc = GetWallpaperController(); | 105 ash::WallpaperController* wc = GetWallpaperController(); |
105 if (wc) | 106 if (wc) |
106 wc->RemoveObserver(this); | 107 wc->RemoveObserver(this); |
107 } | 108 } |
108 | 109 |
109 void ArcWallpaperService::SetWallpaper(const std::vector<uint8_t>& data) { | 110 void ArcWallpaperService::SetWallpaper(const std::vector<uint8_t>& data) { |
110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 111 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
111 ImageDecoder::Cancel(this); | 112 ImageDecoder::Cancel(this); |
112 ImageDecoder::StartWithOptions(this, data, ImageDecoder::DEFAULT_CODEC, true); | 113 ImageDecoder::StartWithOptions(this, data, ImageDecoder::DEFAULT_CODEC, true, |
| 114 gfx::Size()); |
113 } | 115 } |
114 | 116 |
115 void ArcWallpaperService::GetWallpaper(const GetWallpaperCallback& callback) { | 117 void ArcWallpaperService::GetWallpaper(const GetWallpaperCallback& callback) { |
116 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 118 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
117 ash::WallpaperController* wc = ash::WmShell::Get()->wallpaper_controller(); | 119 ash::WallpaperController* wc = ash::WmShell::Get()->wallpaper_controller(); |
118 gfx::ImageSkia wallpaper = wc->GetWallpaper(); | 120 gfx::ImageSkia wallpaper = wc->GetWallpaper(); |
119 base::PostTaskAndReplyWithResult( | 121 base::PostTaskAndReplyWithResult( |
120 content::BrowserThread::GetBlockingPool(), FROM_HERE, | 122 content::BrowserThread::GetBlockingPool(), FROM_HERE, |
121 base::Bind(&EncodeImagePng, wallpaper), callback); | 123 base::Bind(&EncodeImagePng, wallpaper), callback); |
122 } | 124 } |
(...skipping 11 matching lines...) Expand all Loading... |
134 void ArcWallpaperService::OnWallpaperDataChanged() { | 136 void ArcWallpaperService::OnWallpaperDataChanged() { |
135 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 137 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
136 auto* wallpaper_instance = ARC_GET_INSTANCE_FOR_METHOD( | 138 auto* wallpaper_instance = ARC_GET_INSTANCE_FOR_METHOD( |
137 arc_bridge_service()->wallpaper(), OnWallpaperChanged); | 139 arc_bridge_service()->wallpaper(), OnWallpaperChanged); |
138 if (!wallpaper_instance) | 140 if (!wallpaper_instance) |
139 return; | 141 return; |
140 wallpaper_instance->OnWallpaperChanged(); | 142 wallpaper_instance->OnWallpaperChanged(); |
141 } | 143 } |
142 | 144 |
143 } // namespace arc | 145 } // namespace arc |
OLD | NEW |