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

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

Issue 2323063003: mash: Port sysui's WallpaperDelegateMus to mojo:ash. (Closed)
Patch Set: Alternative display info workaround. Created 4 years, 3 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/sysui/wallpaper_delegate_mus.h" 5 #include "ash/mus/wallpaper_delegate_mus.h"
6 6
7 #include "ash/common/wallpaper/wallpaper_controller.h" 7 #include "ash/common/wallpaper/wallpaper_controller.h"
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.h"
9 #include "components/wallpaper/wallpaper_layout.h" 9 #include "components/wallpaper/wallpaper_layout.h"
10 #include "services/shell/public/cpp/connector.h" 10 #include "services/shell/public/cpp/connector.h"
11 #include "ui/views/mus/window_manager_connection.h"
12 #include "ui/wm/core/window_animations.h" 11 #include "ui/wm/core/window_animations.h"
13 12
14 namespace { 13 namespace {
15 14
15 // TODO(msw): Use enum traits instead.
16 wallpaper::WallpaperLayout WallpaperLayoutFromMojo( 16 wallpaper::WallpaperLayout WallpaperLayoutFromMojo(
17 ash::mojom::WallpaperLayout layout) { 17 ash::mojom::WallpaperLayout layout) {
18 switch (layout) { 18 switch (layout) {
19 case ash::mojom::WallpaperLayout::CENTER: 19 case ash::mojom::WallpaperLayout::CENTER:
20 return wallpaper::WALLPAPER_LAYOUT_CENTER; 20 return wallpaper::WALLPAPER_LAYOUT_CENTER;
21 case ash::mojom::WallpaperLayout::CENTER_CROPPED: 21 case ash::mojom::WallpaperLayout::CENTER_CROPPED:
22 return wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED; 22 return wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED;
23 case ash::mojom::WallpaperLayout::STRETCH: 23 case ash::mojom::WallpaperLayout::STRETCH:
24 return wallpaper::WALLPAPER_LAYOUT_STRETCH; 24 return wallpaper::WALLPAPER_LAYOUT_STRETCH;
25 case ash::mojom::WallpaperLayout::TILE: 25 case ash::mojom::WallpaperLayout::TILE:
26 return wallpaper::WALLPAPER_LAYOUT_TILE; 26 return wallpaper::WALLPAPER_LAYOUT_TILE;
27 } 27 }
28 NOTREACHED(); 28 NOTREACHED();
29 return wallpaper::WALLPAPER_LAYOUT_CENTER; 29 return wallpaper::WALLPAPER_LAYOUT_CENTER;
30 } 30 }
31 31
32 } // namespace 32 } // namespace
33 33
34 namespace ash { 34 namespace ash {
35 namespace sysui {
36 35
37 WallpaperDelegateMus::WallpaperDelegateMus() {} 36 WallpaperDelegateMus::WallpaperDelegateMus(shell::Connector* connector)
37 : connector_(connector) {}
38 38
39 WallpaperDelegateMus::~WallpaperDelegateMus() {} 39 WallpaperDelegateMus::~WallpaperDelegateMus() {}
40 40
41 int WallpaperDelegateMus::GetAnimationType() { 41 int WallpaperDelegateMus::GetAnimationType() {
42 return ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE; 42 return ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE;
43 } 43 }
44 44
45 int WallpaperDelegateMus::GetAnimationDurationOverride() { 45 int WallpaperDelegateMus::GetAnimationDurationOverride() {
46 return 0; 46 return 0;
47 } 47 }
(...skipping 10 matching lines...) Expand all
58 void WallpaperDelegateMus::UpdateWallpaper(bool clear_cache) { 58 void WallpaperDelegateMus::UpdateWallpaper(bool clear_cache) {
59 NOTIMPLEMENTED(); 59 NOTIMPLEMENTED();
60 } 60 }
61 61
62 void WallpaperDelegateMus::InitializeWallpaper() { 62 void WallpaperDelegateMus::InitializeWallpaper() {
63 // No action required; ChromeBrowserMainPartsChromeos inits WallpaperManager. 63 // No action required; ChromeBrowserMainPartsChromeos inits WallpaperManager.
64 } 64 }
65 65
66 void WallpaperDelegateMus::OpenSetWallpaperPage() { 66 void WallpaperDelegateMus::OpenSetWallpaperPage() {
67 mojom::WallpaperManagerPtr wallpaper_manager; 67 mojom::WallpaperManagerPtr wallpaper_manager;
68 auto* connector = views::WindowManagerConnection::Get()->connector(); 68 connector_->ConnectToInterface("exe:chrome", &wallpaper_manager);
69 connector->ConnectToInterface("exe:chrome", &wallpaper_manager);
70 wallpaper_manager->Open(); 69 wallpaper_manager->Open();
71 } 70 }
72 71
73 bool WallpaperDelegateMus::CanOpenSetWallpaperPage() { 72 bool WallpaperDelegateMus::CanOpenSetWallpaperPage() {
74 // TODO(msw): Restrict this during login, etc. 73 // TODO(msw): Restrict this during login, etc.
75 return true; 74 return true;
76 } 75 }
77 76
78 void WallpaperDelegateMus::OnWallpaperAnimationFinished() {} 77 void WallpaperDelegateMus::OnWallpaperAnimationFinished() {}
79 78
80 void WallpaperDelegateMus::OnWallpaperBootAnimationFinished() {} 79 void WallpaperDelegateMus::OnWallpaperBootAnimationFinished() {}
81 80
82 void WallpaperDelegateMus::SetWallpaper(const SkBitmap& wallpaper, 81 void WallpaperDelegateMus::SetWallpaper(const SkBitmap& wallpaper,
83 mojom::WallpaperLayout layout) { 82 mojom::WallpaperLayout layout) {
84 if (wallpaper.isNull()) 83 if (wallpaper.isNull())
85 return; 84 return;
86 gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(wallpaper); 85 gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(wallpaper);
87 WmShell::Get()->wallpaper_controller()->SetWallpaperImage( 86 WmShell::Get()->wallpaper_controller()->SetWallpaperImage(
88 image, WallpaperLayoutFromMojo(layout)); 87 image, WallpaperLayoutFromMojo(layout));
89 } 88 }
90 89
91 } // namespace sysui
92 } // namespace ash 90 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698