Chromium Code Reviews| Index: ash/desktop_background/desktop_background_controller.cc |
| diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc |
| index 7673f29aa6a48d9439e9397c4663105e09f001b3..4e57f9e4bc35dda9d394b8b36b17cca0a9316f2f 100644 |
| --- a/ash/desktop_background/desktop_background_controller.cc |
| +++ b/ash/desktop_background/desktop_background_controller.cc |
| @@ -155,17 +155,13 @@ class DesktopBackgroundController::WallpaperLoader |
| }; |
| DesktopBackgroundController::DesktopBackgroundController() |
| - : command_line_for_testing_(NULL), |
| - locked_(false), |
| + : locked_(false), |
| desktop_background_mode_(BACKGROUND_NONE), |
| - current_default_wallpaper_resource_id_(-1), |
| - weak_ptr_factory_(this), |
| wallpaper_reload_delay_(kWallpaperReloadDelayMs) { |
| Shell::GetInstance()->display_controller()->AddObserver(this); |
| } |
| DesktopBackgroundController::~DesktopBackgroundController() { |
| - CancelDefaultWallpaperLoader(); |
| Shell::GetInstance()->display_controller()->RemoveObserver(this); |
| } |
| @@ -208,55 +204,11 @@ void DesktopBackgroundController::OnRootWindowAdded(aura::Window* root_window) { |
| InstallDesktopController(root_window); |
| } |
| -bool DesktopBackgroundController::SetDefaultWallpaper(bool is_guest) { |
| - VLOG(1) << "SetDefaultWallpaper: is_guest=" << is_guest; |
| - const bool use_large = |
| - GetAppropriateResolution() == WALLPAPER_RESOLUTION_LARGE; |
| - |
| - base::FilePath file_path; |
| - WallpaperLayout file_layout = use_large ? WALLPAPER_LAYOUT_CENTER_CROPPED : |
| - WALLPAPER_LAYOUT_CENTER; |
| - int resource_id = use_large ? IDR_AURA_WALLPAPER_DEFAULT_LARGE : |
| - IDR_AURA_WALLPAPER_DEFAULT_SMALL; |
| - WallpaperLayout resource_layout = WALLPAPER_LAYOUT_TILE; |
| - |
| - CommandLine* command_line = command_line_for_testing_ ? |
| - command_line_for_testing_ : CommandLine::ForCurrentProcess(); |
| - const char* switch_name = NULL; |
| - if (is_guest) { |
| - switch_name = use_large ? switches::kAshGuestWallpaperLarge : |
| - switches::kAshGuestWallpaperSmall; |
| - } else { |
| - switch_name = use_large ? switches::kAshDefaultWallpaperLarge : |
| - switches::kAshDefaultWallpaperSmall; |
| - } |
| - file_path = command_line->GetSwitchValuePath(switch_name); |
| - |
| - if (DefaultWallpaperIsAlreadyLoadingOrLoaded(file_path, resource_id)) { |
| - VLOG(1) << "Default wallpaper is already loading or loaded"; |
| - return false; |
| - } |
| - |
| - CancelDefaultWallpaperLoader(); |
| - default_wallpaper_loader_ = new WallpaperLoader( |
| - file_path, file_layout, resource_id, resource_layout); |
| - base::WorkerPool::PostTaskAndReply( |
| - FROM_HERE, |
| - base::Bind(&WallpaperLoader::LoadOnWorkerPoolThread, |
| - default_wallpaper_loader_), |
| - base::Bind(&DesktopBackgroundController::OnDefaultWallpaperLoadCompleted, |
| - weak_ptr_factory_.GetWeakPtr(), |
| - default_wallpaper_loader_), |
| - true /* task_is_slow */); |
| - return true; |
| -} |
| - |
| void DesktopBackgroundController::SetCustomWallpaper( |
| const gfx::ImageSkia& image, |
| WallpaperLayout layout) { |
| VLOG(1) << "SetCustomWallpaper: image_id=" |
| << WallpaperResizer::GetImageId(image) << " layout=" << layout; |
| - CancelDefaultWallpaperLoader(); |
| if (CustomWallpaperIsAlreadyLoaded(image)) { |
| VLOG(1) << "Custom wallpaper is already loaded"; |
| @@ -267,23 +219,11 @@ void DesktopBackgroundController::SetCustomWallpaper( |
| image, GetMaxDisplaySizeInNative(), layout)); |
| current_wallpaper_->StartResize(); |
| - current_default_wallpaper_path_ = base::FilePath(); |
| - current_default_wallpaper_resource_id_ = -1; |
| - |
| FOR_EACH_OBSERVER(DesktopBackgroundControllerObserver, observers_, |
| OnWallpaperDataChanged()); |
| SetDesktopBackgroundImageMode(); |
| } |
| -void DesktopBackgroundController::CancelDefaultWallpaperLoader() { |
| - // Set canceled flag of previous request to skip unneeded loading. |
| - if (default_wallpaper_loader_.get()) |
| - default_wallpaper_loader_->Cancel(); |
| - |
| - // Cancel reply callback for previous request. |
| - weak_ptr_factory_.InvalidateWeakPtrs(); |
| -} |
| - |
| void DesktopBackgroundController::CreateEmptyWallpaper() { |
|
Daniel Erat
2014/03/27 01:45:50
delete this if it's not called anymore
Alexander Alekseev
2014/03/31 14:15:40
It's used by Wallpapermanager, API, DefaultDelegat
|
| current_wallpaper_.reset(NULL); |
| SetDesktopBackgroundImageMode(); |
| @@ -328,18 +268,6 @@ void DesktopBackgroundController::OnDisplayConfigurationChanged() { |
| } |
| } |
| -bool DesktopBackgroundController::DefaultWallpaperIsAlreadyLoadingOrLoaded( |
| - const base::FilePath& image_file, |
| - int image_resource_id) const { |
| - return (default_wallpaper_loader_.get() && |
| - !default_wallpaper_loader_->IsCanceled() && |
| - default_wallpaper_loader_->file_path() == image_file && |
| - default_wallpaper_loader_->resource_id() == image_resource_id) || |
| - (current_wallpaper_.get() && |
| - current_default_wallpaper_path_ == image_file && |
| - current_default_wallpaper_resource_id_ == image_resource_id); |
| -} |
| - |
| bool DesktopBackgroundController::CustomWallpaperIsAlreadyLoaded( |
| const gfx::ImageSkia& image) const { |
| return current_wallpaper_.get() && |
| @@ -352,22 +280,6 @@ void DesktopBackgroundController::SetDesktopBackgroundImageMode() { |
| InstallDesktopControllerForAllWindows(); |
| } |
| -void DesktopBackgroundController::OnDefaultWallpaperLoadCompleted( |
| - scoped_refptr<WallpaperLoader> loader) { |
| - VLOG(1) << "OnDefaultWallpaperLoadCompleted"; |
| - current_wallpaper_.reset(loader->ReleaseWallpaperResizer()); |
| - current_wallpaper_->StartResize(); |
| - current_default_wallpaper_path_ = loader->file_path(); |
| - current_default_wallpaper_resource_id_ = loader->resource_id(); |
| - FOR_EACH_OBSERVER(DesktopBackgroundControllerObserver, observers_, |
| - OnWallpaperDataChanged()); |
| - |
| - SetDesktopBackgroundImageMode(); |
| - |
| - DCHECK(loader.get() == default_wallpaper_loader_.get()); |
| - default_wallpaper_loader_ = NULL; |
| -} |
| - |
| void DesktopBackgroundController::InstallDesktopController( |
| aura::Window* root_window) { |
| internal::DesktopBackgroundWidgetController* component = NULL; |
| @@ -445,8 +357,6 @@ int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { |
| void DesktopBackgroundController::UpdateWallpaper() { |
| current_wallpaper_.reset(NULL); |
| - current_default_wallpaper_path_ = base::FilePath(); |
| - current_default_wallpaper_resource_id_ = -1; |
| ash::Shell::GetInstance()->user_wallpaper_delegate()-> |
| UpdateWallpaper(true /* clear cache */); |
| } |