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 53d66f133e8b3fdb9fcba179b2cade68faf651b2..0881f31f8f487591eb0252ddb373777fc05e92eb 100644 |
--- a/chrome/browser/chromeos/login/user_manager.cc |
+++ b/chrome/browser/chromeos/login/user_manager.cc |
@@ -4,6 +4,7 @@ |
#include "chrome/browser/chromeos/login/user_manager.h" |
+#include "base/bind.h" |
#include "base/command_line.h" |
#include "base/compiler_specific.h" |
#include "base/file_path.h" |
@@ -11,6 +12,7 @@ |
#include "base/lazy_instance.h" |
#include "base/location.h" |
#include "base/logging.h" |
+#include "base/memory/weak_ptr.h" |
#include "base/metrics/histogram.h" |
#include "base/path_service.h" |
#include "base/rand_util.h" |
@@ -21,6 +23,7 @@ |
#include "base/values.h" |
#include "crypto/nss_util.h" |
#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/chromeos/cros_settings.h" |
#include "chrome/browser/chromeos/cros/cros_library.h" |
#include "chrome/browser/chromeos/cros/cryptohome_library.h" |
#include "chrome/browser/chromeos/input_method/input_method_manager.h" |
@@ -147,8 +150,8 @@ void SaveImageToFile(const SkBitmap& image, |
BrowserThread::PostTask( |
BrowserThread::UI, |
FROM_HERE, |
- NewRunnableFunction(&SaveImageToLocalState, |
- username, image_path.value(), image_index)); |
+ base::Bind(&SaveImageToLocalState, |
+ username, image_path.value(), image_index)); |
} |
// Deletes user's image file. Runs on FILE thread. |
@@ -188,7 +191,7 @@ void CheckOwnership() { |
BrowserThread::PostTask( |
BrowserThread::UI, |
FROM_HERE, |
- NewRunnableFunction(&UpdateOwnership, is_owner)); |
+ base::Bind(&UpdateOwnership, is_owner)); |
} |
// Used to handle the asynchronous response of deleting a cryptohome directory. |
@@ -200,7 +203,7 @@ class RemoveAttempt : public CryptohomeLibrary::Delegate { |
chromeos::RemoveUserDelegate* delegate) |
: user_email_(user_email), |
delegate_(delegate), |
- method_factory_(this) { |
+ pointer_factory_(this) { |
RemoveUser(); |
} |
@@ -209,15 +212,18 @@ class RemoveAttempt : public CryptohomeLibrary::Delegate { |
void RemoveUser() { |
// Owner is not allowed to be removed from the device. |
// Must not proceed without signature verification. |
- UserCrosSettingsProvider user_settings; |
- bool trusted_owner_available = user_settings.RequestTrustedOwner( |
- method_factory_.NewRunnableMethod(&RemoveAttempt::RemoveUser)); |
+ CrosSettings* cros_settings = CrosSettings::Get(); |
+ bool trusted_owner_available = cros_settings->GetTrusted( |
+ kDeviceOwner, |
+ base::Bind(&RemoveAttempt::RemoveUser, pointer_factory_.GetWeakPtr())); |
if (!trusted_owner_available) { |
// Value of owner email is still not verified. |
// Another attempt will be invoked after verification completion. |
return; |
} |
- if (user_email_ == UserCrosSettingsProvider::cached_owner()) { |
+ std::string owner; |
+ cros_settings->GetString(kDeviceOwner, &owner); |
+ if (user_email_ == owner) { |
// Owner is not allowed to be removed from the device. Probably on |
// the stack, so deffer the deletion. |
MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
@@ -255,7 +261,7 @@ class RemoveAttempt : public CryptohomeLibrary::Delegate { |
chromeos::RemoveUserDelegate* delegate_; |
// Factory of callbacks. |
- ScopedRunnableMethodFactory<RemoveAttempt> method_factory_; |
+ base::WeakPtrFactory<RemoveAttempt> pointer_factory_; |
DISALLOW_COPY_AND_ASSIGN(RemoveAttempt); |
}; |
@@ -547,8 +553,7 @@ void UserManager::RemoveUserFromList(const std::string& email) { |
BrowserThread::PostTask( |
BrowserThread::FILE, |
FROM_HERE, |
- NewRunnableFunction(&DeleteUserImage, |
- image_path)); |
+ base::Bind(&DeleteUserImage, image_path)); |
} |
} |
@@ -605,8 +610,8 @@ void UserManager::SaveUserImage(const std::string& username, |
BrowserThread::PostTask( |
BrowserThread::FILE, |
FROM_HERE, |
- NewRunnableFunction(&SaveImageToFile, |
- image, image_path, username, image_index)); |
+ base::Bind(&SaveImageToFile, |
+ image, image_path, username, image_index)); |
} |
void UserManager::SaveUserOAuthStatus(const std::string& username, |
@@ -770,7 +775,7 @@ void UserManager::NotifyOnLogin() { |
// Schedules current user ownership check on file thread. |
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
- NewRunnableFunction(&CheckOwnership)); |
+ base::Bind(&CheckOwnership)); |
} |
void UserManager::Observe(int type, |
@@ -778,7 +783,7 @@ void UserManager::Observe(int type, |
const NotificationDetails& details) { |
if (type == chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) { |
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
- NewRunnableFunction(&CheckOwnership)); |
+ base::Bind(&CheckOwnership)); |
} |
} |