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

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

Issue 2943333003: Extracting more than one wallpaper prominent color (Closed)
Patch Set: UMA 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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 return false; 437 return false;
438 } 438 }
439 439
440 void WallpaperManager::CalculateProminentColor(const gfx::ImageSkia& image) { 440 void WallpaperManager::CalculateProminentColor(const gfx::ImageSkia& image) {
441 // Cancel in-flight color calculations, if any. 441 // Cancel in-flight color calculations, if any.
442 if (color_calculator_) { 442 if (color_calculator_) {
443 color_calculator_->RemoveObserver(this); 443 color_calculator_->RemoveObserver(this);
444 color_calculator_.reset(); 444 color_calculator_.reset();
445 } 445 }
446 446
447 // TODO(warx): this color fetching should go through ash::WallpaperController.
448 color_utils::ColorProfiles color_profiles = {color_utils::ColorProfile(
449 color_utils::LumaRange::DARK, color_utils::SaturationRange::MUTED)};
447 color_calculator_ = base::MakeUnique<wallpaper::WallpaperColorCalculator>( 450 color_calculator_ = base::MakeUnique<wallpaper::WallpaperColorCalculator>(
448 image, color_utils::LumaRange::DARK, color_utils::SaturationRange::MUTED, 451 image, color_profiles, task_runner_);
449 task_runner_);
450 color_calculator_->AddObserver(this); 452 color_calculator_->AddObserver(this);
451 if (!color_calculator_->StartCalculation()) { 453 if (!color_calculator_->StartCalculation()) {
452 color_calculator_->RemoveObserver(this); 454 color_calculator_->RemoveObserver(this);
453 color_calculator_.reset(); 455 color_calculator_.reset();
454 if (!prominent_color_.has_value()) 456 if (!prominent_color_.has_value())
455 return; 457 return;
456 prominent_color_.reset(); 458 prominent_color_.reset();
457 for (auto& observer : observers_) 459 for (auto& observer : observers_)
458 observer.OnWallpaperColorsChanged(); 460 observer.OnWallpaperColorsChanged();
459 } 461 }
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 } 939 }
938 } 940 }
939 941
940 void WallpaperManager::OnWindowDestroying(aura::Window* window) { 942 void WallpaperManager::OnWindowDestroying(aura::Window* window) {
941 window_observer_.Remove(window); 943 window_observer_.Remove(window);
942 chromeos::WallpaperWindowStateManager::RestoreWindows( 944 chromeos::WallpaperWindowStateManager::RestoreWindows(
943 user_manager::UserManager::Get()->GetActiveUser()->username_hash()); 945 user_manager::UserManager::Get()->GetActiveUser()->username_hash());
944 } 946 }
945 947
946 void WallpaperManager::OnColorCalculationComplete() { 948 void WallpaperManager::OnColorCalculationComplete() {
947 SkColor color = color_calculator_->prominent_color(); 949 SkColor color = color_calculator_->prominent_colors()[0];
948 color_calculator_->RemoveObserver(this); 950 color_calculator_->RemoveObserver(this);
949 color_calculator_.reset(); 951 color_calculator_.reset();
950 if (prominent_color_ == color) 952 if (prominent_color_ == color)
951 return; 953 return;
952 prominent_color_ = color; 954 prominent_color_ = color;
953 955
954 for (auto& observer : observers_) 956 for (auto& observer : observers_)
955 observer.OnWallpaperColorsChanged(); 957 observer.OnWallpaperColorsChanged();
956 } 958 }
957 959
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 1496
1495 UMA_HISTOGRAM_ENUMERATION( 1497 UMA_HISTOGRAM_ENUMERATION(
1496 "Ash.Wallpaper.Apps", 1498 "Ash.Wallpaper.Apps",
1497 wallpaper_manager_util::ShouldUseAndroidWallpapersApp(profile) 1499 wallpaper_manager_util::ShouldUseAndroidWallpapersApp(profile)
1498 ? WALLPAPERS_APP_ANDROID 1500 ? WALLPAPERS_APP_ANDROID
1499 : WALLPAPERS_PICKER_APP_CHROMEOS, 1501 : WALLPAPERS_PICKER_APP_CHROMEOS,
1500 WALLPAPERS_APPS_NUM); 1502 WALLPAPERS_APPS_NUM);
1501 } 1503 }
1502 1504
1503 } // namespace chromeos 1505 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698