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

Side by Side Diff: ash/wallpaper/wallpaper_controller.cc

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: feedback Created 3 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/wallpaper/wallpaper_controller.h" 5 #include "ash/wallpaper/wallpaper_controller.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/public/cpp/shell_window_ids.h" 11 #include "ash/public/cpp/shell_window_ids.h"
12 #include "ash/root_window_controller.h" 12 #include "ash/root_window_controller.h"
13 #include "ash/session/session_controller.h" 13 #include "ash/session/session_controller.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ash/shell_port.h"
15 #include "ash/wallpaper/wallpaper_controller_observer.h" 16 #include "ash/wallpaper/wallpaper_controller_observer.h"
16 #include "ash/wallpaper/wallpaper_delegate.h" 17 #include "ash/wallpaper/wallpaper_delegate.h"
17 #include "ash/wallpaper/wallpaper_view.h" 18 #include "ash/wallpaper/wallpaper_view.h"
18 #include "ash/wallpaper/wallpaper_widget_controller.h" 19 #include "ash/wallpaper/wallpaper_widget_controller.h"
19 #include "ash/wm_shell.h"
20 #include "ash/wm_window.h" 20 #include "ash/wm_window.h"
21 #include "base/bind.h" 21 #include "base/bind.h"
22 #include "base/command_line.h" 22 #include "base/command_line.h"
23 #include "base/logging.h" 23 #include "base/logging.h"
24 #include "base/task_runner.h" 24 #include "base/task_runner.h"
25 #include "components/wallpaper/wallpaper_color_calculator.h" 25 #include "components/wallpaper/wallpaper_color_calculator.h"
26 #include "components/wallpaper/wallpaper_resizer.h" 26 #include "components/wallpaper/wallpaper_resizer.h"
27 #include "ui/display/manager/managed_display_info.h" 27 #include "ui/display/manager/managed_display_info.h"
28 #include "ui/display/screen.h" 28 #include "ui/display/screen.h"
29 #include "ui/gfx/color_analysis.h" 29 #include "ui/gfx/color_analysis.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 } // namespace 87 } // namespace
88 88
89 WallpaperController::WallpaperController( 89 WallpaperController::WallpaperController(
90 const scoped_refptr<base::TaskRunner>& task_runner) 90 const scoped_refptr<base::TaskRunner>& task_runner)
91 : locked_(false), 91 : locked_(false),
92 wallpaper_mode_(WALLPAPER_NONE), 92 wallpaper_mode_(WALLPAPER_NONE),
93 prominent_color_(kInvalidColor), 93 prominent_color_(kInvalidColor),
94 wallpaper_reload_delay_(kWallpaperReloadDelayMs), 94 wallpaper_reload_delay_(kWallpaperReloadDelayMs),
95 task_runner_(task_runner) { 95 task_runner_(task_runner) {
96 WmShell::Get()->AddDisplayObserver(this); 96 ShellPort::Get()->AddDisplayObserver(this);
97 Shell::Get()->AddShellObserver(this); 97 Shell::Get()->AddShellObserver(this);
98 Shell::Get()->session_controller()->AddSessionStateObserver(this); 98 Shell::Get()->session_controller()->AddSessionStateObserver(this);
99 } 99 }
100 100
101 WallpaperController::~WallpaperController() { 101 WallpaperController::~WallpaperController() {
102 if (current_wallpaper_) 102 if (current_wallpaper_)
103 current_wallpaper_->RemoveObserver(this); 103 current_wallpaper_->RemoveObserver(this);
104 if (color_calculator_) 104 if (color_calculator_)
105 color_calculator_->RemoveObserver(this); 105 color_calculator_->RemoveObserver(this);
106 WmShell::Get()->RemoveDisplayObserver(this); 106 ShellPort::Get()->RemoveDisplayObserver(this);
107 Shell::Get()->RemoveShellObserver(this); 107 Shell::Get()->RemoveShellObserver(this);
108 Shell::Get()->session_controller()->RemoveSessionStateObserver(this); 108 Shell::Get()->session_controller()->RemoveSessionStateObserver(this);
109 } 109 }
110 110
111 void WallpaperController::BindRequest( 111 void WallpaperController::BindRequest(
112 mojom::WallpaperControllerRequest request) { 112 mojom::WallpaperControllerRequest request) {
113 bindings_.AddBinding(this, std::move(request)); 113 bindings_.AddBinding(this, std::move(request));
114 } 114 }
115 115
116 gfx::ImageSkia WallpaperController::GetWallpaper() const { 116 gfx::ImageSkia WallpaperController::GetWallpaper() const {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 session_manager::SessionState state) { 217 session_manager::SessionState state) {
218 CalculateWallpaperColors(); 218 CalculateWallpaperColors();
219 } 219 }
220 220
221 // static 221 // static
222 gfx::Size WallpaperController::GetMaxDisplaySizeInNative() { 222 gfx::Size WallpaperController::GetMaxDisplaySizeInNative() {
223 // Return an empty size for test environments where the screen is null. 223 // Return an empty size for test environments where the screen is null.
224 if (!display::Screen::GetScreen()) 224 if (!display::Screen::GetScreen())
225 return gfx::Size(); 225 return gfx::Size();
226 226
227 // Note that |shell| is null when this is called from Chrome running in Mash. 227 // Note that |shell_port| is null when this is called from Chrome running in
228 WmShell* shell = WmShell::Get(); 228 // Mash.
229 ShellPort* shell_port = ShellPort::Get();
229 230
230 gfx::Size max; 231 gfx::Size max;
231 for (const auto& display : display::Screen::GetScreen()->GetAllDisplays()) { 232 for (const auto& display : display::Screen::GetScreen()->GetAllDisplays()) {
232 // Use the native size, not ManagedDisplayInfo::size_in_pixel or 233 // Use the native size, not ManagedDisplayInfo::size_in_pixel or
233 // Display::size. 234 // Display::size.
234 // TODO(msw): Avoid using Display::size here; see http://crbug.com/613657. 235 // TODO(msw): Avoid using Display::size here; see http://crbug.com/613657.
235 gfx::Size size = display.size(); 236 gfx::Size size = display.size();
236 if (shell) { 237 if (shell_port) {
237 display::ManagedDisplayInfo info = shell->GetDisplayInfo(display.id()); 238 display::ManagedDisplayInfo info =
239 shell_port->GetDisplayInfo(display.id());
238 // TODO(mash): Mash returns a fake ManagedDisplayInfo. crbug.com/622480 240 // TODO(mash): Mash returns a fake ManagedDisplayInfo. crbug.com/622480
239 if (info.id() == display.id()) 241 if (info.id() == display.id())
240 size = info.bounds_in_native().size(); 242 size = info.bounds_in_native().size();
241 } 243 }
242 if (display.rotation() == display::Display::ROTATE_90 || 244 if (display.rotation() == display::Display::ROTATE_90 ||
243 display.rotation() == display::Display::ROTATE_270) { 245 display.rotation() == display::Display::ROTATE_270) {
244 size = gfx::Size(size.height(), size.width()); 246 size = gfx::Size(size.height(), size.width());
245 } 247 }
246 max.SetToMax(size); 248 max.SetToMax(size);
247 } 249 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return; 310 return;
309 } 311 }
310 312
311 RootWindowController* controller = root_window->GetRootWindowController(); 313 RootWindowController* controller = root_window->GetRootWindowController();
312 controller->SetAnimatingWallpaperWidgetController( 314 controller->SetAnimatingWallpaperWidgetController(
313 new AnimatingWallpaperWidgetController(component)); 315 new AnimatingWallpaperWidgetController(component));
314 component->StartAnimating(controller); 316 component->StartAnimating(controller);
315 } 317 }
316 318
317 void WallpaperController::InstallDesktopControllerForAllWindows() { 319 void WallpaperController::InstallDesktopControllerForAllWindows() {
318 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) 320 for (WmWindow* root : ShellPort::Get()->GetAllRootWindows())
319 InstallDesktopController(root); 321 InstallDesktopController(root);
320 current_max_display_size_ = GetMaxDisplaySizeInNative(); 322 current_max_display_size_ = GetMaxDisplaySizeInNative();
321 } 323 }
322 324
323 bool WallpaperController::ReparentWallpaper(int container) { 325 bool WallpaperController::ReparentWallpaper(int container) {
324 bool moved = false; 326 bool moved = false;
325 for (WmWindow* root_window : WmShell::Get()->GetAllRootWindows()) { 327 for (WmWindow* root_window : ShellPort::Get()->GetAllRootWindows()) {
326 RootWindowController* root_window_controller = 328 RootWindowController* root_window_controller =
327 root_window->GetRootWindowController(); 329 root_window->GetRootWindowController();
328 // In the steady state (no animation playing) the wallpaper widget 330 // In the steady state (no animation playing) the wallpaper widget
329 // controller exists in the RootWindowController. 331 // controller exists in the RootWindowController.
330 WallpaperWidgetController* wallpaper_widget_controller = 332 WallpaperWidgetController* wallpaper_widget_controller =
331 root_window_controller->wallpaper_widget_controller(); 333 root_window_controller->wallpaper_widget_controller();
332 if (wallpaper_widget_controller) { 334 if (wallpaper_widget_controller) {
333 moved |= wallpaper_widget_controller->Reparent( 335 moved |= wallpaper_widget_controller->Reparent(
334 root_window_controller->GetWindow(), container); 336 root_window_controller->GetWindow(), container);
335 } 337 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 396
395 bool WallpaperController::ShouldCalculateColors() const { 397 bool WallpaperController::ShouldCalculateColors() const {
396 gfx::ImageSkia image = GetWallpaper(); 398 gfx::ImageSkia image = GetWallpaper();
397 return IsShelfColoringEnabled() && 399 return IsShelfColoringEnabled() &&
398 Shell::Get()->session_controller()->GetSessionState() == 400 Shell::Get()->session_controller()->GetSessionState() ==
399 session_manager::SessionState::ACTIVE && 401 session_manager::SessionState::ACTIVE &&
400 !image.isNull(); 402 !image.isNull();
401 } 403 }
402 404
403 } // namespace ash 405 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698