| Index: chrome/browser/chromeos/login/user_manager_impl.cc
|
| diff --git a/chrome/browser/chromeos/login/user_manager.cc b/chrome/browser/chromeos/login/user_manager_impl.cc
|
| similarity index 85%
|
| copy from chrome/browser/chromeos/login/user_manager.cc
|
| copy to chrome/browser/chromeos/login/user_manager_impl.cc
|
| index 3b56995820865b357fa56d6669ff451387731f35..e8dab96e48c31ae9fbbd1b9eac940cb8b2b02d24 100644
|
| --- a/chrome/browser/chromeos/login/user_manager.cc
|
| +++ b/chrome/browser/chromeos/login/user_manager_impl.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/chromeos/login/user_manager.h"
|
| +#include "chrome/browser/chromeos/login/user_manager_impl.h"
|
|
|
| #include <vector>
|
|
|
| @@ -11,7 +11,6 @@
|
| #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/memory/weak_ptr.h"
|
| #include "base/metrics/histogram.h"
|
| @@ -51,6 +50,7 @@
|
| #include "content/public/browser/notification_service.h"
|
| #include "content/public/common/url_constants.h"
|
| #include "crypto/nss_util.h"
|
| +#include "third_party/skia/include/core/SkBitmap.h"
|
| #include "ui/gfx/codec/png_codec.h"
|
|
|
| #if defined(TOOLKIT_USES_GTK)
|
| @@ -65,15 +65,6 @@ namespace chromeos {
|
|
|
| namespace {
|
|
|
| -// A vector pref of the users who have logged into the device.
|
| -const char kLoggedInUsers[] = "LoggedInUsers";
|
| -// A dictionary that maps usernames to file paths to their images.
|
| -const char kUserImages[] = "UserImages";
|
| -// A dictionary that maps usernames to the displayed (non-canonical) emails.
|
| -const char kUserDisplayEmail[] = "UserDisplayEmail";
|
| -// A dictionary that maps usernames to OAuth token presence flag.
|
| -const char kUserOAuthTokenStatus[] = "OAuthTokenStatus";
|
| -
|
| // Incognito user is represented by an empty string (since some code already
|
| // depends on that and it's hard to figure out what).
|
| const char kGuestUser[] = "";
|
| @@ -91,8 +82,6 @@ const int kStubDefaultImageIndex = 0;
|
| // Delay betweeen user login and attempt to update user's profile image.
|
| const long kProfileImageDownloadDelayMs = 10000;
|
|
|
| -base::LazyInstance<UserManager> g_user_manager = LAZY_INSTANCE_INITIALIZER;
|
| -
|
| // Enum for reporting histograms about profile picture download.
|
| enum ProfileDownloadResult {
|
| kDownloadSuccessChanged,
|
| @@ -293,30 +282,36 @@ void RealTPMTokenInfoDelegate::OnPkcs11GetTpmTokenInfo(
|
|
|
| } // namespace
|
|
|
| -// static
|
| -UserManager* UserManager::Get() {
|
| - // Not thread-safe.
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - return &g_user_manager.Get();
|
| +UserManagerImpl::UserManagerImpl()
|
| + : ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_(new UserImageLoader)),
|
| + demo_user_(kDemoUser, false),
|
| + guest_user_(kGuestUser, true),
|
| + stub_user_(kStubUser, false),
|
| + logged_in_user_(NULL),
|
| + current_user_is_owner_(false),
|
| + current_user_is_new_(false),
|
| + user_is_logged_in_(false),
|
| + observed_sync_service_(NULL),
|
| + last_image_set_async_(false),
|
| + downloaded_profile_image_data_url_(chrome::kAboutBlankURL) {
|
| + // Use stub as the logged-in user for test paths without login.
|
| + if (!system::runtime_environment::IsRunningOnChromeOS())
|
| + StubUserLoggedIn();
|
| + registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED,
|
| + content::NotificationService::AllSources());
|
| + registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED,
|
| + content::NotificationService::AllSources());
|
| }
|
|
|
| -// static
|
| -void UserManager::RegisterPrefs(PrefService* local_state) {
|
| - local_state->RegisterListPref(kLoggedInUsers, PrefService::UNSYNCABLE_PREF);
|
| - local_state->RegisterDictionaryPref(kUserImages,
|
| - PrefService::UNSYNCABLE_PREF);
|
| - local_state->RegisterDictionaryPref(kUserOAuthTokenStatus,
|
| - PrefService::UNSYNCABLE_PREF);
|
| - local_state->RegisterDictionaryPref(kUserDisplayEmail,
|
| - PrefService::UNSYNCABLE_PREF);
|
| +UserManagerImpl::~UserManagerImpl() {
|
| }
|
|
|
| -const UserList& UserManager::GetUsers() const {
|
| - const_cast<UserManager*>(this)->EnsureUsersLoaded();
|
| +const UserList& UserManagerImpl::GetUsers() const {
|
| + const_cast<UserManagerImpl*>(this)->EnsureUsersLoaded();
|
| return users_;
|
| }
|
|
|
| -void UserManager::UserLoggedIn(const std::string& email) {
|
| +void UserManagerImpl::UserLoggedIn(const std::string& email) {
|
| DCHECK(!user_is_logged_in_);
|
|
|
| user_is_logged_in_ = true;
|
| @@ -335,7 +330,7 @@ void UserManager::UserLoggedIn(const std::string& email) {
|
|
|
| // Clear the prefs view of the users.
|
| PrefService* prefs = g_browser_process->local_state();
|
| - ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers);
|
| + ListPrefUpdate prefs_users_update(prefs, UserManager::kLoggedInUsers);
|
| prefs_users_update->Clear();
|
|
|
| // Make sure this user is first.
|
| @@ -372,7 +367,7 @@ void UserManager::UserLoggedIn(const std::string& email) {
|
| BrowserThread::PostDelayedTask(
|
| BrowserThread::UI,
|
| FROM_HERE,
|
| - base::Bind(&UserManager::DownloadProfileImage,
|
| + base::Bind(&UserManagerImpl::DownloadProfileImage,
|
| base::Unretained(this),
|
| kProfileDownloadReasonLoggedIn),
|
| kProfileImageDownloadDelayMs);
|
| @@ -395,17 +390,17 @@ void UserManager::UserLoggedIn(const std::string& email) {
|
| }
|
| }
|
|
|
| -void UserManager::DemoUserLoggedIn() {
|
| +void UserManagerImpl::DemoUserLoggedIn() {
|
| logged_in_user_ = &demo_user_;
|
| NotifyOnLogin();
|
| }
|
|
|
| -void UserManager::GuestUserLoggedIn() {
|
| +void UserManagerImpl::GuestUserLoggedIn() {
|
| logged_in_user_ = &guest_user_;
|
| NotifyOnLogin();
|
| }
|
|
|
| -void UserManager::RemoveUser(const std::string& email,
|
| +void UserManagerImpl::RemoveUser(const std::string& email,
|
| RemoveUserDelegate* delegate) {
|
| if (!IsKnownUser(email))
|
| return;
|
| @@ -425,12 +420,12 @@ void UserManager::RemoveUser(const std::string& email,
|
| RemoveUserInternal(email, delegate);
|
| }
|
|
|
| -void UserManager::RemoveUserFromList(const std::string& email) {
|
| +void UserManagerImpl::RemoveUserFromList(const std::string& email) {
|
| EnsureUsersLoaded();
|
|
|
| // Clear the prefs view of the users.
|
| PrefService* prefs = g_browser_process->local_state();
|
| - ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers);
|
| + ListPrefUpdate prefs_users_update(prefs, UserManager::kLoggedInUsers);
|
| prefs_users_update->Clear();
|
|
|
| UserList::iterator user_to_remove = users_.end();
|
| @@ -443,17 +438,19 @@ void UserManager::RemoveUserFromList(const std::string& email) {
|
| user_to_remove = it;
|
| }
|
|
|
| - DictionaryPrefUpdate prefs_images_update(prefs, kUserImages);
|
| + DictionaryPrefUpdate prefs_images_update(prefs, UserManager::kUserImages);
|
| std::string image_path_string;
|
| prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string);
|
| prefs_images_update->RemoveWithoutPathExpansion(email, NULL);
|
|
|
| - DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus);
|
| + DictionaryPrefUpdate prefs_oauth_update(prefs,
|
| + UserManager::kUserOAuthTokenStatus);
|
| int oauth_status;
|
| prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status);
|
| prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL);
|
|
|
| - DictionaryPrefUpdate prefs_display_email_update(prefs, kUserDisplayEmail);
|
| + DictionaryPrefUpdate prefs_display_email_update(
|
| + prefs, UserManager::kUserDisplayEmail);
|
| prefs_display_email_update->RemoveWithoutPathExpansion(email, NULL);
|
|
|
| if (user_to_remove != users_.end()) {
|
| @@ -469,17 +466,17 @@ void UserManager::RemoveUserFromList(const std::string& email) {
|
| BrowserThread::PostTask(
|
| BrowserThread::FILE,
|
| FROM_HERE,
|
| - base::Bind(&UserManager::DeleteUserImage,
|
| + base::Bind(&UserManagerImpl::DeleteUserImage,
|
| base::Unretained(this),
|
| image_path));
|
| }
|
| }
|
|
|
| -bool UserManager::IsKnownUser(const std::string& email) const {
|
| +bool UserManagerImpl::IsKnownUser(const std::string& email) const {
|
| return FindUser(email) != NULL;
|
| }
|
|
|
| -const User* UserManager::FindUser(const std::string& email) const {
|
| +const User* UserManagerImpl::FindUser(const std::string& email) const {
|
| // Speed up search by checking the logged-in user first.
|
| if (logged_in_user_ && logged_in_user_->email() == email)
|
| return logged_in_user_;
|
| @@ -491,16 +488,26 @@ const User* UserManager::FindUser(const std::string& email) const {
|
| return NULL;
|
| }
|
|
|
| -bool UserManager::IsDisplayNameUnique(const std::string& display_name) const {
|
| +const User& UserManagerImpl::logged_in_user() const {
|
| + return *logged_in_user_;
|
| +}
|
| +
|
| +User& UserManagerImpl::logged_in_user() {
|
| + return *logged_in_user_;
|
| +}
|
| +
|
| +bool UserManagerImpl::IsDisplayNameUnique(
|
| + const std::string& display_name) const {
|
| return display_name_count_[display_name] < 2;
|
| }
|
|
|
| -void UserManager::SaveUserOAuthStatus(
|
| +void UserManagerImpl::SaveUserOAuthStatus(
|
| const std::string& username,
|
| User::OAuthTokenStatus oauth_token_status) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| PrefService* local_state = g_browser_process->local_state();
|
| - DictionaryPrefUpdate oauth_status_update(local_state, kUserOAuthTokenStatus);
|
| + DictionaryPrefUpdate oauth_status_update(local_state,
|
| + UserManager::kUserOAuthTokenStatus);
|
| oauth_status_update->SetWithoutPathExpansion(username,
|
| new base::FundamentalValue(static_cast<int>(oauth_token_status)));
|
| DVLOG(1) << "Saving user OAuth token status in Local State";
|
| @@ -509,7 +516,7 @@ void UserManager::SaveUserOAuthStatus(
|
| user->set_oauth_token_status(oauth_token_status);
|
| }
|
|
|
| -User::OAuthTokenStatus UserManager::LoadUserOAuthStatus(
|
| +User::OAuthTokenStatus UserManagerImpl::LoadUserOAuthStatus(
|
| const std::string& username) const {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -520,7 +527,7 @@ User::OAuthTokenStatus UserManager::LoadUserOAuthStatus(
|
| } else {
|
| PrefService* local_state = g_browser_process->local_state();
|
| const DictionaryValue* prefs_oauth_status =
|
| - local_state->GetDictionary(kUserOAuthTokenStatus);
|
| + local_state->GetDictionary(UserManager::kUserOAuthTokenStatus);
|
|
|
| int oauth_token_status = User::OAUTH_TOKEN_STATUS_UNKNOWN;
|
| if (prefs_oauth_status &&
|
| @@ -533,8 +540,8 @@ User::OAuthTokenStatus UserManager::LoadUserOAuthStatus(
|
| return User::OAUTH_TOKEN_STATUS_UNKNOWN;
|
| }
|
|
|
| -void UserManager::SaveUserDisplayEmail(const std::string& username,
|
| - const std::string& display_email) {
|
| +void UserManagerImpl::SaveUserDisplayEmail(const std::string& username,
|
| + const std::string& display_email) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| User* user = const_cast<User*>(FindUser(username));
|
| @@ -545,39 +552,41 @@ void UserManager::SaveUserDisplayEmail(const std::string& username,
|
|
|
| PrefService* local_state = g_browser_process->local_state();
|
|
|
| - DictionaryPrefUpdate display_email_update(local_state, kUserDisplayEmail);
|
| + DictionaryPrefUpdate display_email_update(local_state,
|
| + UserManager::kUserDisplayEmail);
|
| display_email_update->SetWithoutPathExpansion(
|
| username,
|
| base::Value::CreateStringValue(display_email));
|
| }
|
|
|
| -std::string UserManager::GetUserDisplayEmail(
|
| +std::string UserManagerImpl::GetUserDisplayEmail(
|
| const std::string& username) const {
|
| const User* user = FindUser(username);
|
| return user ? user->display_email() : username;
|
| }
|
|
|
| -void UserManager::SaveUserDefaultImageIndex(const std::string& username,
|
| +void UserManagerImpl::SaveUserDefaultImageIndex(const std::string& username,
|
| int image_index) {
|
| DCHECK(image_index >= 0 && image_index < kDefaultImagesCount);
|
| SetUserImage(username, image_index, GetDefaultImage(image_index));
|
| SaveImageToLocalState(username, "", image_index, false);
|
| }
|
|
|
| -void UserManager::SaveUserImage(const std::string& username,
|
| +void UserManagerImpl::SaveUserImage(const std::string& username,
|
| const SkBitmap& image) {
|
| SaveUserImageInternal(username, User::kExternalImageIndex, image);
|
| }
|
|
|
| -void UserManager::SaveUserImageFromFile(const std::string& username,
|
| +void UserManagerImpl::SaveUserImageFromFile(const std::string& username,
|
| const FilePath& path) {
|
| image_loader_->Start(
|
| path.value(), login::kUserImageSize,
|
| - base::Bind(&UserManager::SaveUserImage,
|
| + base::Bind(&UserManagerImpl::SaveUserImage,
|
| base::Unretained(this), username));
|
| }
|
|
|
| -void UserManager::SaveUserImageFromProfileImage(const std::string& username) {
|
| +void UserManagerImpl::SaveUserImageFromProfileImage(
|
| + const std::string& username) {
|
| if (!downloaded_profile_image_.empty()) {
|
| // Profile image has already been downloaded, so save it to file right now.
|
| SaveUserImageInternal(username, User::kProfileImageIndex,
|
| @@ -589,7 +598,7 @@ void UserManager::SaveUserImageFromProfileImage(const std::string& username) {
|
| }
|
| }
|
|
|
| -void UserManager::DownloadProfileImage(const std::string& reason) {
|
| +void UserManagerImpl::DownloadProfileImage(const std::string& reason) {
|
| if (profile_image_downloader_.get()) {
|
| // Another download is already in progress
|
| return;
|
| @@ -606,13 +615,13 @@ void UserManager::DownloadProfileImage(const std::string& reason) {
|
| profile_image_downloader_->Start();
|
| }
|
|
|
| -void UserManager::Observe(int type,
|
| +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(&UserManager::CheckOwnership,
|
| + base::Bind(&UserManagerImpl::CheckOwnership,
|
| base::Unretained(this)));
|
| break;
|
| case chrome::NOTIFICATION_PROFILE_ADDED:
|
| @@ -633,7 +642,7 @@ void UserManager::Observe(int type,
|
| }
|
| }
|
|
|
| -void UserManager::OnStateChanged() {
|
| +void UserManagerImpl::OnStateChanged() {
|
| DCHECK(user_is_logged_in() && !IsLoggedInAsGuest());
|
| if (observed_sync_service_->GetAuthError().state() != AuthError::NONE) {
|
| // Invalidate OAuth token to force Gaia sign-in flow. This is needed
|
| @@ -646,72 +655,59 @@ void UserManager::OnStateChanged() {
|
| }
|
| }
|
|
|
| -bool UserManager::current_user_is_owner() const {
|
| +bool UserManagerImpl::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) {
|
| +void UserManagerImpl::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;
|
| }
|
|
|
| -bool UserManager::IsLoggedInAsDemoUser() const {
|
| +bool UserManagerImpl::current_user_is_new() const {
|
| + return current_user_is_new_;
|
| +}
|
| +
|
| +bool UserManagerImpl::user_is_logged_in() const {
|
| + return user_is_logged_in_;
|
| +}
|
| +
|
| +bool UserManagerImpl::IsLoggedInAsDemoUser() const {
|
| return logged_in_user_ == &demo_user_;
|
| }
|
|
|
| -bool UserManager::IsLoggedInAsGuest() const {
|
| +bool UserManagerImpl::IsLoggedInAsGuest() const {
|
| return logged_in_user_ == &guest_user_;
|
| }
|
|
|
| -void UserManager::AddObserver(Observer* obs) {
|
| +void UserManagerImpl::AddObserver(Observer* obs) {
|
| observer_list_.AddObserver(obs);
|
| }
|
|
|
| -void UserManager::RemoveObserver(Observer* obs) {
|
| +void UserManagerImpl::RemoveObserver(Observer* obs) {
|
| observer_list_.RemoveObserver(obs);
|
| }
|
|
|
| -void UserManager::NotifyLocalStateChanged() {
|
| +const SkBitmap& UserManagerImpl::downloaded_profile_image() const {
|
| + return downloaded_profile_image_;
|
| +}
|
| +
|
| +void UserManagerImpl::NotifyLocalStateChanged() {
|
| FOR_EACH_OBSERVER(
|
| Observer,
|
| observer_list_,
|
| LocalStateChanged(this));
|
| }
|
|
|
| -// Protected constructor and destructor.
|
| -UserManager::UserManager()
|
| - : ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_(new UserImageLoader)),
|
| - demo_user_(kDemoUser, false),
|
| - guest_user_(kGuestUser, true),
|
| - stub_user_(kStubUser, false),
|
| - logged_in_user_(NULL),
|
| - current_user_is_owner_(false),
|
| - current_user_is_new_(false),
|
| - user_is_logged_in_(false),
|
| - observed_sync_service_(NULL),
|
| - last_image_set_async_(false),
|
| - downloaded_profile_image_data_url_(chrome::kAboutBlankURL) {
|
| - // Use stub as the logged-in user for test paths without login.
|
| - if (!system::runtime_environment::IsRunningOnChromeOS())
|
| - StubUserLoggedIn();
|
| - registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED,
|
| - content::NotificationService::AllSources());
|
| - registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED,
|
| - content::NotificationService::AllSources());
|
| -}
|
| -
|
| -UserManager::~UserManager() {
|
| -}
|
| -
|
| -FilePath UserManager::GetImagePathForUser(const std::string& username) {
|
| +FilePath UserManagerImpl::GetImagePathForUser(const std::string& username) {
|
| std::string filename = username + ".png";
|
| FilePath user_data_dir;
|
| PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
|
| return user_data_dir.AppendASCII(filename);
|
| }
|
|
|
| -void UserManager::EnsureUsersLoaded() {
|
| +void UserManagerImpl::EnsureUsersLoaded() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| if (!users_.empty())
|
| return;
|
| @@ -719,10 +715,12 @@ void UserManager::EnsureUsersLoaded() {
|
| return;
|
|
|
| PrefService* local_state = g_browser_process->local_state();
|
| - const ListValue* prefs_users = local_state->GetList(kLoggedInUsers);
|
| - const DictionaryValue* prefs_images = local_state->GetDictionary(kUserImages);
|
| + const ListValue* prefs_users =
|
| + local_state->GetList(UserManager::kLoggedInUsers);
|
| + const DictionaryValue* prefs_images =
|
| + local_state->GetDictionary(UserManager::kUserImages);
|
| const DictionaryValue* prefs_display_emails =
|
| - local_state->GetDictionary(kUserDisplayEmail);
|
| + local_state->GetDictionary(UserManager::kUserDisplayEmail);
|
|
|
| if (prefs_users) {
|
| for (ListValue::const_iterator it = prefs_users->begin();
|
| @@ -750,7 +748,7 @@ void UserManager::EnsureUsersLoaded() {
|
| // Load user image asynchronously.
|
| image_loader_->Start(
|
| image_path, 0,
|
| - base::Bind(&UserManager::SetUserImage,
|
| + base::Bind(&UserManagerImpl::SetUserImage,
|
| base::Unretained(this), email, image_index));
|
| }
|
| } else if (prefs_images->GetDictionaryWithoutPathExpansion(
|
| @@ -774,7 +772,7 @@ void UserManager::EnsureUsersLoaded() {
|
| // Load user image asynchronously.
|
| image_loader_->Start(
|
| image_path, 0,
|
| - base::Bind(&UserManager::SetUserImage,
|
| + base::Bind(&UserManagerImpl::SetUserImage,
|
| base::Unretained(this), email, image_index));
|
| }
|
| } else {
|
| @@ -794,17 +792,17 @@ void UserManager::EnsureUsersLoaded() {
|
| }
|
| }
|
|
|
| -void UserManager::StubUserLoggedIn() {
|
| +void UserManagerImpl::StubUserLoggedIn() {
|
| logged_in_user_ = &stub_user_;
|
| stub_user_.SetImage(GetDefaultImage(kStubDefaultImageIndex),
|
| kStubDefaultImageIndex);
|
| }
|
|
|
| -void UserManager::NotifyOnLogin() {
|
| +void UserManagerImpl::NotifyOnLogin() {
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| content::NotificationService::current()->Notify(
|
| chrome::NOTIFICATION_LOGIN_USER_CHANGED,
|
| - content::Source<UserManager>(this),
|
| + content::Source<UserManagerImpl>(this),
|
| content::Details<const User>(logged_in_user_));
|
|
|
| #if defined(TOOLKIT_USES_GTK)
|
| @@ -829,17 +827,17 @@ void UserManager::NotifyOnLogin() {
|
|
|
| // Schedules current user ownership check on file thread.
|
| BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
|
| - base::Bind(&UserManager::CheckOwnership,
|
| + base::Bind(&UserManagerImpl::CheckOwnership,
|
| base::Unretained(this)));
|
| }
|
|
|
| -void UserManager::SetInitialUserImage(const std::string& username) {
|
| +void UserManagerImpl::SetInitialUserImage(const std::string& username) {
|
| // Choose a random default image.
|
| int image_id = base::RandInt(0, kDefaultImagesCount - 1);
|
| SaveUserDefaultImageIndex(username, image_id);
|
| }
|
|
|
| -void UserManager::SetUserImage(const std::string& username,
|
| +void UserManagerImpl::SetUserImage(const std::string& username,
|
| int image_index,
|
| const SkBitmap& image) {
|
| User* user = const_cast<User*>(FindUser(username));
|
| @@ -863,13 +861,13 @@ void UserManager::SetUserImage(const std::string& username,
|
| // send a notification about image change.
|
| content::NotificationService::current()->Notify(
|
| chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
|
| - content::Source<UserManager>(this),
|
| + content::Source<UserManagerImpl>(this),
|
| content::Details<const User>(user));
|
| }
|
| }
|
| }
|
|
|
| -void UserManager::SaveUserImageInternal(const std::string& username,
|
| +void UserManagerImpl::SaveUserImageInternal(const std::string& username,
|
| int image_index,
|
| const SkBitmap& image) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| @@ -884,12 +882,12 @@ void UserManager::SaveUserImageInternal(const std::string& username,
|
| BrowserThread::PostTask(
|
| BrowserThread::FILE,
|
| FROM_HERE,
|
| - base::Bind(&UserManager::SaveImageToFile,
|
| + base::Bind(&UserManagerImpl::SaveImageToFile,
|
| base::Unretained(this),
|
| username, image, image_path, image_index));
|
| }
|
|
|
| -void UserManager::SaveImageToFile(const std::string& username,
|
| +void UserManagerImpl::SaveImageToFile(const std::string& username,
|
| const SkBitmap& image,
|
| const FilePath& image_path,
|
| int image_index) {
|
| @@ -911,12 +909,12 @@ void UserManager::SaveImageToFile(const std::string& username,
|
| BrowserThread::PostTask(
|
| BrowserThread::UI,
|
| FROM_HERE,
|
| - base::Bind(&UserManager::SaveImageToLocalState,
|
| + base::Bind(&UserManagerImpl::SaveImageToLocalState,
|
| base::Unretained(this),
|
| username, image_path.value(), image_index, true));
|
| }
|
|
|
| -void UserManager::SaveImageToLocalState(const std::string& username,
|
| +void UserManagerImpl::SaveImageToLocalState(const std::string& username,
|
| const std::string& image_path,
|
| int image_index,
|
| bool is_async) {
|
| @@ -934,7 +932,7 @@ void UserManager::SaveImageToLocalState(const std::string& username,
|
| }
|
|
|
| PrefService* local_state = g_browser_process->local_state();
|
| - DictionaryPrefUpdate images_update(local_state, kUserImages);
|
| + DictionaryPrefUpdate images_update(local_state, UserManager::kUserImages);
|
| base::DictionaryValue* image_properties = new base::DictionaryValue();
|
| image_properties->Set(kImagePathNodeName, new StringValue(image_path));
|
| image_properties->Set(kImageIndexNodeName,
|
| @@ -945,7 +943,7 @@ void UserManager::SaveImageToLocalState(const std::string& username,
|
| NotifyLocalStateChanged();
|
| }
|
|
|
| -void UserManager::InitDownloadedProfileImage() {
|
| +void UserManagerImpl::InitDownloadedProfileImage() {
|
| DCHECK(logged_in_user_);
|
| if (downloaded_profile_image_.empty() && !logged_in_user_->image_is_stub()) {
|
| VLOG(1) << "Profile image initialized";
|
| @@ -955,7 +953,7 @@ void UserManager::InitDownloadedProfileImage() {
|
| }
|
| }
|
|
|
| -void UserManager::DeleteUserImage(const FilePath& image_path) {
|
| +void UserManagerImpl::DeleteUserImage(const FilePath& image_path) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| if (!file_util::Delete(image_path, false)) {
|
| LOG(ERROR) << "Failed to remove user image.";
|
| @@ -963,7 +961,7 @@ void UserManager::DeleteUserImage(const FilePath& image_path) {
|
| }
|
| }
|
|
|
| -void UserManager::UpdateOwnership(bool is_owner) {
|
| +void UserManagerImpl::UpdateOwnership(bool is_owner) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| set_current_user_is_owner(is_owner);
|
| @@ -973,42 +971,40 @@ void UserManager::UpdateOwnership(bool is_owner) {
|
| content::NotificationService::NoDetails());
|
| if (is_owner) {
|
| // Also update cached value.
|
| - CrosSettings::Get()->SetString(
|
| - kDeviceOwner,
|
| - g_user_manager.Get().logged_in_user().email());
|
| + CrosSettings::Get()->SetString(kDeviceOwner, logged_in_user().email());
|
| }
|
| }
|
|
|
| -void UserManager::CheckOwnership() {
|
| +void UserManagerImpl::CheckOwnership() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| bool is_owner = OwnershipService::GetSharedInstance()->CurrentUserIsOwner();
|
| VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner");
|
|
|
| set_current_user_is_owner(is_owner);
|
|
|
| - // UserManager should be accessed only on UI thread.
|
| + // UserManagerImpl should be accessed only on UI thread.
|
| BrowserThread::PostTask(
|
| BrowserThread::UI,
|
| FROM_HERE,
|
| - base::Bind(&UserManager::UpdateOwnership,
|
| + base::Bind(&UserManagerImpl::UpdateOwnership,
|
| base::Unretained(this),
|
| is_owner));
|
| }
|
|
|
| -int UserManager::GetDesiredImageSideLength() const {
|
| +int UserManagerImpl::GetDesiredImageSideLength() const {
|
| return login::kUserImageSize;
|
| }
|
|
|
| -Profile* UserManager::GetBrowserProfile() {
|
| +Profile* UserManagerImpl::GetBrowserProfile() {
|
| return ProfileManager::GetDefaultProfile();
|
| }
|
|
|
| -std::string UserManager::GetCachedPictureURL() const {
|
| +std::string UserManagerImpl::GetCachedPictureURL() const {
|
| // Currently the profile picture URL is not cached on ChromeOS.
|
| return std::string();
|
| }
|
|
|
| -void UserManager::OnDownloadComplete(ProfileDownloader* downloader,
|
| +void UserManagerImpl::OnDownloadComplete(ProfileDownloader* downloader,
|
| bool success) {
|
| // Make sure that |ProfileDownloader| gets deleted after return.
|
| scoped_ptr<ProfileDownloader> profile_image_downloader(
|
| @@ -1055,17 +1051,17 @@ void UserManager::OnDownloadComplete(ProfileDownloader* downloader,
|
| if (result == kDownloadSuccess) {
|
| content::NotificationService::current()->Notify(
|
| chrome::NOTIFICATION_PROFILE_IMAGE_UPDATED,
|
| - content::Source<UserManager>(this),
|
| + content::Source<UserManagerImpl>(this),
|
| content::Details<const SkBitmap>(&downloaded_profile_image_));
|
| } else {
|
| content::NotificationService::current()->Notify(
|
| chrome::NOTIFICATION_PROFILE_IMAGE_UPDATE_FAILED,
|
| - content::Source<UserManager>(this),
|
| + content::Source<UserManagerImpl>(this),
|
| content::NotificationService::NoDetails());
|
| }
|
| }
|
|
|
| -User* UserManager::CreateUser(const std::string& email) const {
|
| +User* UserManagerImpl::CreateUser(const std::string& email) const {
|
| User* user = new User(email, email == kGuestUser);
|
| user->set_oauth_token_status(LoadUserOAuthStatus(email));
|
| // Used to determine whether user's display name is unique.
|
|
|