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

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

Issue 9348022: [cros] Use mocked URLFetcher and other mocks in ExistingUserController tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move Created 8 years, 9 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
« no previous file with comments | « chrome/browser/chromeos/login/user_manager.cc ('k') | chrome/browser/chromeos/login/user_manager_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/user_manager_impl.h
diff --git a/chrome/browser/chromeos/login/user_manager.h b/chrome/browser/chromeos/login/user_manager_impl.h
similarity index 54%
copy from chrome/browser/chromeos/login/user_manager.h
copy to chrome/browser/chromeos/login/user_manager_impl.h
index 6e70d7cccc4a2a00169a9fe6400573e316668955..48ed4c744c87eb2fb00d7458eebd53ca75483acd 100644
--- a/chrome/browser/chromeos/login/user_manager.h
+++ b/chrome/browser/chromeos/login/user_manager_impl.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_
-#define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_
+#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_
#pragma once
#include <string>
@@ -11,119 +11,74 @@
#include "base/basictypes.h"
#include "base/hash_tables.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/singleton.h"
#include "base/observer_list.h"
#include "base/synchronization/lock.h"
#include "base/time.h"
#include "chrome/browser/chromeos/login/user.h"
#include "chrome/browser/chromeos/login/user_image_loader.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/profiles/profile_downloader_delegate.h"
#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
-#include "third_party/skia/include/core/SkBitmap.h"
+class SkBitmap;
class FilePath;
class PrefService;
class ProfileDownloader;
class ProfileSyncService;
-namespace base {
-template<typename> struct DefaultLazyInstanceTraits;
-}
-
namespace chromeos {
class RemoveUserDelegate;
-// This class provides a mechanism for discovering users who have logged
-// into this chromium os device before and updating that list.
-class UserManager : public ProfileDownloaderDelegate,
- public ProfileSyncServiceObserver,
- public content::NotificationObserver {
+// Implementation of the UserManager.
+class UserManagerImpl : public UserManager,
+ public ProfileDownloaderDelegate,
+ public ProfileSyncServiceObserver,
+ public content::NotificationObserver {
public:
- // Returns a shared instance of a UserManager. Not thread-safe, should only be
- // called from the main UI thread.
- static UserManager* Get();
-
- // Registers user manager preferences.
- static void RegisterPrefs(PrefService* local_state);
-
- // Returns a list of the users who have logged into this device previously.
- // It is sorted in order of recency, with most recent at the beginning.
- const UserList& GetUsers() const;
-
- // Indicates that a user with the given email has just logged in.
- // The persistent list will be updated accordingly.
- void UserLoggedIn(const std::string& email);
-
- // Indicates that user just logged on as the demo user.
- void DemoUserLoggedIn();
-
- // Indicates that user just started incognito session.
- void GuestUserLoggedIn();
-
- // Removes the user from the device. Note, it will verify that the given user
- // isn't the owner, so calling this method for the owner will take no effect.
- // Note, |delegate| can be NULL.
- void RemoveUser(const std::string& email,
- RemoveUserDelegate* delegate);
-
- // Removes the user from the persistent list only. Also removes the user's
- // picture.
- void RemoveUserFromList(const std::string& email);
-
- // Returns true if given user has logged into the device before.
- virtual bool IsKnownUser(const std::string& email) const;
-
- // Returns a user with given email or |NULL| if no such user exists.
- const User* FindUser(const std::string& email) const;
-
- // Returns the logged-in user.
- const User& logged_in_user() const { return *logged_in_user_; }
- User& logged_in_user() { return *logged_in_user_; }
-
- // Returns true if given display name is unique.
- bool IsDisplayNameUnique(const std::string& display_name) const;
-
- // Saves user's oauth token status in local state preferences.
- void SaveUserOAuthStatus(const std::string& username,
- User::OAuthTokenStatus oauth_token_status);
-
- // Save user's displayed (non-canonical) email in local state preferences.
- // Ignored If there is no such user.
- void SaveUserDisplayEmail(const std::string& username,
- const std::string& display_email);
-
- // Returns the display email for user |username| if it is known (was
- // previously set by a |SaveUserDisplayEmail| call).
- // Otherwise, returns |username| itself.
- std::string GetUserDisplayEmail(const std::string& username) const;
-
- // Sets user image to the default image with index |image_index|, sends
- // LOGIN_USER_IMAGE_CHANGED notification and updates Local State.
- void SaveUserDefaultImageIndex(const std::string& username, int image_index);
-
- // Saves image to file, sends LOGIN_USER_IMAGE_CHANGED notification and
- // updates Local State.
- void SaveUserImage(const std::string& username, const SkBitmap& image);
-
- // Tries to load user image from disk; if successful, sets it for the user,
- // sends LOGIN_USER_IMAGE_CHANGED notification and updates Local State.
- void SaveUserImageFromFile(const std::string& username, const FilePath& path);
-
- // Sets profile image as user image for |username|, sends
- // LOGIN_USER_IMAGE_CHANGED notification and updates Local State. If the user
- // is not logged-in or the last |DownloadProfileImage| call has failed, a
- // default grey avatar will be used until the user logs in and profile image
- // is downloaded successfuly.
- void SaveUserImageFromProfileImage(const std::string& username);
-
- // Starts downloading the profile image for the logged-in user.
- // If user's image index is |kProfileImageIndex|, newly downloaded image
- // is immediately set as user's current picture.
- // |reason| is an arbitraty string (used to report UMA histograms with
- // download times).
- void DownloadProfileImage(const std::string& reason);
+ // UserManager implementation:
+ virtual const UserList& GetUsers() const OVERRIDE;
+ virtual void UserLoggedIn(const std::string& email) OVERRIDE;
+ virtual void DemoUserLoggedIn() OVERRIDE;
+ virtual void GuestUserLoggedIn() OVERRIDE;
+ virtual void RemoveUser(const std::string& email,
+ RemoveUserDelegate* delegate) OVERRIDE;
+ virtual void RemoveUserFromList(const std::string& email) OVERRIDE;
+ virtual bool IsKnownUser(const std::string& email) const OVERRIDE;
+ virtual const User* FindUser(const std::string& email) const OVERRIDE;
+ virtual const User& logged_in_user() const OVERRIDE;
+ virtual User& logged_in_user() OVERRIDE;
+ virtual bool IsDisplayNameUnique(
+ const std::string& display_name) const OVERRIDE;
+ virtual void SaveUserOAuthStatus(
+ const std::string& username,
+ User::OAuthTokenStatus oauth_token_status) OVERRIDE;
+ virtual void SaveUserDisplayEmail(const std::string& username,
+ const std::string& display_email) OVERRIDE;
+ virtual std::string GetUserDisplayEmail(
+ const std::string& username) const OVERRIDE;
+ virtual void SaveUserDefaultImageIndex(const std::string& username,
+ int image_index) OVERRIDE;
+ virtual void SaveUserImage(const std::string& username,
+ const SkBitmap& image) OVERRIDE;
+ virtual void SaveUserImageFromFile(const std::string& username,
+ const FilePath& path) OVERRIDE;
+ virtual void SaveUserImageFromProfileImage(
+ const std::string& username) OVERRIDE;
+ virtual void DownloadProfileImage(const std::string& reason) OVERRIDE;
+ virtual bool current_user_is_owner() const OVERRIDE;
+ virtual void set_current_user_is_owner(bool current_user_is_owner) OVERRIDE;
+ virtual bool current_user_is_new() const OVERRIDE;
+ virtual bool user_is_logged_in() const OVERRIDE;
+ virtual bool IsLoggedInAsDemoUser() const OVERRIDE;
+ virtual bool IsLoggedInAsGuest() const OVERRIDE;
+ virtual void AddObserver(Observer* obs) OVERRIDE;
+ virtual void RemoveObserver(Observer* obs) OVERRIDE;
+ virtual void NotifyLocalStateChanged() OVERRIDE;
+ virtual const SkBitmap& downloaded_profile_image() const OVERRIDE;
// content::NotificationObserver implementation.
virtual void Observe(int type,
@@ -133,53 +88,16 @@ class UserManager : public ProfileDownloaderDelegate,
// ProfileSyncServiceObserver implementation.
virtual void OnStateChanged() OVERRIDE;
- // Accessor for current_user_is_owner_
- virtual bool current_user_is_owner() const;
- virtual void set_current_user_is_owner(bool current_user_is_owner);
-
- // Accessor for current_user_is_new_.
- bool current_user_is_new() const {
- return current_user_is_new_;
- }
-
- bool user_is_logged_in() const { return user_is_logged_in_; }
-
- // Returns true if we're logged in as a demo user.
- bool IsLoggedInAsDemoUser() const;
-
- // Returns true if we're logged in as a Guest.
- bool IsLoggedInAsGuest() const;
-
- // Interface that observers of UserManager must implement in order
- // to receive notification when local state preferences is changed
- class Observer {
- public:
- // Called when the local state preferences is changed
- virtual void LocalStateChanged(UserManager* user_manager) = 0;
-
- protected:
- virtual ~Observer() {}
- };
-
- void AddObserver(Observer* obs);
- void RemoveObserver(Observer* obs);
-
- void NotifyLocalStateChanged();
-
- // Returns the result of the last successful profile image download, if any.
- // Otherwise, returns an empty bitmap.
- const SkBitmap& downloaded_profile_image() const {
- return downloaded_profile_image_;
- }
-
protected:
- UserManager();
- virtual ~UserManager();
+ UserManagerImpl();
+ virtual ~UserManagerImpl();
// Returns image filepath for the given user.
FilePath GetImagePathForUser(const std::string& username);
private:
+ friend class UserManagerImplWrapper;
+
// Loads |users_| from Local State if the list has not been loaded yet.
// Subsequent calls have no effect. Must be called on the UI thread.
void EnsureUsersLoaded();
@@ -294,8 +212,6 @@ class UserManager : public ProfileDownloaderDelegate,
// service, so do NOT use it outside |OnStateChanged| method.
ProfileSyncService* observed_sync_service_;
- friend struct base::DefaultLazyInstanceTraits<UserManager>;
-
ObserverList<Observer> observer_list_;
// Download user profile image on login to update it if it's changed.
@@ -318,9 +234,9 @@ class UserManager : public ProfileDownloaderDelegate,
// Data URL for |downloaded_profile_image_|.
std::string downloaded_profile_image_data_url_;
- DISALLOW_COPY_AND_ASSIGN(UserManager);
+ DISALLOW_COPY_AND_ASSIGN(UserManagerImpl);
};
} // namespace chromeos
-#endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_
« no previous file with comments | « chrome/browser/chromeos/login/user_manager.cc ('k') | chrome/browser/chromeos/login/user_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698