chrome_user_selection_screen.h revision 03b57e008b61dfcb1fbad3aea950ae0e001748b0
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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_CHROME_USER_SELECTION_SCREEN_H_
6#define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_CHROME_USER_SELECTION_SCREEN_H_
7
8#include <map>
9#include <string>
10#include <vector>
11
12#include "base/compiler_specific.h"
13#include "base/macros.h"
14#include "base/memory/weak_ptr.h"
15#include "chrome/browser/chromeos/login/screens/user_selection_screen.h"
16#include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
17
18namespace chromeos {
19
20class ChromeUserSelectionScreen
21    : public UserSelectionScreen,
22      public policy::DeviceLocalAccountPolicyService::Observer {
23 public:
24  ChromeUserSelectionScreen();
25  virtual ~ChromeUserSelectionScreen();
26
27  // UserSelectionScreen:
28  virtual void Init(const user_manager::UserList& users,
29                    bool show_guest) OVERRIDE;
30  virtual void SendUserList() OVERRIDE;
31
32  // policy::DeviceLocalAccountPolicyService::Observer:
33  virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE;
34  virtual void OnDeviceLocalAccountsChanged() OVERRIDE;
35
36 private:
37  // Check whether the display name set by policy for a public session has
38  // changed and if so, notify the UI.
39  void CheckForPublicSessionDisplayNameChange(
40      policy::DeviceLocalAccountPolicyBroker* broker);
41
42  // Check whether the list of recommended locales set by policy for a public
43  // session has changed and if so, notify the UI.
44  void CheckForPublicSessionLocalePolicyChange(
45      policy::DeviceLocalAccountPolicyBroker* broker);
46
47  // Notify the UI that the display name for a public session has changed,
48  // taking the display name from the |User| owned by |UserManager|.
49  void SetPublicSessionDisplayName(const std::string& user_id);
50
51  // Send an updated list of locales for a public session to the UI, consisting
52  // of the |recommended_locales| followed by all other available locales.
53  void SetPublicSessionLocales(
54      const std::string& user_id,
55      const std::vector<std::string>& recommended_locales);
56
57  bool handler_initialized_;
58
59  policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_;
60
61  // Map from public session user IDs to their display names set by policy.
62  typedef std::map<std::string, std::string> DisplayNamesMap;
63  DisplayNamesMap public_session_display_names_;
64
65  base::WeakPtrFactory<ChromeUserSelectionScreen> weak_factory_;
66
67  DISALLOW_COPY_AND_ASSIGN(ChromeUserSelectionScreen);
68};
69
70}  // namespace chromeos
71
72#endif  // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_CHROME_USER_SELECTION_SCREEN_H_
73