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

Side by Side Diff: chrome/browser/chromeos/system/device_disabling_manager.h

Issue 711433002: Enable device disabling during normal operation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@f_4_425574_add_device_disabling_manager
Patch Set: Rebased. Created 6 years, 1 month 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_SYSTEM_DEVICE_DISABLING_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_DEVICE_DISABLING_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_DEVICE_DISABLING_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_DEVICE_DISABLING_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h"
15 #include "chrome/browser/chromeos/settings/cros_settings.h"
13 16
14 namespace policy { 17 namespace policy {
15 class BrowserPolicyConnectorChromeOS; 18 class BrowserPolicyConnectorChromeOS;
16 } 19 }
17 20
21 namespace user_manager {
22 class UserManager;
23 }
24
18 namespace chromeos { 25 namespace chromeos {
19 namespace system { 26 namespace system {
20 27
21 // If an enrolled device is lost or stolen, it can be remotely disabled by its 28 // If an enrolled device is lost or stolen, it can be remotely disabled by its
22 // owner. The disabling is triggered in two different ways, depending on the 29 // owner. The disabling is triggered in two different ways, depending on the
23 // state the device is in: 30 // state the device is in:
24 // - If the device has been wiped, it will perform a hash dance during OOBE to 31 // - If the device has been wiped, it will perform a hash dance during OOBE to
25 // find out whether any persistent state has been stored for it on the server. 32 // find out whether any persistent state has been stored for it on the server.
26 // If so, persistent state is retrieved as a |DeviceStateRetrievalResponse| 33 // If so, persistent state is retrieved as a |DeviceStateRetrievalResponse|
27 // protobuf, parsed and written to the |prefs::kServerBackedDeviceState| local 34 // protobuf, parsed and written to the |prefs::kServerBackedDeviceState| local
28 // state pref. At the appropriate place in the OOBE flow, the 35 // state pref. At the appropriate place in the OOBE flow, the
29 // |WizardController| will call CheckWhetherDeviceDisabledDuringOOBE() to find 36 // |WizardController| will call CheckWhetherDeviceDisabledDuringOOBE() to find
30 // out whether the device is disabled, causing it to either show or skip the 37 // out whether the device is disabled, causing it to either show or skip the
31 // device disabled screen. 38 // device disabled screen.
32 // - If the device has not been wiped, the disabled state is retrieved with 39 // - If the device has not been wiped, the disabled state is retrieved with
33 // every device policy fetch as part of the |PolicyData| protobuf, parsed and 40 // every device policy fetch as part of the |PolicyData| protobuf, parsed and
34 // written to the |chromeos::kDeviceDisabled| cros setting. 41 // written to the |chromeos::kDeviceDisabled| cros setting. This class
35 // 42 // monitors the cros setting. When the device becomes disabled, one of two
36 // TODO(bartfab): Make this class subscribe to the cros setting and trigger 43 // actions is taken:
37 // the device disabled screen. http://crbug.com/425574 44 // 1) If no session is in progress, the device disabled screen is shown
45 // immediately.
46 // 2) If a session is in progress, the session is terminated. After Chrome has
47 // restarted on the login screen, the disabled screen is shown per 1).
48 // This ensures that when a device is disabled, there is never any user
49 // session running in the backround.
50 // When the device is re-enabled, Chrome is restarted once more to resume the
51 // regular login screen flows from a known-good point.
38 class DeviceDisablingManager { 52 class DeviceDisablingManager {
39 public: 53 public:
40 using DeviceDisabledCheckCallback = base::Callback<void(bool)>; 54 using DeviceDisabledCheckCallback = base::Callback<void(bool)>;
41 55
42 explicit DeviceDisablingManager( 56 class Observer {
43 policy::BrowserPolicyConnectorChromeOS* browser_policy_connector); 57 public:
58 virtual ~Observer();
59
60 virtual void OnDisabledMessageChanged(
61 const std::string& disabled_message) = 0;
62
63 private:
64 DISALLOW_ASSIGN(Observer);
65 };
66
67 class Delegate {
68 public:
69 virtual ~Delegate();
70
71 // Terminate the current session (if any) and restart Chrome to show the
72 // login screen.
73 virtual void RestartToLoginScreen() = 0;
74
75 // Show the device disabled screen.
76 virtual void ShowDeviceDisabledScreen() = 0;
77
78 private:
79 DISALLOW_ASSIGN(Delegate);
80 };
81
82 // If |delegate| is a nullptr, a default Delegate implementation will be used.
83 // Otherwise, the specified |delegate| must outlive |this| and will be used.
84 DeviceDisablingManager(
85 Delegate* delegate,
86 CrosSettings* cros_settings,
87 user_manager::UserManager* user_manager);
88
89 void AddObserver(Observer* observer);
90 void RemoveObserver(Observer* observer);
44 91
45 // Returns the cached disabled message. The message is only guaranteed to be 92 // Returns the cached disabled message. The message is only guaranteed to be
46 // up to date if the disabled screen was triggered. 93 // up to date if the disabled screen was triggered.
47 const std::string& disabled_message() const { return disabled_message_; } 94 const std::string& disabled_message() const { return disabled_message_; }
48 95
49 // Checks whether the device is disabled. |callback| will be invoked with the 96 // Performs a check whether the device is disabled during OOBE. |callback|
50 // result of the check. 97 // will be invoked with the result of the check.
51 void CheckWhetherDeviceDisabledDuringOOBE( 98 void CheckWhetherDeviceDisabledDuringOOBE(
52 const DeviceDisabledCheckCallback& callback); 99 const DeviceDisabledCheckCallback& callback);
53 100
101 // Whenever trusted cros settings indicate that the device is disabled, this
102 // method should be used to check whether the device disabling is to be
103 // honored. If this method returns false, the device should not be disabled.
104 static bool HonorDeviceDisablingDuringNormalOperation();
105
54 private: 106 private:
107 // Cache the disabled message and inform observers if it changed.
108 void CacheDisabledMessageAndNotify(const std::string& disabled_message);
109
110 void UpdateFromCrosSettings();
111
112 scoped_ptr<Delegate> owned_delegate_;
achuithb 2014/11/07 00:15:17 This owned_delegate_, delegate_ business seems so
bartfab (slow) 2014/11/07 10:11:37 Done.
113 Delegate* delegate_;
55 policy::BrowserPolicyConnectorChromeOS* browser_policy_connector_; 114 policy::BrowserPolicyConnectorChromeOS* browser_policy_connector_;
115 CrosSettings* cros_settings_;
116 user_manager::UserManager* user_manager_;
117
118 ObserverList<Observer> observers_;
119
120 scoped_ptr<CrosSettings::ObserverSubscription> device_disabled_subscription_;
121 scoped_ptr<CrosSettings::ObserverSubscription> disabled_message_subscription_;
122
123 // Indicates whether the device was disabled when the cros settings were last
124 // read.
125 bool device_disabled_;
56 126
57 // A cached copy of the message to show on the device disabled screen. 127 // A cached copy of the message to show on the device disabled screen.
58 std::string disabled_message_; 128 std::string disabled_message_;
59 129
60 base::WeakPtrFactory<DeviceDisablingManager> weak_factory_; 130 base::WeakPtrFactory<DeviceDisablingManager> weak_factory_;
61 131
62 DISALLOW_COPY_AND_ASSIGN(DeviceDisablingManager); 132 DISALLOW_COPY_AND_ASSIGN(DeviceDisablingManager);
63 }; 133 };
64 134
65 } // namespace system 135 } // namespace system
66 } // namespace chromeos 136 } // namespace chromeos
67 137
68 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_DEVICE_DISABLING_MANAGER_H_ 138 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_DEVICE_DISABLING_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698