| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/observer_list.h" |
| 15 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 16 #include "chrome/browser/chromeos/login/user_image_loader.h" | 17 #include "chrome/browser/chromeos/login/user_image_loader.h" |
| 17 #include "content/common/notification_observer.h" | 18 #include "content/common/notification_observer.h" |
| 18 #include "content/common/notification_registrar.h" | 19 #include "content/common/notification_registrar.h" |
| 19 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
| 20 | 21 |
| 21 class FilePath; | 22 class FilePath; |
| 22 class PrefService; | 23 class PrefService; |
| 23 | 24 |
| 24 namespace base { | 25 namespace base { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // Accessor for current_user_is_new_. | 156 // Accessor for current_user_is_new_. |
| 156 bool current_user_is_new() const { | 157 bool current_user_is_new() const { |
| 157 return current_user_is_new_; | 158 return current_user_is_new_; |
| 158 } | 159 } |
| 159 | 160 |
| 160 bool user_is_logged_in() const { return user_is_logged_in_; } | 161 bool user_is_logged_in() const { return user_is_logged_in_; } |
| 161 | 162 |
| 162 // Returns true if we're logged in as a Guest. | 163 // Returns true if we're logged in as a Guest. |
| 163 bool IsLoggedInAsGuest() const; | 164 bool IsLoggedInAsGuest() const; |
| 164 | 165 |
| 166 // Interface that observers of UserManager must implement in order |
| 167 // to receive notification when local state preferences is changed |
| 168 class Observer { |
| 169 public: |
| 170 // Called when the local state preferences is changed |
| 171 virtual void LocalStateChanged(UserManager* user_manager) = 0; |
| 172 |
| 173 protected: |
| 174 virtual ~Observer() {} |
| 175 }; |
| 176 |
| 177 void AddObserver(Observer* obs); |
| 178 void RemoveObserver(Observer* obs); |
| 179 |
| 180 void NotifyLocalStateChanged(); |
| 181 |
| 165 protected: | 182 protected: |
| 166 UserManager(); | 183 UserManager(); |
| 167 virtual ~UserManager(); | 184 virtual ~UserManager(); |
| 168 | 185 |
| 169 // Returns image filepath for the given user. | 186 // Returns image filepath for the given user. |
| 170 FilePath GetImagePathForUser(const std::string& username); | 187 FilePath GetImagePathForUser(const std::string& username); |
| 171 | 188 |
| 172 private: | 189 private: |
| 173 // Notifies on new user session. | 190 // Notifies on new user session. |
| 174 void NotifyOnLogin(); | 191 void NotifyOnLogin(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 196 // login. | 213 // login. |
| 197 bool current_user_is_new_; | 214 bool current_user_is_new_; |
| 198 | 215 |
| 199 // Cached flag of whether any user is logged in at the moment. | 216 // Cached flag of whether any user is logged in at the moment. |
| 200 bool user_is_logged_in_; | 217 bool user_is_logged_in_; |
| 201 | 218 |
| 202 NotificationRegistrar registrar_; | 219 NotificationRegistrar registrar_; |
| 203 | 220 |
| 204 friend struct base::DefaultLazyInstanceTraits<UserManager>; | 221 friend struct base::DefaultLazyInstanceTraits<UserManager>; |
| 205 | 222 |
| 223 ObserverList<Observer> observer_list_; |
| 224 |
| 206 DISALLOW_COPY_AND_ASSIGN(UserManager); | 225 DISALLOW_COPY_AND_ASSIGN(UserManager); |
| 207 }; | 226 }; |
| 208 | 227 |
| 209 typedef std::vector<UserManager::User> UserVector; | 228 typedef std::vector<UserManager::User> UserVector; |
| 210 | 229 |
| 211 } // namespace chromeos | 230 } // namespace chromeos |
| 212 | 231 |
| 213 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ | 232 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |
| OLD | NEW |