1cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#ifndef COMPONENTS_USER_MANAGER_USER_H_
65f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#define COMPONENTS_USER_MANAGER_USER_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
125e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles)#include "base/strings/string16.h"
13116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/user_manager/user_image/user_image.h"
14116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/user_manager/user_info.h"
155f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "components/user_manager/user_manager_export.h"
16116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/user_manager/user_type.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "third_party/skia/include/core/SkBitmap.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/image/image_skia.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace chromeos {
216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class ChromeUserManagerImpl;
225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class FakeLoginUtils;
235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class FakeUserManager;
245f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class MockUserManager;
255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class SupervisedUserManagerImpl;
265f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class UserAddingScreenTest;
275f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class UserImageManagerImpl;
285f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class UserSessionManager;
295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}
305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
315f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace user_manager {
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class UserManagerBase;
346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// A class representing information about a previously logged in user.
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Each user has a canonical email (username), returned by |email()| and
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// may have a different displayed email (in the raw form as entered by user),
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// returned by |displayed_email()|.
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Displayed emails are for use in UI only, anywhere else users must be referred
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// to by |email()|.
415f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class USER_MANAGER_EXPORT User : public UserInfo {
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // User OAuth token status according to the last check.
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Please note that enum values 1 and 2 were used for OAuth1 status and are
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // deprecated now.
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef enum {
475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    OAUTH_TOKEN_STATUS_UNKNOWN = 0,
485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    OAUTH2_TOKEN_STATUS_INVALID = 3,
495f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    OAUTH2_TOKEN_STATUS_VALID = 4,
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } OAuthTokenStatus;
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
525f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // These special values are used instead of actual default image indices.
535f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  typedef enum {
545f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    USER_IMAGE_INVALID = -3,
555f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
565f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    // Returned as |image_index| when user profile image is used as user image.
575f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    USER_IMAGE_PROFILE = -2,
585f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
595f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    // Returned as |image_index| when user-selected file or photo is used as
605f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    // user image.
615f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    USER_IMAGE_EXTERNAL = -1,
625f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  } UserImageType;
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
646e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // This enum is used to define the buckets for an enumerated UMA histogram.
656e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Hence,
666e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  //   (a) existing enumerated constants should never be deleted or reordered,
676e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  //   (b) new constants should only be appended at the end of the enumeration.
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum WallpaperType {
696e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    /* DAILY = 0 */    // Removed.
705c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu    CUSTOMIZED = 1,    // Selected by user.
715c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu    DEFAULT = 2,       // Default.
726e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    /* UNKNOWN = 3 */  // Removed.
736e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    ONLINE = 4,        // WallpaperInfo.location denotes an URL.
74c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    POLICY = 5,        // Controlled by policy, can't be changed by the user.
75a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    WALLPAPER_TYPE_COUNT = 6
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns the user type.
795f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual UserType GetType() const = 0;
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The email the user used to log in.
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const std::string& email() const { return email_; }
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
845c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // The displayed user name.
855c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  base::string16 display_name() const { return display_name_; }
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
875f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // UserInfo
885c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual std::string GetEmail() const OVERRIDE;
895c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual base::string16 GetDisplayName() const OVERRIDE;
905c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual base::string16 GetGivenName() const OVERRIDE;
915c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual const gfx::ImageSkia& GetImage() const OVERRIDE;
925c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual std::string GetUserID() const OVERRIDE;
93f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Is user supervised.
951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool IsSupervised() const;
961320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void SetIsSupervised(bool is_supervised);
971320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the account name part of the email. Use the display form of the
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // email if available and use_display_name == true. Otherwise use canonical.
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string GetAccountName(bool use_display_email) const;
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether the user has a default image.
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool HasDefaultImage() const;
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1053551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  // True if user image can be synced.
1063551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  virtual bool CanSyncImage() const;
1073551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int image_index() const { return image_index_; }
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool has_raw_image() const { return user_image_.has_raw_image(); }
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns raw representation of static user image.
1115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  const UserImage::RawImage& raw_image() const {
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return user_image_.raw_image();
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether |raw_image| contains data in format that is considered safe to
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // decode in sensitive environment (on Login screen).
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool image_is_safe_format() const { return user_image_.is_safe_format(); }
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the URL of user image, if there is any. Currently only the profile
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // image has a URL, for other images empty URL is returned.
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL image_url() const { return user_image_.url(); }
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True if user image is a stub (while real image is being loaded from file).
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool image_is_stub() const { return image_is_stub_; }
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True if image is being loaded from file.
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool image_is_loading() const { return image_is_loading_; }
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The displayed (non-canonical) user email.
1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual std::string display_email() const;
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // OAuth token status for this user.
1335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; }
1345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Whether online authentication against GAIA should be enforced during the
1365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // user's next sign-in.
1375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool force_online_signin() const { return force_online_signin_; }
1385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // True if the user's session can be locked (i.e. the user has a password with
1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // which to unlock the session).
1415f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  bool can_lock() const;
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1435f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Returns empty string when home dir hasn't been mounted yet.
1445f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  std::string username_hash() const;
145c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
146c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // True if current user is logged in.
1475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  bool is_logged_in() const;
148c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
149c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // True if current user is active within the current session.
1505f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  bool is_active() const;
151c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // True if the user Profile is created.
1535f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  bool is_profile_created() const { return profile_is_created_; }
1545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) protected:
1566e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  friend class UserManagerBase;
1576e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  friend class chromeos::ChromeUserManagerImpl;
1585f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  friend class chromeos::SupervisedUserManagerImpl;
1595f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  friend class chromeos::UserImageManagerImpl;
1605f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  friend class chromeos::UserSessionManager;
161116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // For testing:
1635f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  friend class chromeos::MockUserManager;
1645f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  friend class chromeos::FakeLoginUtils;
1655f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  friend class chromeos::FakeUserManager;
1665f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  friend class chromeos::UserAddingScreenTest;
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Do not allow anyone else to create new User instances.
1692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static User* CreateRegularUser(const std::string& email);
1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static User* CreateGuestUser();
1712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static User* CreateKioskAppUser(const std::string& kiosk_app_username);
1725f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  static User* CreateSupervisedUser(const std::string& username);
1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static User* CreateRetailModeUser();
1742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static User* CreatePublicAccountUser(const std::string& email);
1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  explicit User(const std::string& email);
1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~User();
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1795f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  const std::string* GetAccountLocale() const { return account_locale_.get(); }
18068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Setters are private so only UserManager can call them.
1824e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void SetAccountLocale(const std::string& resolved_account_locale);
18368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
1845f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  void SetImage(const UserImage& user_image, int image_index);
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetImageURL(const GURL& image_url);
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets a stub image until the next |SetImage| call. |image_index| may be
1895f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // one of |USER_IMAGE_EXTERNAL| or |USER_IMAGE_PROFILE|.
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If |is_loading| is |true|, that means user image is being loaded from file.
1915f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  void SetStubImage(const UserImage& stub_user_image,
1925f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                    int image_index,
1935f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                    bool is_loading);
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
195a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void set_display_name(const base::string16& display_name) {
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    display_name_ = display_name;
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
199cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void set_given_name(const base::string16& given_name) {
200cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    given_name_ = given_name;
201cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  }
202f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void set_display_email(const std::string& display_email) {
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    display_email_ = display_email;
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2075f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  const UserImage& user_image() const { return user_image_; }
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void set_oauth_token_status(OAuthTokenStatus status) {
2105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    oauth_token_status_ = status;
2115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
2125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void set_force_online_signin(bool force_online_signin) {
2145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    force_online_signin_ = force_online_signin;
2155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
2165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
217c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void set_username_hash(const std::string& username_hash) {
218c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    username_hash_ = username_hash;
219c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
220c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
2215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  void set_is_logged_in(bool is_logged_in) { is_logged_in_ = is_logged_in; }
222c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
2235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  void set_can_lock(bool can_lock) { can_lock_ = can_lock; }
2245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  void set_is_active(bool is_active) { is_active_ = is_active; }
226c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
2275f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  void set_profile_is_created() { profile_is_created_ = true; }
22868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
22968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // True if user has google account (not a guest or managed user).
23068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  bool has_gaia_account() const;
23168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
2322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string email_;
234a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 display_name_;
235a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 given_name_;
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The displayed user email, defaults to |email_|.
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string display_email_;
2385f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  UserImage user_image_;
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  OAuthTokenStatus oauth_token_status_;
2405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool force_online_signin_;
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
24268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // This is set to chromeos locale if account data has been downloaded.
24368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // (Or failed to download, but at least one download attempt finished).
24468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // An empty string indicates error in data load, or in
24568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // translation of Account locale to chromeos locale.
24668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  scoped_ptr<std::string> account_locale_;
24768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
248c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Used to identify homedir mount point.
249c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  std::string username_hash_;
250c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
2515f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Either index of a default image for the user, |USER_IMAGE_EXTERNAL| or
2525f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // |USER_IMAGE_PROFILE|.
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int image_index_;
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True if current user image is a stub set by a |SetStubImage| call.
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool image_is_stub_;
2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True if current user image is being loaded from file.
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool image_is_loading_;
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // True if user is able to lock screen.
2625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool can_lock_;
2635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
264c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // True if user is currently logged in in current session.
265c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  bool is_logged_in_;
266c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
267c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // True if user is currently logged in and active in current session.
268c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  bool is_active_;
269c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
27068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // True if user Profile is created
27168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  bool profile_is_created_;
27268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(User);
2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// List of known users.
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef std::vector<User*> UserList;
2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2795f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}  // namespace user_manager
2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2815f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#endif  // COMPONENTS_USER_MANAGER_USER_H_
282