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

Side by Side Diff: chrome/browser/chromeos/login/wallpaper_manager.cc

Issue 190993003: Invalidate all wallpaper cache if display configuration changed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/chromeos/login/wallpaper_manager.h" 5 #include "chrome/browser/chromeos/login/wallpaper_manager.h"
6 6
7 #include <numeric> 7 #include <numeric>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 const std::string& user_id, gfx::ImageSkia* image) { 282 const std::string& user_id, gfx::ImageSkia* image) {
283 return wallpaper_manager_->GetWallpaperFromCache(user_id, image); 283 return wallpaper_manager_->GetWallpaperFromCache(user_id, image);
284 } 284 }
285 285
286 void WallpaperManager::TestApi::SetWallpaperCache(const std::string& user_id, 286 void WallpaperManager::TestApi::SetWallpaperCache(const std::string& user_id,
287 const gfx::ImageSkia& image) { 287 const gfx::ImageSkia& image) {
288 DCHECK(!image.isNull()); 288 DCHECK(!image.isNull());
289 wallpaper_manager_->wallpaper_cache_[user_id] = image; 289 wallpaper_manager_->wallpaper_cache_[user_id] = image;
290 } 290 }
291 291
292 void WallpaperManager::TestApi::ClearWallpaperCache() { 292 void WallpaperManager::TestApi::ClearDisposableWallpaperCache() {
293 wallpaper_manager_->ClearWallpaperCache(); 293 wallpaper_manager_->ClearDisposableWallpaperCache();
294 } 294 }
295 295
296 // static 296 // static
297 WallpaperManager* WallpaperManager::Get() { 297 WallpaperManager* WallpaperManager::Get() {
298 if (!g_wallpaper_manager) 298 if (!g_wallpaper_manager)
299 g_wallpaper_manager = new WallpaperManager(); 299 g_wallpaper_manager = new WallpaperManager();
300 return g_wallpaper_manager; 300 return g_wallpaper_manager;
301 } 301 }
302 302
303 WallpaperManager::WallpaperManager() 303 WallpaperManager::WallpaperManager()
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 WallpaperInfo info; 363 WallpaperInfo info;
364 if (GetLoggedInUserWallpaperInfo(&info)) { 364 if (GetLoggedInUserWallpaperInfo(&info)) {
365 // TODO(sschmitz): We need an index for default wallpapers for the new UI. 365 // TODO(sschmitz): We need an index for default wallpapers for the new UI.
366 RecordUma(info.type, -1); 366 RecordUma(info.type, -1);
367 if (info == current_user_wallpaper_info_) 367 if (info == current_user_wallpaper_info_)
368 return; 368 return;
369 } 369 }
370 SetUserWallpaperNow(UserManager::Get()->GetLoggedInUser()->email()); 370 SetUserWallpaperNow(UserManager::Get()->GetLoggedInUser()->email());
371 } 371 }
372 372
373 void WallpaperManager::ClearWallpaperCache() { 373 void WallpaperManager::ClearDisposableWallpaperCache() {
374 // Cancel callback for previous cache requests. 374 // Cancel callback for previous cache requests.
375 weak_factory_.InvalidateWeakPtrs(); 375 weak_factory_.InvalidateWeakPtrs();
376 if (!UserManager::IsMultipleProfilesAllowed()) { 376 if (!UserManager::IsMultipleProfilesAllowed()) {
377 wallpaper_cache_.clear(); 377 wallpaper_cache_.clear();
378 } else { 378 } else {
379 // Keep the wallpaper of logged in users in cache at multi-profile mode. 379 // Keep the wallpaper of logged in users in cache at multi-profile mode.
380 std::set<std::string> logged_in_users_names; 380 std::set<std::string> logged_in_users_names;
381 const UserList& logged_users = UserManager::Get()->GetLoggedInUsers(); 381 const UserList& logged_users = UserManager::Get()->GetLoggedInUsers();
382 for (UserList::const_iterator it = logged_users.begin(); 382 for (UserList::const_iterator it = logged_users.begin();
383 it != logged_users.end(); 383 it != logged_users.end();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 } 460 }
461 SetUserWallpaperDelayed(user_manager->GetLoggedInUser()->email()); 461 SetUserWallpaperDelayed(user_manager->GetLoggedInUser()->email());
462 } 462 }
463 463
464 void WallpaperManager::Observe(int type, 464 void WallpaperManager::Observe(int type,
465 const content::NotificationSource& source, 465 const content::NotificationSource& source,
466 const content::NotificationDetails& details) { 466 const content::NotificationDetails& details) {
467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
468 switch (type) { 468 switch (type) {
469 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { 469 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: {
470 ClearWallpaperCache(); 470 ClearDisposableWallpaperCache();
471 BrowserThread::PostDelayedTask( 471 BrowserThread::PostDelayedTask(
472 BrowserThread::UI, 472 BrowserThread::UI,
473 FROM_HERE, 473 FROM_HERE,
474 base::Bind(&WallpaperManager::MoveLoggedInUserCustomWallpaper, 474 base::Bind(&WallpaperManager::MoveLoggedInUserCustomWallpaper,
475 weak_factory_.GetWeakPtr()), 475 weak_factory_.GetWeakPtr()),
476 base::TimeDelta::FromSeconds(kMoveCustomWallpaperDelaySeconds)); 476 base::TimeDelta::FromSeconds(kMoveCustomWallpaperDelaySeconds));
477 break; 477 break;
478 } 478 }
479 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { 479 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: {
480 if (!GetComandLine()->HasSwitch(switches::kDisableBootAnimation)) { 480 if (!GetComandLine()->HasSwitch(switches::kDisableBootAnimation)) {
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 info.layout = layout; 821 info.layout = layout;
822 if (UserManager::IsMultipleProfilesAllowed()) 822 if (UserManager::IsMultipleProfilesAllowed())
823 wallpaper_cache_[user_id] = wallpaper; 823 wallpaper_cache_[user_id] = wallpaper;
824 824
825 if (update_wallpaper) { 825 if (update_wallpaper) {
826 GetPendingWallpaper(last_selected_user_, false /* Not delayed */) 826 GetPendingWallpaper(last_selected_user_, false /* Not delayed */)
827 ->ResetSetWallpaperImage(wallpaper, info); 827 ->ResetSetWallpaperImage(wallpaper, info);
828 } 828 }
829 } 829 }
830 830
831 void WallpaperManager::UpdateWallpaper() { 831 void WallpaperManager::UpdateWallpaper(bool clear_cache) {
832 ClearWallpaperCache(); 832 if (clear_cache)
833 wallpaper_cache_.clear();
833 current_wallpaper_path_.clear(); 834 current_wallpaper_path_.clear();
834 // For GAIA login flow, the last_selected_user_ may not be set before user 835 // For GAIA login flow, the last_selected_user_ may not be set before user
835 // login. If UpdateWallpaper is called at GAIA login screen, no wallpaper will 836 // login. If UpdateWallpaper is called at GAIA login screen, no wallpaper will
836 // be set. It could result a black screen on external monitors. 837 // be set. It could result a black screen on external monitors.
837 // See http://crbug.com/265689 for detail. 838 // See http://crbug.com/265689 for detail.
838 if (last_selected_user_.empty()) { 839 if (last_selected_user_.empty()) {
839 SetDefaultWallpaperNow(UserManager::kSignInUser); 840 SetDefaultWallpaperNow(UserManager::kSignInUser);
840 return; 841 return;
841 } 842 }
842 SetUserWallpaperNow(last_selected_user_); 843 SetUserWallpaperNow(last_selected_user_);
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 loading_.push_back(new WallpaperManager::PendingWallpaper( 1390 loading_.push_back(new WallpaperManager::PendingWallpaper(
1390 (delayed ? GetWallpaperLoadDelay() 1391 (delayed ? GetWallpaperLoadDelay()
1391 : base::TimeDelta::FromMilliseconds(0)), 1392 : base::TimeDelta::FromMilliseconds(0)),
1392 user_id)); 1393 user_id));
1393 pending_inactive_ = loading_.back(); 1394 pending_inactive_ = loading_.back();
1394 } 1395 }
1395 return pending_inactive_; 1396 return pending_inactive_;
1396 } 1397 }
1397 1398
1398 } // namespace chromeos 1399 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698