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

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

Issue 2413503002: Cleanup mojo Wallpaper interfaces for mash. (Closed)
Patch Set: Sync and rebase again... 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
« no previous file with comments | « ash/mus/wallpaper_delegate_mus.h ('k') | ash/mus/window_manager_application.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/service_manager/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( 12 WallpaperDelegateMus::WallpaperDelegateMus() {}
37 service_manager::Connector* connector)
38 : connector_(connector) {}
39
40 WallpaperDelegateMus::~WallpaperDelegateMus() {} 13 WallpaperDelegateMus::~WallpaperDelegateMus() {}
41 14
42 int WallpaperDelegateMus::GetAnimationType() { 15 int WallpaperDelegateMus::GetAnimationType() {
43 return ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE; 16 return ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE;
44 } 17 }
45 18
46 int WallpaperDelegateMus::GetAnimationDurationOverride() { 19 int WallpaperDelegateMus::GetAnimationDurationOverride() {
47 return 0; 20 return 0;
48 } 21 }
49 22
50 void WallpaperDelegateMus::SetAnimationDurationOverride( 23 void WallpaperDelegateMus::SetAnimationDurationOverride(
51 int animation_duration_in_ms) { 24 int animation_duration_in_ms) {
52 NOTIMPLEMENTED(); 25 NOTIMPLEMENTED();
53 } 26 }
54 27
55 bool WallpaperDelegateMus::ShouldShowInitialAnimation() { 28 bool WallpaperDelegateMus::ShouldShowInitialAnimation() {
56 return false; 29 return false;
57 } 30 }
58 31
59 void WallpaperDelegateMus::UpdateWallpaper(bool clear_cache) { 32 void WallpaperDelegateMus::UpdateWallpaper(bool clear_cache) {
60 NOTIMPLEMENTED(); 33 NOTIMPLEMENTED();
61 } 34 }
62 35
63 void WallpaperDelegateMus::InitializeWallpaper() { 36 void WallpaperDelegateMus::InitializeWallpaper() {
64 // No action required; ChromeBrowserMainPartsChromeos inits WallpaperManager. 37 // No action required; ChromeBrowserMainPartsChromeos inits WallpaperManager.
65 } 38 }
66 39
67 void WallpaperDelegateMus::OpenSetWallpaperPage() {
68 mojom::WallpaperManagerPtr wallpaper_manager;
69 connector_->ConnectToInterface("service:content_browser", &wallpaper_manager);
70 wallpaper_manager->Open();
71 }
72
73 bool WallpaperDelegateMus::CanOpenSetWallpaperPage() { 40 bool WallpaperDelegateMus::CanOpenSetWallpaperPage() {
74 // TODO(msw): Restrict this during login, etc. 41 // TODO(msw): Restrict this during login, etc.
75 return true; 42 return true;
76 } 43 }
77 44
78 void WallpaperDelegateMus::OnWallpaperAnimationFinished() {} 45 void WallpaperDelegateMus::OnWallpaperAnimationFinished() {}
79 46
80 void WallpaperDelegateMus::OnWallpaperBootAnimationFinished() {} 47 void WallpaperDelegateMus::OnWallpaperBootAnimationFinished() {}
81 48
82 void WallpaperDelegateMus::SetWallpaper(const SkBitmap& wallpaper,
83 mojom::WallpaperLayout layout) {
84 if (wallpaper.isNull())
85 return;
86 gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(wallpaper);
87 WmShell::Get()->wallpaper_controller()->SetWallpaperImage(
88 image, WallpaperLayoutFromMojo(layout));
89 }
90
91 } // namespace ash 49 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/wallpaper_delegate_mus.h ('k') | ash/mus/window_manager_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698