Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / multi_profile_user_controller.h
blob4c1a907de65f363abba83c806e004eec91d19ba2
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MULTI_PROFILE_USER_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MULTI_PROFILE_USER_CONTROLLER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_vector.h"
13 class PrefChangeRegistrar;
14 class PrefRegistrySimple;
15 class PrefService;
16 class Profile;
18 namespace user_prefs {
19 class PrefRegistrySyncable;
22 namespace chromeos {
24 class MultiProfileUserControllerDelegate;
25 class UserManager;
27 // MultiProfileUserController decides whether a user is allowed to be in a
28 // multi-profiles session. It caches the multiprofile user behavior pref backed
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.
31 class MultiProfileUserController {
32 public:
33 MultiProfileUserController(MultiProfileUserControllerDelegate* delegate,
34 PrefService* local_state);
35 ~MultiProfileUserController();
37 static void RegisterPrefs(PrefRegistrySimple* registry);
38 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
40 // Returns true if the user is allowed to be in the current session.
41 bool IsUserAllowedInSession(const std::string& user_email) const;
43 // Starts to observe the multiprofile user behavior pref of the given profile.
44 void StartObserving(Profile* user_profile);
46 // Removes the cached values for the given user.
47 void RemoveCachedValues(const std::string& user_email);
49 // Possible behavior values.
50 static const char kBehaviorUnrestricted[];
51 static const char kBehaviorPrimaryOnly[];
52 static const char kBehaviorNotAllowed[];
54 private:
55 friend class MultiProfileUserControllerTest;
57 // Gets/sets the cached policy value.
58 std::string GetCachedValue(const std::string& user_email) const;
59 void SetCachedValue(const std::string& user_email,
60 const std::string& behavior);
62 // Checks if all users are allowed in the current session.
63 void CheckSessionUsers();
65 // Invoked when user behavior pref value changes.
66 void OnUserPrefChanged(Profile* profile);
68 MultiProfileUserControllerDelegate* delegate_; // Not owned.
69 PrefService* local_state_; // Not owned.
70 ScopedVector<PrefChangeRegistrar> pref_watchers_;
72 DISALLOW_COPY_AND_ASSIGN(MultiProfileUserController);
75 } // namespace chromeos
77 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MULTI_PROFILE_USER_CONTROLLER_H_