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

Side by Side Diff: ash/mus/wallpaper_delegate_mus.cc

Issue 2413503002: Cleanup mojo Wallpaper interfaces for mash. (Closed)
Patch Set: Sync and rebase; do *not* use mojo in classic ash. Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/mus/wallpaper_delegate_mus.h" 5 #include "ash/mus/wallpaper_delegate_mus.h"
6 6
7 #include "ash/common/wallpaper/wallpaper_controller.h"
8 #include "ash/common/wm_shell.h"
9 #include "components/wallpaper/wallpaper_layout.h" 7 #include "components/wallpaper/wallpaper_layout.h"
10 #include "services/shell/public/cpp/connector.h"
11 #include "ui/wm/core/window_animations.h" 8 #include "ui/wm/core/window_animations.h"
12 9
13 namespace {
14
15 // TODO(msw): Use enum traits instead.
16 wallpaper::WallpaperLayout WallpaperLayoutFromMojo(
17 ash::mojom::WallpaperLayout layout) {
18 switch (layout) {
19 case ash::mojom::WallpaperLayout::CENTER:
20 return wallpaper::WALLPAPER_LAYOUT_CENTER;
21 case ash::mojom::WallpaperLayout::CENTER_CROPPED:
22 return wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED;
23 case ash::mojom::WallpaperLayout::STRETCH:
24 return wallpaper::WALLPAPER_LAYOUT_STRETCH;
25 case ash::mojom::WallpaperLayout::TILE:
26 return wallpaper::WALLPAPER_LAYOUT_TILE;
27 }
28 NOTREACHED();
29 return wallpaper::WALLPAPER_LAYOUT_CENTER;
30 }
31
32 } // namespace
33
34 namespace ash { 10 namespace ash {
35 11
36 WallpaperDelegateMus::WallpaperDelegateMus(shell::Connector* connector) 12 WallpaperDelegateMus::WallpaperDelegateMus() {}
37 : connector_(connector) {}
38
39 WallpaperDelegateMus::~WallpaperDelegateMus() {} 13 WallpaperDelegateMus::~WallpaperDelegateMus() {}
40 14
41 int WallpaperDelegateMus::GetAnimationType() { 15 int WallpaperDelegateMus::GetAnimationType() {
42 return ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE; 16 return ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE;
43 } 17 }
44 18
45 int WallpaperDelegateMus::GetAnimationDurationOverride() { 19 int WallpaperDelegateMus::GetAnimationDurationOverride() {
46 return 0; 20 return 0;
47 } 21 }
48 22
49 void WallpaperDelegateMus::SetAnimationDurationOverride( 23 void WallpaperDelegateMus::SetAnimationDurationOverride(
50 int animation_duration_in_ms) { 24 int animation_duration_in_ms) {
51 NOTIMPLEMENTED(); 25 NOTIMPLEMENTED();
52 } 26 }
53 27
54 bool WallpaperDelegateMus::ShouldShowInitialAnimation() { 28 bool WallpaperDelegateMus::ShouldShowInitialAnimation() {
55 return false; 29 return false;
56 } 30 }
57 31
58 void WallpaperDelegateMus::UpdateWallpaper(bool clear_cache) { 32 void WallpaperDelegateMus::UpdateWallpaper(bool clear_cache) {
59 NOTIMPLEMENTED(); 33 NOTIMPLEMENTED();
60 } 34 }
61 35
62 void WallpaperDelegateMus::InitializeWallpaper() { 36 void WallpaperDelegateMus::InitializeWallpaper() {
63 // No action required; ChromeBrowserMainPartsChromeos inits WallpaperManager. 37 // No action required; ChromeBrowserMainPartsChromeos inits WallpaperManager.
64 } 38 }
65 39
66 void WallpaperDelegateMus::OpenSetWallpaperPage() {
67 mojom::WallpaperManagerPtr wallpaper_manager;
68 connector_->ConnectToInterface("service:content_browser", &wallpaper_manager);
69 wallpaper_manager->Open();
70 }
71
72 bool WallpaperDelegateMus::CanOpenSetWallpaperPage() { 40 bool WallpaperDelegateMus::CanOpenSetWallpaperPage() {
73 // TODO(msw): Restrict this during login, etc. 41 // TODO(msw): Restrict this during login, etc.
74 return true; 42 return true;
75 } 43 }
76 44
77 void WallpaperDelegateMus::OnWallpaperAnimationFinished() {} 45 void WallpaperDelegateMus::OnWallpaperAnimationFinished() {}
78 46
79 void WallpaperDelegateMus::OnWallpaperBootAnimationFinished() {} 47 void WallpaperDelegateMus::OnWallpaperBootAnimationFinished() {}
80 48
81 void WallpaperDelegateMus::SetWallpaper(const SkBitmap& wallpaper,
82 mojom::WallpaperLayout layout) {
83 if (wallpaper.isNull())
84 return;
85 gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(wallpaper);
86 WmShell::Get()->wallpaper_controller()->SetWallpaperImage(
87 image, WallpaperLayoutFromMojo(layout));
88 }
89
90 } // namespace ash 49 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698