OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/login/users/wallpaper/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <numeric> | 8 #include <numeric> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/common/ash_constants.h" | 12 #include "ash/common/ash_constants.h" |
13 #include "ash/common/ash_switches.h" | 13 #include "ash/common/ash_switches.h" |
14 #include "ash/desktop_background/desktop_background_controller.h" | 14 #include "ash/desktop_background/desktop_background_controller.h" |
15 #include "ash/public/interfaces/wallpaper.mojom.h" | |
15 #include "ash/shell.h" | 16 #include "ash/shell.h" |
16 #include "ash/sysui/public/interfaces/wallpaper.mojom.h" | |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/files/file_enumerator.h" | 19 #include "base/files/file_enumerator.h" |
20 #include "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
21 #include "base/files/file_util.h" | 21 #include "base/files/file_util.h" |
22 #include "base/logging.h" | 22 #include "base/logging.h" |
23 #include "base/macros.h" | 23 #include "base/macros.h" |
24 #include "base/metrics/histogram.h" | 24 #include "base/metrics/histogram.h" |
25 #include "base/path_service.h" | 25 #include "base/path_service.h" |
26 #include "base/sha1.h" | 26 #include "base/sha1.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 return wallpaper::WallpaperFilesId::FromString(result); | 170 return wallpaper::WallpaperFilesId::FromString(result); |
171 } | 171 } |
172 | 172 |
173 void SetKnownUserWallpaperFilesId( | 173 void SetKnownUserWallpaperFilesId( |
174 const AccountId& account_id, | 174 const AccountId& account_id, |
175 const wallpaper::WallpaperFilesId& wallpaper_files_id) { | 175 const wallpaper::WallpaperFilesId& wallpaper_files_id) { |
176 user_manager::known_user::SetStringPref(account_id, kWallpaperFilesId, | 176 user_manager::known_user::SetStringPref(account_id, kWallpaperFilesId, |
177 wallpaper_files_id.id()); | 177 wallpaper_files_id.id()); |
178 } | 178 } |
179 | 179 |
180 ash::sysui::mojom::WallpaperLayout WallpaperLayoutToMojo( | 180 ash::mojom::WallpaperLayout WallpaperLayoutToMojo( |
181 wallpaper::WallpaperLayout layout) { | 181 wallpaper::WallpaperLayout layout) { |
182 switch (layout) { | 182 switch (layout) { |
183 case wallpaper::WALLPAPER_LAYOUT_CENTER: | 183 case wallpaper::WALLPAPER_LAYOUT_CENTER: |
184 return ash::sysui::mojom::WallpaperLayout::CENTER; | 184 return ash::mojom::WallpaperLayout::CENTER; |
185 case wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED: | 185 case wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED: |
186 return ash::sysui::mojom::WallpaperLayout::CENTER_CROPPED; | 186 return ash::mojom::WallpaperLayout::CENTER_CROPPED; |
187 case wallpaper::WALLPAPER_LAYOUT_STRETCH: | 187 case wallpaper::WALLPAPER_LAYOUT_STRETCH: |
188 return ash::sysui::mojom::WallpaperLayout::STRETCH; | 188 return ash::mojom::WallpaperLayout::STRETCH; |
189 case wallpaper::WALLPAPER_LAYOUT_TILE: | 189 case wallpaper::WALLPAPER_LAYOUT_TILE: |
190 return ash::sysui::mojom::WallpaperLayout::TILE; | 190 return ash::mojom::WallpaperLayout::TILE; |
191 case wallpaper::NUM_WALLPAPER_LAYOUT: | 191 case wallpaper::NUM_WALLPAPER_LAYOUT: |
192 NOTREACHED(); | 192 NOTREACHED(); |
193 return ash::sysui::mojom::WallpaperLayout::CENTER; | 193 return ash::mojom::WallpaperLayout::CENTER; |
194 } | 194 } |
195 NOTREACHED(); | 195 NOTREACHED(); |
196 return ash::sysui::mojom::WallpaperLayout::CENTER; | 196 return ash::mojom::WallpaperLayout::CENTER; |
197 } | 197 } |
198 | 198 |
199 // A helper to set the wallpaper image for Ash and Mash. | 199 // A helper to set the wallpaper image for Ash and Mash. |
200 void SetWallpaper(const gfx::ImageSkia& image, | 200 void SetWallpaper(const gfx::ImageSkia& image, |
201 wallpaper::WallpaperLayout layout) { | 201 wallpaper::WallpaperLayout layout) { |
202 if (chrome::IsRunningInMash()) { | 202 if (chrome::IsRunningInMash()) { |
203 shell::Connector* connector = | 203 shell::Connector* connector = |
204 content::MojoShellConnection::GetForProcess()->GetConnector(); | 204 content::MojoShellConnection::GetForProcess()->GetConnector(); |
205 ash::sysui::mojom::WallpaperControllerPtr wallpaper_controller; | 205 ash::mojom::WallpaperControllerPtr wallpaper_controller; |
206 connector->ConnectToInterface("mojo:ash_sysui", &wallpaper_controller); | 206 connector->ConnectToInterface("mojo:ash", &wallpaper_controller); |
msw
2016/08/09 23:31:23
Ditto, this connection is just a placeholder for n
| |
207 wallpaper_controller->SetWallpaper(*image.bitmap(), | 207 wallpaper_controller->SetWallpaper(*image.bitmap(), |
208 WallpaperLayoutToMojo(layout)); | 208 WallpaperLayoutToMojo(layout)); |
209 return; | 209 return; |
210 } | 210 } |
211 // Avoid loading unnecessary wallpapers in tests without a shell instance. | 211 // Avoid loading unnecessary wallpapers in tests without a shell instance. |
212 if (ash::Shell::HasInstance()) { | 212 if (ash::Shell::HasInstance()) { |
213 ash::Shell::GetInstance() | 213 ash::Shell::GetInstance() |
214 ->desktop_background_controller() | 214 ->desktop_background_controller() |
215 ->SetWallpaperImage(image, layout); | 215 ->SetWallpaperImage(image, layout); |
216 } | 216 } |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1166 &stored_value)) { | 1166 &stored_value)) { |
1167 return wallpaper::WallpaperFilesId::FromString(stored_value); | 1167 return wallpaper::WallpaperFilesId::FromString(stored_value); |
1168 } | 1168 } |
1169 const std::string& old_id = account_id.GetUserEmail(); // Migrated | 1169 const std::string& old_id = account_id.GetUserEmail(); // Migrated |
1170 const wallpaper::WallpaperFilesId files_id = HashWallpaperFilesIdStr(old_id); | 1170 const wallpaper::WallpaperFilesId files_id = HashWallpaperFilesIdStr(old_id); |
1171 SetKnownUserWallpaperFilesId(account_id, files_id); | 1171 SetKnownUserWallpaperFilesId(account_id, files_id); |
1172 return files_id; | 1172 return files_id; |
1173 } | 1173 } |
1174 | 1174 |
1175 } // namespace chromeos | 1175 } // namespace chromeos |
OLD | NEW |