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

Side by Side Diff: ash/desktop_background/desktop_background_controller.cc

Issue 1984433002: Hook up Chrome's wallpaper picker for mash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 7 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/desktop_background/desktop_background_controller.h" 5 #include "ash/desktop_background/desktop_background_controller.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/desktop_background/desktop_background_controller_observer.h" 8 #include "ash/desktop_background/desktop_background_controller_observer.h"
9 #include "ash/desktop_background/desktop_background_view.h" 9 #include "ash/desktop_background/desktop_background_view.h"
10 #include "ash/desktop_background/desktop_background_widget_controller.h" 10 #include "ash/desktop_background/desktop_background_widget_controller.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 if (desktop_background_mode_ == BACKGROUND_IMAGE && 154 if (desktop_background_mode_ == BACKGROUND_IMAGE &&
155 current_wallpaper_.get()) 155 current_wallpaper_.get())
156 UpdateWallpaper(true /* clear cache */); 156 UpdateWallpaper(true /* clear cache */);
157 } 157 }
158 158
159 InstallDesktopController(root_window); 159 InstallDesktopController(root_window);
160 } 160 }
161 161
162 // static 162 // static
163 gfx::Size DesktopBackgroundController::GetMaxDisplaySizeInNative() { 163 gfx::Size DesktopBackgroundController::GetMaxDisplaySizeInNative() {
164 // Return an empty size for test environments where the screen is null.
165 if (!display::Screen::GetScreen())
166 return gfx::Size();
167
164 int width = 0; 168 int width = 0;
165 int height = 0; 169 int height = 0;
166 std::vector<display::Display> displays = 170 DisplayManager* display_manager =
167 display::Screen::GetScreen()->GetAllDisplays(); 171 Shell::HasInstance() ? Shell::GetInstance()->display_manager() : nullptr;
168 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 172 for (auto& display : display::Screen::GetScreen()->GetAllDisplays()) {
dcheng 2016/05/24 18:53:37 Nit: const auto&?
msw 2016/05/24 22:06:37 Done.
169
170 for (std::vector<display::Display>::iterator iter = displays.begin();
171 iter != displays.end(); ++iter) {
172 // Don't use size_in_pixel because we want to use the native pixel size. 173 // Don't use size_in_pixel because we want to use the native pixel size.
174 // TODO(msw): Fix this for Mash/Mus; see http://crbug.com/613657.
173 gfx::Size size_in_pixel = 175 gfx::Size size_in_pixel =
174 display_manager->GetDisplayInfo(iter->id()).bounds_in_native().size(); 176 display_manager
175 if (iter->rotation() == display::Display::ROTATE_90 || 177 ? display_manager->GetDisplayInfo(display.id())
176 iter->rotation() == display::Display::ROTATE_270) { 178 .bounds_in_native()
179 .size()
180 : display.size();
181 if (display.rotation() == display::Display::ROTATE_90 ||
182 display.rotation() == display::Display::ROTATE_270) {
177 size_in_pixel = gfx::Size(size_in_pixel.height(), size_in_pixel.width()); 183 size_in_pixel = gfx::Size(size_in_pixel.height(), size_in_pixel.width());
178 } 184 }
179 width = std::max(size_in_pixel.width(), width); 185 width = std::max(size_in_pixel.width(), width);
180 height = std::max(size_in_pixel.height(), height); 186 height = std::max(size_in_pixel.height(), height);
181 } 187 }
182 return gfx::Size(width, height); 188 return gfx::Size(width, height);
183 } 189 }
184 190
185 bool DesktopBackgroundController::WallpaperIsAlreadyLoaded( 191 bool DesktopBackgroundController::WallpaperIsAlreadyLoaded(
186 const gfx::ImageSkia& image, 192 const gfx::ImageSkia& image,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 : kShellWindowId_DesktopBackgroundContainer; 282 : kShellWindowId_DesktopBackgroundContainer;
277 } 283 }
278 284
279 void DesktopBackgroundController::UpdateWallpaper(bool clear_cache) { 285 void DesktopBackgroundController::UpdateWallpaper(bool clear_cache) {
280 current_wallpaper_.reset(NULL); 286 current_wallpaper_.reset(NULL);
281 ash::Shell::GetInstance()->user_wallpaper_delegate()->UpdateWallpaper( 287 ash::Shell::GetInstance()->user_wallpaper_delegate()->UpdateWallpaper(
282 clear_cache); 288 clear_cache);
283 } 289 }
284 290
285 } // namespace ash 291 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/mus/BUILD.gn » ('j') | chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698