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

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: feedback from ps4 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "components/user_manager/user_type.h" 56 #include "components/user_manager/user_type.h"
57 #include "components/wallpaper/wallpaper_files_id.h" 57 #include "components/wallpaper/wallpaper_files_id.h"
58 #include "components/wallpaper/wallpaper_layout.h" 58 #include "components/wallpaper/wallpaper_layout.h"
59 #include "components/wallpaper/wallpaper_resizer.h" 59 #include "components/wallpaper/wallpaper_resizer.h"
60 #include "content/public/browser/browser_thread.h" 60 #include "content/public/browser/browser_thread.h"
61 #include "content/public/browser/notification_service.h" 61 #include "content/public/browser/notification_service.h"
62 #include "content/public/common/content_switches.h" 62 #include "content/public/common/content_switches.h"
63 #include "content/public/common/service_manager_connection.h" 63 #include "content/public/common/service_manager_connection.h"
64 #include "crypto/sha2.h" 64 #include "crypto/sha2.h"
65 #include "services/service_manager/public/cpp/connector.h" 65 #include "services/service_manager/public/cpp/connector.h"
66 #include "ui/gfx/color_analysis.h"
66 #include "url/gurl.h" 67 #include "url/gurl.h"
67 68
68 using content::BrowserThread; 69 using content::BrowserThread;
69 using wallpaper::WallpaperManagerBase; 70 using wallpaper::WallpaperManagerBase;
70 using wallpaper::WallpaperInfo; 71 using wallpaper::WallpaperInfo;
71 using wallpaper::MovableOnDestroyCallback; 72 using wallpaper::MovableOnDestroyCallback;
72 using wallpaper::MovableOnDestroyCallbackHolder; 73 using wallpaper::MovableOnDestroyCallbackHolder;
73 74
74 namespace chromeos { 75 namespace chromeos {
75 76
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 return false; 438 return false;
438 } 439 }
439 440
440 void WallpaperManager::CalculateProminentColor(const gfx::ImageSkia& image) { 441 void WallpaperManager::CalculateProminentColor(const gfx::ImageSkia& image) {
441 // Cancel in-flight color calculations, if any. 442 // Cancel in-flight color calculations, if any.
442 if (color_calculator_) { 443 if (color_calculator_) {
443 color_calculator_->RemoveObserver(this); 444 color_calculator_->RemoveObserver(this);
444 color_calculator_.reset(); 445 color_calculator_.reset();
445 } 446 }
446 447
448 // TODO(warx): this color fetching should go through ash::WallpaperController.
449 std::vector<color_utils::ColorProfile> color_profiles;
450 color_profiles.emplace_back(color_utils::LumaRange::DARK,
451 color_utils::SaturationRange::MUTED);
447 color_calculator_ = base::MakeUnique<wallpaper::WallpaperColorCalculator>( 452 color_calculator_ = base::MakeUnique<wallpaper::WallpaperColorCalculator>(
448 image, color_utils::LumaRange::DARK, color_utils::SaturationRange::MUTED, 453 image, color_profiles, task_runner_);
449 task_runner_);
450 color_calculator_->AddObserver(this); 454 color_calculator_->AddObserver(this);
451 if (!color_calculator_->StartCalculation()) { 455 if (!color_calculator_->StartCalculation()) {
452 color_calculator_->RemoveObserver(this); 456 color_calculator_->RemoveObserver(this);
453 color_calculator_.reset(); 457 color_calculator_.reset();
454 if (!prominent_color_.has_value()) 458 if (!prominent_color_.has_value())
455 return; 459 return;
456 prominent_color_.reset(); 460 prominent_color_.reset();
457 for (auto& observer : observers_) 461 for (auto& observer : observers_)
458 observer.OnWallpaperColorsChanged(); 462 observer.OnWallpaperColorsChanged();
459 } 463 }
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 } 941 }
938 } 942 }
939 943
940 void WallpaperManager::OnWindowDestroying(aura::Window* window) { 944 void WallpaperManager::OnWindowDestroying(aura::Window* window) {
941 window_observer_.Remove(window); 945 window_observer_.Remove(window);
942 chromeos::WallpaperWindowStateManager::RestoreWindows( 946 chromeos::WallpaperWindowStateManager::RestoreWindows(
943 user_manager::UserManager::Get()->GetActiveUser()->username_hash()); 947 user_manager::UserManager::Get()->GetActiveUser()->username_hash());
944 } 948 }
945 949
946 void WallpaperManager::OnColorCalculationComplete() { 950 void WallpaperManager::OnColorCalculationComplete() {
947 SkColor color = color_calculator_->prominent_color(); 951 SkColor color = color_calculator_->prominent_colors()[0];
bruthig 2017/06/21 15:54:17 '0' seems like a magic number here.
Qiang(Joe) Xu 2017/06/21 22:35:27 Done.
948 color_calculator_->RemoveObserver(this); 952 color_calculator_->RemoveObserver(this);
949 color_calculator_.reset(); 953 color_calculator_.reset();
950 if (prominent_color_ == color) 954 if (prominent_color_ == color)
951 return; 955 return;
952 prominent_color_ = color; 956 prominent_color_ = color;
953 957
954 for (auto& observer : observers_) 958 for (auto& observer : observers_)
955 observer.OnWallpaperColorsChanged(); 959 observer.OnWallpaperColorsChanged();
956 } 960 }
957 961
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 1498
1495 UMA_HISTOGRAM_ENUMERATION( 1499 UMA_HISTOGRAM_ENUMERATION(
1496 "Ash.Wallpaper.Apps", 1500 "Ash.Wallpaper.Apps",
1497 wallpaper_manager_util::ShouldUseAndroidWallpapersApp(profile) 1501 wallpaper_manager_util::ShouldUseAndroidWallpapersApp(profile)
1498 ? WALLPAPERS_APP_ANDROID 1502 ? WALLPAPERS_APP_ANDROID
1499 : WALLPAPERS_PICKER_APP_CHROMEOS, 1503 : WALLPAPERS_PICKER_APP_CHROMEOS,
1500 WALLPAPERS_APPS_NUM); 1504 WALLPAPERS_APPS_NUM);
1501 } 1505 }
1502 1506
1503 } // namespace chromeos 1507 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698