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

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

Issue 23494053: Remove NOTIFICATION_SYSTEM_SETTING_CHANGED, switch CrosSettings to base::CallbackRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 7 years, 3 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 <vector> 7 #include <vector>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 WallpaperManager::~WallpaperManager() { 156 WallpaperManager::~WallpaperManager() {
157 // TODO(bshe): Lifetime of WallpaperManager needs more consideration. 157 // TODO(bshe): Lifetime of WallpaperManager needs more consideration.
158 // http://crbug.com/171694 158 // http://crbug.com/171694
159 DCHECK(no_observers_); 159 DCHECK(no_observers_);
160 ClearObsoleteWallpaperPrefs(); 160 ClearObsoleteWallpaperPrefs();
161 weak_factory_.InvalidateWeakPtrs(); 161 weak_factory_.InvalidateWeakPtrs();
162 } 162 }
163 163
164 void WallpaperManager::Shutdown() { 164 void WallpaperManager::Shutdown() {
165 CrosSettings::Get()->RemoveSettingsObserver( 165 show_user_name_on_signin_subscription_.reset();
166 kAccountsPrefShowUserNamesOnSignIn, this);
167 no_observers_ = true; 166 no_observers_ = true;
Mattias Nissler (ping if slow) 2013/09/18 09:09:48 You probably want to nuke |no_observers_| and repl
Avi (use Gerrit) 2013/09/18 16:41:44 Done.
168 } 167 }
169 168
170 // static 169 // static
171 void WallpaperManager::RegisterPrefs(PrefRegistrySimple* registry) { 170 void WallpaperManager::RegisterPrefs(PrefRegistrySimple* registry) {
172 registry->RegisterDictionaryPref(prefs::kUsersWallpaperInfo); 171 registry->RegisterDictionaryPref(prefs::kUsersWallpaperInfo);
173 registry->RegisterDictionaryPref(kUserWallpapers); 172 registry->RegisterDictionaryPref(kUserWallpapers);
174 registry->RegisterDictionaryPref(kUserWallpapersProperties); 173 registry->RegisterDictionaryPref(kUserWallpapersProperties);
175 } 174 }
176 175
177 void WallpaperManager::AddObservers() { 176 void WallpaperManager::AddObservers() {
178 CrosSettings::Get()->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, 177 show_user_name_on_signin_subscription_ =
179 this); 178 CrosSettings::Get()->AddSettingsObserver(
179 kAccountsPrefShowUserNamesOnSignIn,
180 base::Bind(&WallpaperManager::InitializeRegisteredDeviceWallpaper,
181 base::Unretained(this)));
180 no_observers_ = false; 182 no_observers_ = false;
181 } 183 }
182 184
183 void WallpaperManager::EnsureLoggedInUserWallpaperLoaded() { 185 void WallpaperManager::EnsureLoggedInUserWallpaperLoaded() {
184 // Some browser tests do not have a shell instance. As no wallpaper is needed 186 // Some browser tests do not have a shell instance. As no wallpaper is needed
185 // in these tests anyway, avoid loading one, preventing crashes and speeding 187 // in these tests anyway, avoid loading one, preventing crashes and speeding
186 // up the tests. 188 // up the tests.
187 if (!ash::Shell::HasInstance()) 189 if (!ash::Shell::HasInstance())
188 return; 190 return;
189 191
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 if (should_cache_wallpaper_) { 319 if (should_cache_wallpaper_) {
318 BrowserThread::PostDelayedTask( 320 BrowserThread::PostDelayedTask(
319 BrowserThread::UI, FROM_HERE, 321 BrowserThread::UI, FROM_HERE,
320 base::Bind(&WallpaperManager::CacheUsersWallpapers, 322 base::Bind(&WallpaperManager::CacheUsersWallpapers,
321 weak_factory_.GetWeakPtr()), 323 weak_factory_.GetWeakPtr()),
322 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); 324 base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs));
323 should_cache_wallpaper_ = false; 325 should_cache_wallpaper_ = false;
324 } 326 }
325 break; 327 break;
326 } 328 }
327 case chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED: {
328 if (*content::Details<const std::string>(details).ptr() ==
329 kAccountsPrefShowUserNamesOnSignIn) {
330 InitializeRegisteredDeviceWallpaper();
331 }
332 break;
333 }
334 default: 329 default:
335 NOTREACHED() << "Unexpected notification " << type; 330 NOTREACHED() << "Unexpected notification " << type;
336 } 331 }
337 } 332 }
338 333
339 void WallpaperManager::RemoveUserWallpaperInfo(const std::string& email) { 334 void WallpaperManager::RemoveUserWallpaperInfo(const std::string& email) {
340 PrefService* prefs = g_browser_process->local_state(); 335 PrefService* prefs = g_browser_process->local_state();
341 DictionaryPrefUpdate prefs_wallpapers_info_update(prefs, 336 DictionaryPrefUpdate prefs_wallpapers_info_update(prefs,
342 prefs::kUsersWallpaperInfo); 337 prefs::kUsersWallpaperInfo);
343 prefs_wallpapers_info_update->RemoveWithoutPathExpansion(email, NULL); 338 prefs_wallpapers_info_update->RemoveWithoutPathExpansion(email, NULL);
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 // |sequence_token_| here. 1086 // |sequence_token_| here.
1092 wallpaper_loader_->Start(wallpaper_path.value(), 0, sequence_token_, 1087 wallpaper_loader_->Start(wallpaper_path.value(), 0, sequence_token_,
1093 base::Bind(&WallpaperManager::OnWallpaperDecoded, 1088 base::Bind(&WallpaperManager::OnWallpaperDecoded,
1094 base::Unretained(this), 1089 base::Unretained(this),
1095 email, 1090 email,
1096 info.layout, 1091 info.layout,
1097 update_wallpaper)); 1092 update_wallpaper));
1098 } 1093 }
1099 1094
1100 } // namespace chromeos 1095 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698