| Index: chrome/browser/chromeos/login/user_manager.cc
|
| diff --git a/chrome/browser/chromeos/login/user_manager.cc b/chrome/browser/chromeos/login/user_manager.cc
|
| index 250f7bc8ab479d3d28d44d5b6d9177dd9638c3b0..05d95f2437e995884f200ac6d903f54829d1b1ba 100644
|
| --- a/chrome/browser/chromeos/login/user_manager.cc
|
| +++ b/chrome/browser/chromeos/login/user_manager.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/compiler_specific.h"
|
| #include "base/file_path.h"
|
| #include "base/file_util.h"
|
| +#include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| #include "base/nss_util.h"
|
| #include "base/path_service.h"
|
| @@ -64,8 +65,7 @@ const int kDefaultImageResources[] = {
|
| IDR_LOGIN_DEFAULT_USER_4
|
| };
|
|
|
| -// The one true UserManager.
|
| -static UserManager* user_manager_ = NULL;
|
| +base::LazyInstance<UserManager> g_user_manager(base::LINKER_INITIALIZED);
|
|
|
| // Stores path to the image in local state. Runs on UI thread.
|
| void SavePathToLocalState(const std::string& username,
|
| @@ -132,13 +132,14 @@ bool IsDefaultImagePath(const std::string& path, size_t* image_id) {
|
| void UpdateOwnership(bool is_owner) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| - UserManager* user_manager = UserManager::Get();
|
| - user_manager->set_current_user_is_owner(is_owner);
|
| -
|
| + g_user_manager.Get().set_current_user_is_owner(is_owner);
|
| + NotificationService::current()->Notify(NotificationType::OWNERSHIP_CHECKED,
|
| + NotificationService::AllSources(),
|
| + NotificationService::NoDetails());
|
| if (is_owner) {
|
| // Also update cached value.
|
| UserCrosSettingsProvider::UpdateCachedOwner(
|
| - user_manager->logged_in_user().email());
|
| + g_user_manager.Get().logged_in_user().email());
|
| }
|
| }
|
|
|
| @@ -148,6 +149,8 @@ void CheckOwnership() {
|
| bool is_owner = OwnershipService::GetSharedInstance()->CurrentUserIsOwner();
|
| VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner");
|
|
|
| + g_user_manager.Get().set_current_user_is_owner(is_owner);
|
| +
|
| // UserManager should be accessed only on UI thread.
|
| BrowserThread::PostTask(
|
| BrowserThread::UI,
|
| @@ -258,9 +261,7 @@ std::string UserManager::User::GetNameTooltip() const {
|
| UserManager* UserManager::Get() {
|
| // Not thread-safe.
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - if (!user_manager_)
|
| - user_manager_ = new UserManager();
|
| - return user_manager_;
|
| + return &g_user_manager.Get();
|
| }
|
|
|
| // static
|
| @@ -576,10 +577,12 @@ void UserManager::Observe(NotificationType type,
|
| }
|
|
|
| bool UserManager::current_user_is_owner() const {
|
| + base::AutoLock lk(current_user_is_owner_lock_);
|
| return current_user_is_owner_;
|
| }
|
|
|
| void UserManager::set_current_user_is_owner(bool current_user_is_owner) {
|
| + base::AutoLock lk(current_user_is_owner_lock_);
|
| current_user_is_owner_ = current_user_is_owner;
|
| }
|
|
|
|
|