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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/shutdown_policy_observer.h

Issue 776093004: Add device policy to disallow shutdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
(Empty)
1 // Copyright (c) 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_UI_WEBUI_CHROMEOS_LOGIN_SHUTDOWN_POLICY_OBSERVER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SHUTDOWN_POLICY_OBSERVER_H_
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/chromeos/settings/cros_settings.h"
12
13 namespace chromeos {
14
15 // This class observes the device setting "DeviceShutdownAllowed". Changes to
16 // this policy are communicated to the ShutdownPolicyObserver::Delegate by
17 // calling its OnShutdownPolicyChanged method with the new state of the policy.
18 class ShutdownPolicyObserver {
19 public:
20 using ShutdownAllowedCallback = base::Callback<void(bool)>;
21
22 // This delegate is called when the "DeviceShutdownAllowed" policy changes.
23 class Delegate {
24 public:
25 virtual void OnShutdownPolicyChanged(bool shutdown_allowed) = 0;
26 protected:
27 virtual ~Delegate() {}
28 };
29
30 ShutdownPolicyObserver(CrosSettings* cros_settings, Delegate* delegate);
31 ~ShutdownPolicyObserver();
32
33 void CheckIfShutdownAllowed(const ShutdownAllowedCallback& callback);
34
35 // Resets the policy subscription and clears the delegate.
36 void Shutdown();
37 private:
38 void OnShutdownPolicyChanged();
39
40 CrosSettings* cros_settings_;
41
42 Delegate* delegate_;
43
44 scoped_ptr<CrosSettings::ObserverSubscription> shutdown_policy_subscription_;
45
46 base::WeakPtrFactory<ShutdownPolicyObserver> weak_factory_;
47
48 DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyObserver);
49 };
50
51 } // namespace chromeos
52
53 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SHUTDOWN_POLICY_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698