diff options
Diffstat (limited to 'chrome/browser/ui/webui/options2')
-rw-r--r-- | chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc | 37 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.h | 4 |
2 files changed, 27 insertions, 14 deletions
diff --git a/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc index a7f7c78..ecef6d7 100644 --- a/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc +++ b/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc @@ -65,8 +65,8 @@ void SetWallpaperOptionsHandler::GetLocalizedValues( l10n_util::GetStringUTF16(IDS_OPTIONS_SET_WALLPAPER_DIALOG_TEXT)); localized_strings->SetString("setWallpaperAuthor", l10n_util::GetStringUTF16(IDS_OPTIONS_SET_WALLPAPER_AUTHOR_TEXT)); - localized_strings->SetString("randomCheckbox", - l10n_util::GetStringUTF16(IDS_OPTIONS_SET_WALLPAPER_RANDOM)); + localized_strings->SetString("dailyWallpaperLabel", + l10n_util::GetStringUTF16(IDS_OPTIONS_SET_WALLPAPER_DAILY)); localized_strings->SetString("customWallpaper", l10n_util::GetStringUTF16(IDS_OPTIONS_CUSTOME_WALLPAPER)); } @@ -81,8 +81,8 @@ void SetWallpaperOptionsHandler::RegisterMessages() { web_ui()->RegisterMessageCallback("selectDefaultWallpaper", base::Bind(&SetWallpaperOptionsHandler::HandleDefaultWallpaper, base::Unretained(this))); - web_ui()->RegisterMessageCallback("selectRandomWallpaper", - base::Bind(&SetWallpaperOptionsHandler::HandleRandomWallpaper, + web_ui()->RegisterMessageCallback("selectDailyWallpaper", + base::Bind(&SetWallpaperOptionsHandler::HandleDailyWallpaper, base::Unretained(this))); web_ui()->RegisterMessageCallback("chooseWallpaper", base::Bind(&SetWallpaperOptionsHandler::HandleChooseFile, @@ -161,9 +161,17 @@ void SetWallpaperOptionsHandler::HandlePageShown(const base::ListValue* args) { DCHECK(args && args->empty()); User::WallpaperType type; int index; - UserManager::Get()->GetLoggedInUserWallpaperProperties(&type, &index); + base::Time date; + UserManager::Get()->GetLoggedInUserWallpaperProperties(&type, &index, &date); + if (type == User::DAILY && date != base::Time::Now().LocalMidnight()) { + index = ash::GetNextWallpaperIndex(index); + UserManager::Get()->SaveLoggedInUserWallpaperProperties(User::DAILY, + index); + ash::Shell::GetInstance()->user_wallpaper_delegate()-> + InitializeWallpaper(); + } base::StringValue image_url(GetDefaultWallpaperThumbnailURL(index)); - base::FundamentalValue is_random(type == User::RANDOM); + base::FundamentalValue is_daily(type == User::DAILY); if (type == User::CUSTOMIZED) { ash::WallpaperLayout layout = static_cast<ash::WallpaperLayout>(index); SendLayoutOptions(layout); @@ -171,7 +179,7 @@ void SetWallpaperOptionsHandler::HandlePageShown(const base::ListValue* args) { } else { SendLayoutOptions(ash::CENTER_CROPPED); web_ui()->CallJavascriptFunction("SetWallpaperOptions.setSelectedImage", - image_url, is_random); + image_url, is_daily); } } @@ -224,15 +232,20 @@ void SetWallpaperOptionsHandler::HandleDefaultWallpaper(const ListValue* args) { } } -void SetWallpaperOptionsHandler::HandleRandomWallpaper(const ListValue* args) { - int index = ash::GetRandomWallpaperIndex(); - UserManager::Get()->SaveLoggedInUserWallpaperProperties(User::RANDOM, index); +void SetWallpaperOptionsHandler::HandleDailyWallpaper(const ListValue* args) { + User::WallpaperType type; + int index; + base::Time date; + UserManager::Get()->GetLoggedInUserWallpaperProperties(&type, &index, &date); + if (date != base::Time::Now().LocalMidnight()) + index = ash::GetNextWallpaperIndex(index); + UserManager::Get()->SaveLoggedInUserWallpaperProperties(User::DAILY, index); ash::Shell::GetInstance()->desktop_background_controller()-> SetDefaultWallpaper(index); base::StringValue image_url(GetDefaultWallpaperThumbnailURL(index)); - base::FundamentalValue is_random(true); + base::FundamentalValue is_daily(true); web_ui()->CallJavascriptFunction("SetWallpaperOptions.setSelectedImage", - image_url, is_random); + image_url, is_daily); } gfx::NativeWindow SetWallpaperOptionsHandler::GetBrowserWindow() const { diff --git a/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.h b/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.h index 6bcf981..6c8907e 100644 --- a/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.h +++ b/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.h @@ -76,8 +76,8 @@ class SetWallpaperOptionsHandler : public ::options2::OptionsPageUIHandler, // Selects one of the available default wallpapers. void HandleDefaultWallpaper(const base::ListValue* args); - // Sets user wallpaper to a random one from the default wallpapers. - void HandleRandomWallpaper(const base::ListValue* args); + // Sets user wallpaper to the next one in the list of default wallpapers. + void HandleDailyWallpaper(const base::ListValue* args); // Returns handle to browser window or NULL if it can't be found. gfx::NativeWindow GetBrowserWindow() const; |