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

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

Issue 2931063004: Extract colors from wallpaper and dynamically update login screen overlay (Closed)
Patch Set: Move unrelated style changes to a separate CL Created 3 years, 6 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 <utility> 7 #include <utility>
8 8
9 #include "ash/ash_constants.h" 9 #include "ash/ash_constants.h"
10 #include "ash/public/cpp/shelf_types.h" 10 #include "ash/public/cpp/shelf_types.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 void SetKnownUserWallpaperFilesId( 197 void SetKnownUserWallpaperFilesId(
198 const AccountId& account_id, 198 const AccountId& account_id,
199 const wallpaper::WallpaperFilesId& wallpaper_files_id) { 199 const wallpaper::WallpaperFilesId& wallpaper_files_id) {
200 user_manager::known_user::SetStringPref(account_id, kWallpaperFilesId, 200 user_manager::known_user::SetStringPref(account_id, kWallpaperFilesId,
201 wallpaper_files_id.id()); 201 wallpaper_files_id.id());
202 } 202 }
203 203
204 // A helper to set the wallpaper image for Classic Ash and Mash. 204 // A helper to set the wallpaper image for Classic Ash and Mash.
205 void SetWallpaper(const gfx::ImageSkia& image, 205 void SetWallpaper(const gfx::ImageSkia& image,
206 wallpaper::WallpaperLayout layout) { 206 wallpaper::WallpaperLayout layout) {
207 WallpaperManager::Get()->CalculateProminentColor(image);
207 if (ash_util::IsRunningInMash()) { 208 if (ash_util::IsRunningInMash()) {
208 // In mash, connect to the WallpaperController interface via mojo. 209 // In mash, connect to the WallpaperController interface via mojo.
209 service_manager::Connector* connector = 210 service_manager::Connector* connector =
210 content::ServiceManagerConnection::GetForProcess()->GetConnector(); 211 content::ServiceManagerConnection::GetForProcess()->GetConnector();
211 if (!connector) 212 if (!connector)
212 return; 213 return;
213 214
214 ash::mojom::WallpaperControllerPtr wallpaper_controller; 215 ash::mojom::WallpaperControllerPtr wallpaper_controller;
215 connector->BindInterface(ash::mojom::kServiceName, &wallpaper_controller); 216 connector->BindInterface(ash::mojom::kServiceName, &wallpaper_controller);
216 // TODO(crbug.com/655875): Optimize ash wallpaper transport; avoid sending 217 // TODO(crbug.com/655875): Optimize ash wallpaper transport; avoid sending
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 421
421 bool WallpaperManager::IsPendingWallpaper(uint32_t image_id) { 422 bool WallpaperManager::IsPendingWallpaper(uint32_t image_id) {
422 for (size_t i = 0; i < loading_.size(); ++i) { 423 for (size_t i = 0; i < loading_.size(); ++i) {
423 if (loading_[i]->GetImageId() == image_id) { 424 if (loading_[i]->GetImageId() == image_id) {
424 return true; 425 return true;
425 } 426 }
426 } 427 }
427 return false; 428 return false;
428 } 429 }
429 430
431 void WallpaperManager::CalculateProminentColor(const gfx::ImageSkia& image) {
432 // Cancel in-flight color calculations, if any.
433 if (color_calculator_) {
434 color_calculator_->RemoveObserver(this);
435 color_calculator_.reset();
436 }
437
438 color_calculator_ = base::MakeUnique<wallpaper::WallpaperColorCalculator>(
439 image, color_utils::LumaRange::DARK, color_utils::SaturationRange::MUTED,
xdai1 2017/06/13 23:04:24 Is the color scheme for the login screen fixed? Ca
Wenzhao (Colin) Zang 2017/06/14 00:44:50 The color scheme for the shelf is derived from the
xdai1 2017/06/14 18:23:40 The code logic of WallpaperColorCalculator here is
xiyuan 2017/06/14 18:28:26 WallpaperController is part of ash. If we do that,
Wenzhao (Colin) Zang 2017/06/15 05:02:08 I understand the concerns. Before writing this CL
440 task_runner_);
441 color_calculator_->AddObserver(this);
442 if (!color_calculator_->StartCalculation()) {
xdai1 2017/06/13 23:04:24 If the calculation fails to be initiated, why do w
Wenzhao (Colin) Zang 2017/06/14 00:44:50 Because the front end needs to be notified of the
443 prominent_color_.reset();
444 for (auto& observer : observers_)
445 observer.OnColorCalculationComplete();
446 }
447 }
448
430 WallpaperManager::WallpaperResolution 449 WallpaperManager::WallpaperResolution
431 WallpaperManager::GetAppropriateResolution() { 450 WallpaperManager::GetAppropriateResolution() {
432 DCHECK_CURRENTLY_ON(BrowserThread::UI); 451 DCHECK_CURRENTLY_ON(BrowserThread::UI);
433 gfx::Size size = ash::WallpaperController::GetMaxDisplaySizeInNative(); 452 gfx::Size size = ash::WallpaperController::GetMaxDisplaySizeInNative();
434 return (size.width() > wallpaper::kSmallWallpaperMaxWidth || 453 return (size.width() > wallpaper::kSmallWallpaperMaxWidth ||
435 size.height() > wallpaper::kSmallWallpaperMaxHeight) 454 size.height() > wallpaper::kSmallWallpaperMaxHeight)
436 ? WALLPAPER_RESOLUTION_LARGE 455 ? WALLPAPER_RESOLUTION_LARGE
437 : WALLPAPER_RESOLUTION_SMALL; 456 : WALLPAPER_RESOLUTION_SMALL;
438 } 457 }
439 458
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 window_observer_.Add(gained_active); 923 window_observer_.Add(gained_active);
905 } 924 }
906 } 925 }
907 926
908 void WallpaperManager::OnWindowDestroying(aura::Window* window) { 927 void WallpaperManager::OnWindowDestroying(aura::Window* window) {
909 window_observer_.Remove(window); 928 window_observer_.Remove(window);
910 chromeos::WallpaperWindowStateManager::RestoreWindows( 929 chromeos::WallpaperWindowStateManager::RestoreWindows(
911 user_manager::UserManager::Get()->GetActiveUser()->username_hash()); 930 user_manager::UserManager::Get()->GetActiveUser()->username_hash());
912 } 931 }
913 932
933 void WallpaperManager::OnColorCalculationComplete() {
934 if (color_calculator_->prominent_color() == prominent_color_)
935 return;
xiyuan 2017/06/13 23:23:48 |color_calculator_|.reset() is skipped when this h
Wenzhao (Colin) Zang 2017/06/14 00:44:50 Done. Thanks for pointing it out.
936 prominent_color_ = color_calculator_->prominent_color();
937 color_calculator_.reset();
938 for (auto& observer : observers_)
939 observer.OnColorCalculationComplete();
940 }
941
914 // WallpaperManager, private: -------------------------------------------------- 942 // WallpaperManager, private: --------------------------------------------------
915 943
916 WallpaperManager::WallpaperManager() 944 WallpaperManager::WallpaperManager()
917 : binding_(this), 945 : binding_(this),
918 pending_inactive_(nullptr), 946 pending_inactive_(nullptr),
919 activation_client_observer_(this), 947 activation_client_observer_(this),
920 window_observer_(this), 948 window_observer_(this),
921 weak_factory_(this) { 949 weak_factory_(this) {
922 DCHECK_CURRENTLY_ON(BrowserThread::UI); 950 DCHECK_CURRENTLY_ON(BrowserThread::UI);
923 wallpaper::WallpaperManagerBase::SetPathIds( 951 wallpaper::WallpaperManagerBase::SetPathIds(
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 1473
1446 UMA_HISTOGRAM_ENUMERATION( 1474 UMA_HISTOGRAM_ENUMERATION(
1447 "Ash.Wallpaper.Apps", 1475 "Ash.Wallpaper.Apps",
1448 wallpaper_manager_util::ShouldUseAndroidWallpapersApp(profile) 1476 wallpaper_manager_util::ShouldUseAndroidWallpapersApp(profile)
1449 ? WALLPAPERS_APP_ANDROID 1477 ? WALLPAPERS_APP_ANDROID
1450 : WALLPAPERS_PICKER_APP_CHROMEOS, 1478 : WALLPAPERS_PICKER_APP_CHROMEOS,
1451 WALLPAPERS_APPS_NUM); 1479 WALLPAPERS_APPS_NUM);
1452 } 1480 }
1453 1481
1454 } // namespace chromeos 1482 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698