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

Side by Side Diff: chrome/browser/chromeos/login/users/multi_profile_user_controller.h

Issue 420243002: Refactoring IsUserAllowedInSession and GetCachedValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_USERS_MULTI_PROFILE_USER_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 12 matching lines...) Expand all
23 23
24 class MultiProfileUserControllerDelegate; 24 class MultiProfileUserControllerDelegate;
25 class UserManager; 25 class UserManager;
26 26
27 // MultiProfileUserController decides whether a user is allowed to be in a 27 // MultiProfileUserController decides whether a user is allowed to be in a
28 // multi-profiles session. It caches the multi-profile user behavior pref backed 28 // multi-profiles session. It caches the multi-profile user behavior pref backed
29 // by user policy into local state so that the value is available before the 29 // by user policy into local state so that the value is available before the
30 // user login and checks if the meaning of the value is respected. 30 // user login and checks if the meaning of the value is respected.
31 class MultiProfileUserController { 31 class MultiProfileUserController {
32 public: 32 public:
33 // Return value of IsUserAllowedInSession(). 33 // Second return value of IsUserAllowedInSession().
34 enum UserAllowedInSessionResult { 34 enum UserAllowedInSessionReason {
35 // User is allowed in multi-profile session. 35 // User is allowed in multi-profile session.
36 ALLOWED, 36 ALLOWED,
37 37
38 // Owner of the device is not allowed to be added as a secondary user. 38 // Owner of the device is not allowed to be added as a secondary user.
39 NOT_ALLOWED_OWNER_AS_SECONDARY, 39 NOT_ALLOWED_OWNER_AS_SECONDARY,
40 40
41 // Not allowed since it is potentially "tainted" with policy-pushed 41 // Not allowed since it is potentially "tainted" with policy-pushed
42 // certificates. 42 // certificates.
43 NOT_ALLOWED_POLICY_CERT_TAINTED, 43 NOT_ALLOWED_POLICY_CERT_TAINTED,
44 44
(...skipping 13 matching lines...) Expand all
58 MultiProfileUserController(MultiProfileUserControllerDelegate* delegate, 58 MultiProfileUserController(MultiProfileUserControllerDelegate* delegate,
59 PrefService* local_state); 59 PrefService* local_state);
60 ~MultiProfileUserController(); 60 ~MultiProfileUserController();
61 61
62 static void RegisterPrefs(PrefRegistrySimple* registry); 62 static void RegisterPrefs(PrefRegistrySimple* registry);
63 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 63 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
64 64
65 // Returns the cached policy value for |user_email|. 65 // Returns the cached policy value for |user_email|.
66 std::string GetCachedValue(const std::string& user_email) const; 66 std::string GetCachedValue(const std::string& user_email) const;
67 67
68 // Returns UserAllowedInSessionResult enum that describe whether the user is 68 // Returns true if user allowed to be in the current session. If |reason| not
69 // allowed to be in the current session. 69 // null stores UserAllowedInSessionReason enum that describes actual reason.
70 UserAllowedInSessionResult IsUserAllowedInSession( 70 bool IsUserAllowedInSession(const std::string& user_email,
71 const std::string& user_email) const; 71 UserAllowedInSessionReason* reason) const;
72 72
73 // Starts to observe the multiprofile user behavior pref of the given profile. 73 // Starts to observe the multiprofile user behavior pref of the given profile.
74 void StartObserving(Profile* user_profile); 74 void StartObserving(Profile* user_profile);
75 75
76 // Removes the cached values for the given user. 76 // Removes the cached values for the given user.
77 void RemoveCachedValues(const std::string& user_email); 77 void RemoveCachedValues(const std::string& user_email);
78 78
79 // Possible behavior values. 79 // Possible behavior values.
80 static const char kBehaviorUnrestricted[]; 80 static const char kBehaviorUnrestricted[];
81 static const char kBehaviorPrimaryOnly[]; 81 static const char kBehaviorPrimaryOnly[];
(...skipping 16 matching lines...) Expand all
98 MultiProfileUserControllerDelegate* delegate_; // Not owned. 98 MultiProfileUserControllerDelegate* delegate_; // Not owned.
99 PrefService* local_state_; // Not owned. 99 PrefService* local_state_; // Not owned.
100 ScopedVector<PrefChangeRegistrar> pref_watchers_; 100 ScopedVector<PrefChangeRegistrar> pref_watchers_;
101 101
102 DISALLOW_COPY_AND_ASSIGN(MultiProfileUserController); 102 DISALLOW_COPY_AND_ASSIGN(MultiProfileUserController);
103 }; 103 };
104 104
105 } // namespace chromeos 105 } // namespace chromeos
106 106
107 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_ 107 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698