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..4249b4a4e6ad482ef4bb073ebf357b0cde98fc5c 100644 |
--- a/ash/desktop_background/desktop_background_controller.cc |
+++ b/ash/desktop_background/desktop_background_controller.cc |
@@ -155,13 +155,14 @@ 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) { |
+ wallpaper_reload_delay_( |
+ base::TimeDelta::FromMilliseconds(kWallpaperReloadDelayMs)) { |
Shell::GetInstance()->display_controller()->AddObserver(this); |
+ InitWallpaperPathsFromCommandLine(base::CommandLine::ForCurrentProcess()); |
} |
DesktopBackgroundController::~DesktopBackgroundController() { |
@@ -169,12 +170,6 @@ DesktopBackgroundController::~DesktopBackgroundController() { |
Shell::GetInstance()->display_controller()->RemoveObserver(this); |
} |
-gfx::ImageSkia DesktopBackgroundController::GetWallpaper() const { |
- if (current_wallpaper_) |
- return current_wallpaper_->image(); |
- return gfx::ImageSkia(); |
-} |
- |
void DesktopBackgroundController::AddObserver( |
DesktopBackgroundControllerObserver* observer) { |
observers_.AddObserver(observer); |
@@ -191,6 +186,12 @@ WallpaperLayout DesktopBackgroundController::GetWallpaperLayout() const { |
return WALLPAPER_LAYOUT_CENTER_CROPPED; |
} |
+gfx::ImageSkia DesktopBackgroundController::GetWallpaper() const { |
+ if (current_wallpaper_) |
+ return current_wallpaper_->image(); |
+ return gfx::ImageSkia(); |
+} |
+ |
void DesktopBackgroundController::OnRootWindowAdded(aura::Window* root_window) { |
// The background hasn't been set yet. |
if (desktop_background_mode_ == BACKGROUND_NONE) |
@@ -208,29 +209,41 @@ void DesktopBackgroundController::OnRootWindowAdded(aura::Window* root_window) { |
InstallDesktopController(root_window); |
} |
+void DesktopBackgroundController::InitWallpaperPathsFromCommandLine( |
+ base::CommandLine* cl) { |
+ small_default_wallpaper_path_ = |
+ cl->GetSwitchValuePath(switches::kAshDefaultWallpaperSmall); |
+ large_default_wallpaper_path_ = |
+ cl->GetSwitchValuePath(switches::kAshDefaultWallpaperLarge); |
+ small_guest_wallpaper_path_ = |
+ cl->GetSwitchValuePath(switches::kAshGuestWallpaperSmall); |
+ large_guest_wallpaper_path_ = |
+ cl->GetSwitchValuePath(switches::kAshGuestWallpaperLarge); |
+} |
+ |
+void DesktopBackgroundController::SetDefaultWallpaperPaths( |
+ const base::FilePath& small_path, |
+ const base::FilePath& large_path, |
+ bool is_guest) { |
+ base::FilePath old_path; |
+ WallpaperLayout old_layout; |
+ GetDefaultWallpaperInfo(is_guest, &old_path, &old_layout, NULL, NULL); |
Alexander Alekseev
2014/03/24 23:04:12
This call returns "Future wallpaper parameters, th
Daniel Erat
2014/03/24 23:12:05
"first of all" -> is this the only concern?
is yo
|
+ |
+ small_default_wallpaper_path_ = small_path; |
+ large_default_wallpaper_path_ = large_path; |
Alexander Alekseev
2014/03/24 23:04:12
if (is_guest) {
...
} else {
...
}
?
Daniel Erat
2014/03/24 23:12:05
do you need to override the default guest wallpape
|
+ |
+ // If the default was previously in use, update it. |
+ if (DefaultWallpaperIsAlreadyLoadingOrLoaded(old_path, old_layout)) |
+ SetDefaultWallpaper(is_guest); |
+} |
+ |
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); |
+ int resource_id; |
+ WallpaperLayout file_layout, resource_layout; |
+ GetDefaultWallpaperInfo( |
+ is_guest, &file_path, &file_layout, &resource_id, &resource_layout); |
if (DefaultWallpaperIsAlreadyLoadingOrLoaded(file_path, resource_id)) { |
VLOG(1) << "Default wallpaper is already loading or loaded"; |
@@ -320,14 +333,43 @@ void DesktopBackgroundController::OnDisplayConfigurationChanged() { |
if (desktop_background_mode_ == BACKGROUND_IMAGE && |
current_wallpaper_.get()) { |
timer_.Stop(); |
- timer_.Start(FROM_HERE, |
- base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_), |
- this, |
+ timer_.Start(FROM_HERE, wallpaper_reload_delay_, this, |
&DesktopBackgroundController::UpdateWallpaper); |
} |
} |
} |
+void DesktopBackgroundController::GetDefaultWallpaperInfo( |
+ bool is_guest, |
+ base::FilePath* file_path, |
+ WallpaperLayout* file_layout, |
+ int* resource_id, |
+ WallpaperLayout* resource_layout) { |
+ const bool use_large = |
+ GetAppropriateResolution() == WALLPAPER_RESOLUTION_LARGE; |
+ |
+ if (file_path) { |
+ if (is_guest) { |
+ *file_path = use_large ? large_guest_wallpaper_path_ : |
+ small_guest_wallpaper_path_; |
+ } else { |
+ *file_path = use_large ? large_default_wallpaper_path_ : |
+ small_default_wallpaper_path_; |
+ } |
+ } |
+ if (file_layout) { |
+ *file_layout = use_large ? WALLPAPER_LAYOUT_CENTER_CROPPED : |
+ WALLPAPER_LAYOUT_CENTER; |
+ } |
+ |
+ if (resource_id) { |
+ *resource_id = use_large ? IDR_AURA_WALLPAPER_DEFAULT_LARGE : |
+ IDR_AURA_WALLPAPER_DEFAULT_SMALL; |
+ } |
+ if (resource_layout) |
+ *resource_layout = WALLPAPER_LAYOUT_TILE; |
+} |
+ |
bool DesktopBackgroundController::DefaultWallpaperIsAlreadyLoadingOrLoaded( |
const base::FilePath& image_file, |
int image_resource_id) const { |