Skip to content

Commit

Permalink
wallpaper refactoring: Deprecate WallpaperDelegate
Browse files Browse the repository at this point in the history
Bug: 557405
Change-Id: Ic11363ce6a48288ebce37bdc388abd658c1a347b
Reviewed-on: https://chromium-review.googlesource.com/854950
Reviewed-by: Emily Stark <estark@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Commit-Queue: Wenzhao (Colin) Zang <wzang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539394}
  • Loading branch information
Wenzhao Zang authored and Commit Bot committed Feb 27, 2018
1 parent 193277b commit b888661
Show file tree
Hide file tree
Showing 31 changed files with 36 additions and 246 deletions.
5 changes: 0 additions & 5 deletions ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ component("ash") {
"cast_config_controller.h",
"debug.cc",
"debug.h",
"default_wallpaper_delegate.cc",
"default_wallpaper_delegate.h",
"disconnected_app_handler.cc",
"disconnected_app_handler.h",
"display/ash_display_controller.cc",
Expand Down Expand Up @@ -785,9 +783,6 @@ component("ash") {
"wallpaper/wallpaper_controller_observer.h",
"wallpaper/wallpaper_decoder.cc",
"wallpaper/wallpaper_decoder.h",
"wallpaper/wallpaper_delegate.h",
"wallpaper/wallpaper_delegate_mus.cc",
"wallpaper/wallpaper_delegate_mus.h",
"wallpaper/wallpaper_view.cc",
"wallpaper/wallpaper_view.h",
"wallpaper/wallpaper_widget_controller.cc",
Expand Down
16 changes: 0 additions & 16 deletions ash/default_wallpaper_delegate.cc

This file was deleted.

29 changes: 0 additions & 29 deletions ash/default_wallpaper_delegate.h

This file was deleted.

5 changes: 5 additions & 0 deletions ash/public/interfaces/wallpaper.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module ash.mojom;
import "ash/public/interfaces/user_info.mojom";
import "components/signin/public/interfaces/account_id.mojom";
import "mojo/common/file_path.mojom";
import "mojo/common/time.mojom";
import "skia/public/interfaces/bitmap.mojom";
import "url/mojom/url.mojom";

Expand Down Expand Up @@ -157,6 +158,10 @@ interface WallpaperController {
// |wallpaper_files_id|: The file id for user_info.account_id.
RemovePolicyWallpaper(WallpaperUserInfo user_info, string wallpaper_files_id);

// Sets wallpaper animation duration. Passing an empty value disables the
// animation.
SetAnimationDuration(mojo.common.mojom.TimeDelta animation_duration);

// Opens the wallpaper picker if the active user is not controlled by policy
// and it's allowed to change wallpaper per the user type and the login state.
OpenWallpaperPickerIfAllowed();
Expand Down
4 changes: 0 additions & 4 deletions ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
#include "ash/virtual_keyboard_controller.h"
#include "ash/voice_interaction/voice_interaction_controller.h"
#include "ash/wallpaper/wallpaper_controller.h"
#include "ash/wallpaper/wallpaper_delegate.h"
#include "ash/wm/ash_focus_rules.h"
#include "ash/wm/container_finder.h"
#include "ash/wm/event_client_impl.h"
Expand Down Expand Up @@ -846,7 +845,6 @@ Shell::~Shell() {
// Needs to happen right before |instance_| is reset.
shell_port_.reset();
session_controller_->RemoveObserver(this);
wallpaper_delegate_.reset();
// BluetoothPowerController depends on the PrefService and must be destructed
// before it.
bluetooth_power_controller_ = nullptr;
Expand Down Expand Up @@ -875,8 +873,6 @@ void Shell::Init(ui::ContextFactory* context_factory,
touch_devices_controller_ = std::make_unique<TouchDevicesController>();
bluetooth_power_controller_ = std::make_unique<BluetoothPowerController>();

wallpaper_delegate_ = shell_delegate_->CreateWallpaperDelegate();

// Connector can be null in tests.
if (shell_delegate_->GetShellConnector()) {
// Connect to local state prefs now, but wait for an active user before
Expand Down
3 changes: 0 additions & 3 deletions ash/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ class VideoDetector;
class VoiceInteractionController;
class VpnList;
class WallpaperController;
class WallpaperDelegate;
class WebNotificationTray;
class WindowCycleController;
class WindowPositioner;
Expand Down Expand Up @@ -474,7 +473,6 @@ class ASH_EXPORT Shell : public SessionObserver,
WallpaperController* wallpaper_controller() {
return wallpaper_controller_.get();
}
WallpaperDelegate* wallpaper_delegate() { return wallpaper_delegate_.get(); }
WindowCycleController* window_cycle_controller() {
return window_cycle_controller_.get();
}
Expand Down Expand Up @@ -687,7 +685,6 @@ class ASH_EXPORT Shell : public SessionObserver,
std::unique_ptr<VoiceInteractionController> voice_interaction_controller_;
std::unique_ptr<VpnList> vpn_list_;
std::unique_ptr<WallpaperController> wallpaper_controller_;
std::unique_ptr<WallpaperDelegate> wallpaper_delegate_;
std::unique_ptr<WindowCycleController> window_cycle_controller_;
std::unique_ptr<WindowSelectorController> window_selector_controller_;
std::unique_ptr<::wm::ShadowController> shadow_controller_;
Expand Down
6 changes: 0 additions & 6 deletions ash/shell/shell_delegate_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <memory>

#include "ash/accessibility/default_accessibility_delegate.h"
#include "ash/default_wallpaper_delegate.h"
#include "ash/keyboard/test_keyboard_ui.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/root_window_controller.h"
Expand Down Expand Up @@ -65,11 +64,6 @@ ShellDelegateImpl::CreateScreenshotDelegate() {
return std::make_unique<TestScreenshotDelegate>();
}

std::unique_ptr<WallpaperDelegate>
ShellDelegateImpl::CreateWallpaperDelegate() {
return std::make_unique<DefaultWallpaperDelegate>();
}

AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() {
return new DefaultAccessibilityDelegate;
}
Expand Down
1 change: 0 additions & 1 deletion ash/shell/shell_delegate_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class ShellDelegateImpl : public ShellDelegate {
void OpenUrlFromArc(const GURL& url) override;
NetworkingConfigDelegate* GetNetworkingConfigDelegate() override;
std::unique_ptr<ScreenshotDelegate> CreateScreenshotDelegate() override;
std::unique_ptr<WallpaperDelegate> CreateWallpaperDelegate() override;
AccessibilityDelegate* CreateAccessibilityDelegate() override;
ui::InputDeviceControllerClient* GetInputDeviceControllerClient() override;

Expand Down
4 changes: 0 additions & 4 deletions ash/shell_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ namespace ash {
class AccessibilityDelegate;
class NetworkingConfigDelegate;
class ScreenshotDelegate;
class WallpaperDelegate;

// Delegate of the Shell.
class ASH_EXPORT ShellDelegate {
Expand Down Expand Up @@ -78,9 +77,6 @@ class ASH_EXPORT ShellDelegate {
// TODO(jamescook): Replace with a mojo-compatible interface.
virtual std::unique_ptr<ScreenshotDelegate> CreateScreenshotDelegate() = 0;

// Creates a wallpaper delegate. Shell takes ownership of the delegate.
virtual std::unique_ptr<WallpaperDelegate> CreateWallpaperDelegate() = 0;

// Creates a accessibility delegate. Shell takes ownership of the delegate.
virtual AccessibilityDelegate* CreateAccessibilityDelegate() = 0;

Expand Down
5 changes: 0 additions & 5 deletions ash/shell_delegate_mus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "ash/accessibility/default_accessibility_delegate.h"
#include "ash/screenshot_delegate.h"
#include "ash/wallpaper/wallpaper_delegate_mus.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "components/user_manager/user_info_impl.h"
Expand Down Expand Up @@ -96,10 +95,6 @@ ShellDelegateMus::CreateScreenshotDelegate() {
return std::make_unique<ScreenshotDelegateMash>();
}

std::unique_ptr<WallpaperDelegate> ShellDelegateMus::CreateWallpaperDelegate() {
return std::make_unique<WallpaperDelegateMus>();
}

AccessibilityDelegate* ShellDelegateMus::CreateAccessibilityDelegate() {
return new DefaultAccessibilityDelegate;
}
Expand Down
1 change: 0 additions & 1 deletion ash/shell_delegate_mus.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class ShellDelegateMus : public ShellDelegate {
void OpenUrlFromArc(const GURL& url) override;
NetworkingConfigDelegate* GetNetworkingConfigDelegate() override;
std::unique_ptr<ScreenshotDelegate> CreateScreenshotDelegate() override;
std::unique_ptr<WallpaperDelegate> CreateWallpaperDelegate() override;
AccessibilityDelegate* CreateAccessibilityDelegate() override;
ui::InputDeviceControllerClient* GetInputDeviceControllerClient() override;

Expand Down
1 change: 0 additions & 1 deletion ash/shell_port_mus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "ash/shell.h"
#include "ash/touch/touch_transform_setter_mus.h"
#include "ash/virtual_keyboard_controller.h"
#include "ash/wallpaper/wallpaper_delegate.h"
#include "ash/window_manager.h"
#include "ash/wm/drag_window_resizer.h"
#include "ash/wm/mru_window_tracker.h"
Expand Down
6 changes: 0 additions & 6 deletions ash/test_shell_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "ash/test_shell_delegate.h"

#include "ash/accessibility/default_accessibility_delegate.h"
#include "ash/default_wallpaper_delegate.h"
#include "ash/keyboard/test_keyboard_ui.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/test_screenshot_delegate.h"
Expand Down Expand Up @@ -53,11 +52,6 @@ TestShellDelegate::CreateScreenshotDelegate() {
return std::make_unique<TestScreenshotDelegate>();
}

std::unique_ptr<WallpaperDelegate>
TestShellDelegate::CreateWallpaperDelegate() {
return std::make_unique<DefaultWallpaperDelegate>();
}

AccessibilityDelegate* TestShellDelegate::CreateAccessibilityDelegate() {
return new DefaultAccessibilityDelegate;
}
Expand Down
1 change: 0 additions & 1 deletion ash/test_shell_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class TestShellDelegate : public ShellDelegate {
void OpenUrlFromArc(const GURL& url) override;
NetworkingConfigDelegate* GetNetworkingConfigDelegate() override;
std::unique_ptr<ScreenshotDelegate> CreateScreenshotDelegate() override;
std::unique_ptr<WallpaperDelegate> CreateWallpaperDelegate() override;
AccessibilityDelegate* CreateAccessibilityDelegate() override;
ui::InputDeviceControllerClient* GetInputDeviceControllerClient() override;

Expand Down
6 changes: 5 additions & 1 deletion ash/wallpaper/wallpaper_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "ash/shell_delegate.h"
#include "ash/wallpaper/wallpaper_controller_observer.h"
#include "ash/wallpaper/wallpaper_decoder.h"
#include "ash/wallpaper/wallpaper_delegate.h"
#include "ash/wallpaper/wallpaper_view.h"
#include "ash/wallpaper/wallpaper_widget_controller.h"
#include "base/bind.h"
Expand Down Expand Up @@ -1357,6 +1356,11 @@ void WallpaperController::RemovePolicyWallpaper(
SetDefaultWallpaper(std::move(user_info), wallpaper_files_id, show_wallpaper);
}

void WallpaperController::SetAnimationDuration(
base::TimeDelta animation_duration) {
animation_duration_ = animation_duration;
}

void WallpaperController::OpenWallpaperPickerIfAllowed() {
if (wallpaper_controller_client_ && CanOpenWallpaperPicker()) {
wallpaper_controller_client_->OpenWallpaperPicker();
Expand Down
6 changes: 6 additions & 0 deletions ash/wallpaper/wallpaper_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ class ASH_EXPORT WallpaperController
// no wallpaper.
wallpaper::WallpaperType GetWallpaperType() const;

base::TimeDelta animation_duration() const { return animation_duration_; }

// Returns true if the slower initial animation should be shown (as opposed to
// the faster animation that's used e.g. when switching between different
// wallpapers at login screen).
Expand Down Expand Up @@ -381,6 +383,7 @@ class ASH_EXPORT WallpaperController
const std::string& wallpaper_files_id) override;
void RemovePolicyWallpaper(mojom::WallpaperUserInfoPtr user_info,
const std::string& wallpaper_files_id) override;
void SetAnimationDuration(base::TimeDelta animation_duration) override;
void OpenWallpaperPickerIfAllowed() override;
void AddObserver(mojom::WallpaperObserverAssociatedPtrInfo observer) override;
void GetWallpaperColors(GetWallpaperColorsCallback callback) override;
Expand Down Expand Up @@ -600,6 +603,9 @@ class ASH_EXPORT WallpaperController

bool is_wallpaper_blurred_ = false;

// The wallpaper animation duration. An empty value disables the animation.
base::TimeDelta animation_duration_;

// Whether the device wallpaper policy is enforced on this device.
bool is_device_wallpaper_policy_enforced_ = false;

Expand Down
26 changes: 0 additions & 26 deletions ash/wallpaper/wallpaper_delegate.h

This file was deleted.

23 changes: 0 additions & 23 deletions ash/wallpaper/wallpaper_delegate_mus.cc

This file was deleted.

28 changes: 0 additions & 28 deletions ash/wallpaper/wallpaper_delegate_mus.h

This file was deleted.

11 changes: 4 additions & 7 deletions ash/wallpaper/wallpaper_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "ash/shell.h"
#include "ash/shell_port.h"
#include "ash/wallpaper/wallpaper_controller.h"
#include "ash/wallpaper/wallpaper_delegate.h"
#include "ash/wallpaper/wallpaper_widget_controller.h"
#include "ash/wm/overview/window_selector_controller.h"
#include "ash/wm/window_animation_types.h"
Expand Down Expand Up @@ -267,12 +266,10 @@ views::Widget* CreateWallpaperWidget(aura::Window* root_window,
Shell::Get()->session_controller()->NumberOfLoggedInUsers()) {
::wm::SetWindowVisibilityAnimationTransition(wallpaper_window,
::wm::ANIMATE_SHOW);
int duration_override =
Shell::Get()->wallpaper_delegate()->GetAnimationDurationOverride();
if (duration_override) {
::wm::SetWindowVisibilityAnimationDuration(
wallpaper_window,
base::TimeDelta::FromMilliseconds(duration_override));
base::TimeDelta animation_duration = controller->animation_duration();
if (!animation_duration.is_zero()) {
::wm::SetWindowVisibilityAnimationDuration(wallpaper_window,
animation_duration);
}
} else {
// Disable animation if transition to login screen from an empty background.
Expand Down
Loading

0 comments on commit b888661

Please sign in to comment.