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

Unified Diff: chrome/browser/chromeos/login/user_manager_impl.cc

Issue 10832035: Switch from SignedSettings to DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More test fixing... Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/user_manager_impl.cc
diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc
index 9eb7b3c90c51482fdc25525e586937c5ef6ea219..40895dab9d6db253620ff7357a38810eff4d09ea 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/user_manager_impl.cc
@@ -6,8 +6,8 @@
#include <vector>
-#include "ash/shell.h"
#include "ash/desktop_background/desktop_background_controller.h"
+#include "ash/shell.h"
#include "base/bind.h"
#include "base/chromeos/chromeos_version.h"
#include "base/command_line.h"
@@ -34,7 +34,6 @@
#include "chrome/browser/chromeos/login/default_user_images.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/login_display.h"
-#include "chrome/browser/chromeos/login/ownership_service.h"
#include "chrome/browser/chromeos/login/remove_user_delegate.h"
#include "chrome/browser/chromeos/login/user_image.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
@@ -224,7 +223,7 @@ UserManagerImpl::UserManagerImpl()
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
MigrateWallpaperData();
- registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED,
+ registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED,
content::NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED,
content::NotificationService::AllSources());
@@ -233,7 +232,7 @@ UserManagerImpl::UserManagerImpl()
UserManagerImpl::~UserManagerImpl() {
// Can't use STLDeleteElements because of the private destructor of User.
- for (size_t i = 0; i < users_.size();++i)
+ for (size_t i = 0; i < users_.size(); ++i)
delete users_[i];
users_.clear();
if (is_current_user_ephemeral_)
@@ -676,13 +675,9 @@ void UserManagerImpl::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
- case chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED:
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- base::Bind(&UserManagerImpl::CheckOwnership,
- base::Unretained(this)));
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies,
- base::Unretained(this)));
+ case chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED:
+ CheckOwnership();
+ RetrieveTrustedDevicePolicies();
break;
case chrome::NOTIFICATION_PROFILE_ADDED:
if (IsUserLoggedIn() && !IsLoggedInAsGuest()) {
@@ -709,13 +704,13 @@ void UserManagerImpl::OnStateChanged() {
state != AuthError::CONNECTION_FAILED &&
state != AuthError::SERVICE_UNAVAILABLE &&
state != AuthError::REQUEST_CANCELED) {
- // Invalidate OAuth token to force Gaia sign-in flow. This is needed
- // because sign-out/sign-in solution is suggested to the user.
- // TODO(altimofeev): this code isn't needed after crosbug.com/25978 is
- // implemented.
- DVLOG(1) << "Invalidate OAuth token because of a sync error.";
- SaveUserOAuthStatus(GetLoggedInUser().email(),
- User::OAUTH_TOKEN_STATUS_INVALID);
+ // Invalidate OAuth token to force Gaia sign-in flow. This is needed
+ // because sign-out/sign-in solution is suggested to the user.
+ // TODO(altimofeev): this code isn't needed after crosbug.com/25978 is
+ // implemented.
+ DVLOG(1) << "Invalidate OAuth token because of a sync error.";
+ SaveUserOAuthStatus(GetLoggedInUser().email(),
+ User::OAUTH_TOKEN_STATUS_INVALID);
}
}
@@ -766,12 +761,12 @@ bool UserManagerImpl::IsSessionStarted() const {
return session_started_;
}
-void UserManagerImpl::AddObserver(Observer* obs) {
+void UserManagerImpl::AddObserver(UserManager::Observer* obs) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
observer_list_.AddObserver(obs);
}
-void UserManagerImpl::RemoveObserver(Observer* obs) {
+void UserManagerImpl::RemoveObserver(UserManager::Observer* obs) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
observer_list_.RemoveObserver(obs);
}
@@ -783,10 +778,8 @@ const SkBitmap& UserManagerImpl::DownloadedProfileImage() const {
void UserManagerImpl::NotifyLocalStateChanged() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- FOR_EACH_OBSERVER(
- Observer,
- observer_list_,
- LocalStateChanged(this));
+ FOR_EACH_OBSERVER(UserManager::Observer, observer_list_,
+ LocalStateChanged(this));
}
FilePath UserManagerImpl::GetImagePathForUser(const std::string& username) {
@@ -1008,10 +1001,9 @@ void UserManagerImpl::NotifyOnLogin() {
CrosLibrary::Get()->GetCertLibrary()->LoadKeyStore();
- // Schedules current user ownership check on file thread.
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- base::Bind(&UserManagerImpl::CheckOwnership,
- base::Unretained(this)));
+ // Indicate to DeviceSettingsService that the owner key may have become
+ // available.
+ DeviceSettingsService::Get()->SetUsername(logged_in_user_->email());
}
void UserManagerImpl::SetInitialUserImage(const std::string& username) {
@@ -1471,32 +1463,18 @@ void UserManagerImpl::DeleteUserImage(const FilePath& image_path) {
}
}
-void UserManagerImpl::UpdateOwnership(bool is_owner) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+void UserManagerImpl::UpdateOwnership(
+ DeviceSettingsService::OwnershipStatus status,
+ bool is_owner) {
+ VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner");
SetCurrentUserIsOwner(is_owner);
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_OWNERSHIP_CHECKED,
- content::NotificationService::AllSources(),
- content::NotificationService::NoDetails());
- if (is_owner) {
- // Also update cached value.
- CrosSettings::Get()->SetString(kDeviceOwner, GetLoggedInUser().email());
- }
}
void UserManagerImpl::CheckOwnership() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- bool is_owner = OwnershipService::GetSharedInstance()->IsCurrentUserOwner();
- VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner");
-
- // UserManagerImpl should be accessed only on UI thread.
- BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
+ DeviceSettingsService::Get()->GetOwnershipStatusAsync(
base::Bind(&UserManagerImpl::UpdateOwnership,
- base::Unretained(this),
- is_owner));
+ base::Unretained(this)));
}
// ProfileDownloaderDelegate override.

Powered by Google App Engine
This is Rietveld 408576698