Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(579)

Side by Side Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc

Issue 2318223003: mash: Migrate wallpaper controllers to ash/common. (Closed)
Patch Set: Fix nit. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/common/wallpaper/wallpaper_controller.h"
15 #include "ash/common/wm_shell.h"
14 #include "ash/public/interfaces/wallpaper.mojom.h" 16 #include "ash/public/interfaces/wallpaper.mojom.h"
15 #include "ash/shell.h"
16 #include "ash/wallpaper/wallpaper_controller.h"
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/bind_helpers.h" 18 #include "base/bind_helpers.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/files/file_enumerator.h" 20 #include "base/files/file_enumerator.h"
21 #include "base/files/file_path.h" 21 #include "base/files/file_path.h"
22 #include "base/files/file_util.h" 22 #include "base/files/file_util.h"
23 #include "base/logging.h" 23 #include "base/logging.h"
24 #include "base/macros.h" 24 #include "base/macros.h"
25 #include "base/metrics/histogram_macros.h" 25 #include "base/metrics/histogram_macros.h"
26 #include "base/path_service.h" 26 #include "base/path_service.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 if (chrome::IsRunningInMash()) { 213 if (chrome::IsRunningInMash()) {
214 shell::Connector* connector = 214 shell::Connector* connector =
215 content::MojoShellConnection::GetForProcess()->GetConnector(); 215 content::MojoShellConnection::GetForProcess()->GetConnector();
216 ash::mojom::WallpaperControllerPtr wallpaper_controller; 216 ash::mojom::WallpaperControllerPtr wallpaper_controller;
217 connector->ConnectToInterface("mojo:ash", &wallpaper_controller); 217 connector->ConnectToInterface("mojo:ash", &wallpaper_controller);
218 wallpaper_controller->SetWallpaper(*image.bitmap(), 218 wallpaper_controller->SetWallpaper(*image.bitmap(),
219 WallpaperLayoutToMojo(layout)); 219 WallpaperLayoutToMojo(layout));
220 return; 220 return;
221 } 221 }
222 // Avoid loading unnecessary wallpapers in tests without a shell instance. 222 // Avoid loading unnecessary wallpapers in tests without a shell instance.
223 if (ash::Shell::HasInstance()) { 223 if (ash::WmShell::HasInstance()) {
224 ash::Shell::GetInstance()->wallpaper_controller()->SetWallpaperImage( 224 ash::WmShell::Get()->wallpaper_controller()->SetWallpaperImage(image,
225 image, layout); 225 layout);
226 } 226 }
227 } 227 }
228 228
229 } // namespace 229 } // namespace
230 230
231 // This is "wallpaper either scheduled to load, or loading right now". 231 // This is "wallpaper either scheduled to load, or loading right now".
232 // 232 //
233 // While enqueued, it defines moment in the future, when it will be loaded. 233 // While enqueued, it defines moment in the future, when it will be loaded.
234 // Enqueued but not started request might be updated by subsequent load 234 // Enqueued but not started request might be updated by subsequent load
235 // request. Therefore it's created empty, and updated being enqueued. 235 // request. Therefore it's created empty, and updated being enqueued.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 CrosSettings::Get()->AddSettingsObserver( 416 CrosSettings::Get()->AddSettingsObserver(
417 kAccountsPrefShowUserNamesOnSignIn, 417 kAccountsPrefShowUserNamesOnSignIn,
418 base::Bind(&WallpaperManager::InitializeRegisteredDeviceWallpaper, 418 base::Bind(&WallpaperManager::InitializeRegisteredDeviceWallpaper,
419 weak_factory_.GetWeakPtr())); 419 weak_factory_.GetWeakPtr()));
420 } 420 }
421 421
422 void WallpaperManager::EnsureLoggedInUserWallpaperLoaded() { 422 void WallpaperManager::EnsureLoggedInUserWallpaperLoaded() {
423 // Some browser tests do not have a shell instance. As no wallpaper is needed 423 // Some browser tests do not have a shell instance. As no wallpaper is needed
424 // in these tests anyway, avoid loading one, preventing crashes and speeding 424 // in these tests anyway, avoid loading one, preventing crashes and speeding
425 // up the tests. 425 // up the tests.
426 if (!ash::Shell::HasInstance()) 426 if (!ash::WmShell::HasInstance())
427 return; 427 return;
428 428
429 WallpaperInfo info; 429 WallpaperInfo info;
430 if (GetLoggedInUserWallpaperInfo(&info)) { 430 if (GetLoggedInUserWallpaperInfo(&info)) {
431 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", info.type, 431 UMA_HISTOGRAM_ENUMERATION("Ash.Wallpaper.Type", info.type,
432 user_manager::User::WALLPAPER_TYPE_COUNT); 432 user_manager::User::WALLPAPER_TYPE_COUNT);
433 if (info == current_user_wallpaper_info_) 433 if (info == current_user_wallpaper_info_)
434 return; 434 return;
435 } 435 }
436 SetUserWallpaperNow( 436 SetUserWallpaperNow(
(...skipping 21 matching lines...) Expand all
458 // used here to determine if current user is guest. 458 // used here to determine if current user is guest.
459 return; 459 return;
460 } 460 }
461 461
462 if (command_line->HasSwitch(::switches::kTestType)) 462 if (command_line->HasSwitch(::switches::kTestType))
463 WizardController::SetZeroDelays(); 463 WizardController::SetZeroDelays();
464 464
465 // Zero delays is also set in autotests. 465 // Zero delays is also set in autotests.
466 if (WizardController::IsZeroDelayEnabled()) { 466 if (WizardController::IsZeroDelayEnabled()) {
467 // Ensure tests have some sort of wallpaper. 467 // Ensure tests have some sort of wallpaper.
468 ash::Shell::GetInstance()->wallpaper_controller()->CreateEmptyWallpaper(); 468 ash::WmShell::Get()->wallpaper_controller()->CreateEmptyWallpaper();
469 return; 469 return;
470 } 470 }
471 471
472 if (!user_manager->IsUserLoggedIn()) { 472 if (!user_manager->IsUserLoggedIn()) {
473 if (!StartupUtils::IsDeviceRegistered()) 473 if (!StartupUtils::IsDeviceRegistered())
474 SetDefaultWallpaperDelayed(login::SignInAccountId()); 474 SetDefaultWallpaperDelayed(login::SignInAccountId());
475 else 475 else
476 InitializeRegisteredDeviceWallpaper(); 476 InitializeRegisteredDeviceWallpaper();
477 return; 477 return;
478 } 478 }
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 1135
1136 void WallpaperManager::SetDefaultWallpaperPath( 1136 void WallpaperManager::SetDefaultWallpaperPath(
1137 const base::FilePath& default_small_wallpaper_file, 1137 const base::FilePath& default_small_wallpaper_file,
1138 std::unique_ptr<gfx::ImageSkia> small_wallpaper_image, 1138 std::unique_ptr<gfx::ImageSkia> small_wallpaper_image,
1139 const base::FilePath& default_large_wallpaper_file, 1139 const base::FilePath& default_large_wallpaper_file,
1140 std::unique_ptr<gfx::ImageSkia> large_wallpaper_image) { 1140 std::unique_ptr<gfx::ImageSkia> large_wallpaper_image) {
1141 default_small_wallpaper_file_ = default_small_wallpaper_file; 1141 default_small_wallpaper_file_ = default_small_wallpaper_file;
1142 default_large_wallpaper_file_ = default_large_wallpaper_file; 1142 default_large_wallpaper_file_ = default_large_wallpaper_file;
1143 1143
1144 ash::WallpaperController* controller = 1144 ash::WallpaperController* controller =
1145 ash::Shell::GetInstance()->wallpaper_controller(); 1145 ash::WmShell::Get()->wallpaper_controller();
1146 1146
1147 // |need_update_screen| is true if the previous default wallpaper is visible 1147 // |need_update_screen| is true if the previous default wallpaper is visible
1148 // now, so we need to update wallpaper on the screen. 1148 // now, so we need to update wallpaper on the screen.
1149 // 1149 //
1150 // Layout is ignored here, so wallpaper::WALLPAPER_LAYOUT_CENTER is used 1150 // Layout is ignored here, so wallpaper::WALLPAPER_LAYOUT_CENTER is used
1151 // as a placeholder only. 1151 // as a placeholder only.
1152 const bool need_update_screen = 1152 const bool need_update_screen =
1153 default_wallpaper_image_.get() && 1153 default_wallpaper_image_.get() &&
1154 controller->WallpaperIsAlreadyLoaded(default_wallpaper_image_->image(), 1154 controller->WallpaperIsAlreadyLoaded(default_wallpaper_image_->image(),
1155 false /* compare_layouts */, 1155 false /* compare_layouts */,
(...skipping 25 matching lines...) Expand all
1181 &stored_value)) { 1181 &stored_value)) {
1182 return wallpaper::WallpaperFilesId::FromString(stored_value); 1182 return wallpaper::WallpaperFilesId::FromString(stored_value);
1183 } 1183 }
1184 const std::string& old_id = account_id.GetUserEmail(); // Migrated 1184 const std::string& old_id = account_id.GetUserEmail(); // Migrated
1185 const wallpaper::WallpaperFilesId files_id = HashWallpaperFilesIdStr(old_id); 1185 const wallpaper::WallpaperFilesId files_id = HashWallpaperFilesIdStr(old_id);
1186 SetKnownUserWallpaperFilesId(account_id, files_id); 1186 SetKnownUserWallpaperFilesId(account_id, files_id);
1187 return files_id; 1187 return files_id;
1188 } 1188 }
1189 1189
1190 } // namespace chromeos 1190 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698